m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java19
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java3
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementationTests.java3
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java2
4 files changed, 16 insertions, 11 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java
index 1e0bb4f..7419ad4 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java
@@ -50,6 +50,7 @@ import pl.edu.mimuw.cloudatlas.model.ValueList;
import pl.edu.mimuw.cloudatlas.model.ValueSet;
import pl.edu.mimuw.cloudatlas.model.ValueString;
import pl.edu.mimuw.cloudatlas.model.ValueTime;
+import pl.edu.mimuw.cloudatlas.model.ValueUtils;
import pl.edu.mimuw.cloudatlas.model.ZMI;
public class Main {
@@ -274,29 +275,31 @@ public class Main {
List<Value> list;
+ ValueTime time = ValueUtils.currentTime();
+
ZMI root = new ZMI();
root.getAttributes().add("level", new ValueInt(0l));
root.getAttributes().add("name", new ValueString(null));
- root.getAttributes().add("timestamp", new ValueTime(10l));
+ root.getAttributes().add("timestamp", time);
ZMI uw = new ZMI(root);
root.addSon(uw);
uw.getAttributes().add("level", new ValueInt(1l));
uw.getAttributes().add("name", new ValueString("uw"));
- uw.getAttributes().add("timestamp", new ValueTime(10l));
+ uw.getAttributes().add("timestamp", time);
ZMI pjwstk = new ZMI(root);
root.addSon(pjwstk);
pjwstk.getAttributes().add("level", new ValueInt(1l));
pjwstk.getAttributes().add("name", new ValueString("pjwstk"));
- pjwstk.getAttributes().add("timestamp", new ValueTime(10l));
+ pjwstk.getAttributes().add("timestamp", time);
ZMI violet07 = new ZMI(uw);
uw.addSon(violet07);
violet07.getAttributes().add("level", new ValueInt(2l));
violet07.getAttributes().add("name", new ValueString("violet07"));
violet07.getAttributes().add("owner", new ValueString("/uw/violet07"));
- violet07.getAttributes().add("timestamp", new ValueTime("2012/11/09 18:00:00.000"));
+ violet07.getAttributes().add("timestamp", time);
list = Arrays.asList(new Value[] {
violet07Contact, khaki31Contact, khaki13Contact
});
@@ -322,7 +325,7 @@ public class Main {
khaki31.getAttributes().add("level", new ValueInt(2l));
khaki31.getAttributes().add("name", new ValueString("khaki31"));
khaki31.getAttributes().add("owner", new ValueString("/uw/khaki31"));
- khaki31.getAttributes().add("timestamp", new ValueTime("2012/11/09 20:03:00.000"));
+ khaki31.getAttributes().add("timestamp", time);
list = Arrays.asList(new Value[] {
violet08Contact
});
@@ -348,7 +351,7 @@ public class Main {
khaki13.getAttributes().add("level", new ValueInt(2l));
khaki13.getAttributes().add("name", new ValueString("khaki13"));
khaki13.getAttributes().add("owner", new ValueString("/uw/khaki13"));
- khaki13.getAttributes().add("timestamp", new ValueTime("2012/11/09 21:03:00.000"));
+ khaki13.getAttributes().add("timestamp", time);
list = Arrays.asList(new Value[] {
khaki14Contact, khaki32Contact
});
@@ -372,7 +375,7 @@ public class Main {
whatever01.getAttributes().add("level", new ValueInt(2l));
whatever01.getAttributes().add("name", new ValueString("whatever01"));
whatever01.getAttributes().add("owner", new ValueString("/pjwstk/whatever01"));
- whatever01.getAttributes().add("timestamp", new ValueTime("2012/11/09 21:12:00.000"));
+ whatever01.getAttributes().add("timestamp", time);
list = Arrays.asList(new Value[] {
whatever02Contact,
});
@@ -396,7 +399,7 @@ public class Main {
whatever02.getAttributes().add("level", new ValueInt(2l));
whatever02.getAttributes().add("name", new ValueString("whatever02"));
whatever02.getAttributes().add("owner", new ValueString("/pjwstk/whatever02"));
- whatever02.getAttributes().add("timestamp", new ValueTime("2012/11/09 21:13:00.000"));
+ whatever02.getAttributes().add("timestamp", time);
list = Arrays.asList(new Value[] {
whatever01Contact,
});
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java
index 28b47a9..e4684cd 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java
@@ -95,7 +95,8 @@ public class AgentIntegrationTest {
assertEquals(new ValueInt(2l), attributes.get("level"));
assertEquals(new ValueString("whatever01"), attributes.get("name"));
assertEquals(new ValueString("/pjwstk/whatever01"), attributes.get("owner"));
- assertEquals(new ValueTime("2012/11/09 21:12:00.000"), attributes.get("timestamp"));
+ long timestamp = ((ValueTime) attributes.get("timestamp")).getValue();
+ assertTrue(timestamp <= System.currentTimeMillis());
assertEquals(new ValueInt(1l), attributes.get("cardinality"));
assertEquals(new ValueTime("2012/10/18 07:03:00.000"), attributes.get("creation"));
assertEquals(new ValueDouble(0.1), attributes.get("cpu_usage"));
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementationTests.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementationTests.java
index 0a7a8df..002c43c 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementationTests.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementationTests.java
@@ -63,7 +63,8 @@ public class ApiImplementationTests {
assertEquals(new ValueInt(2l), attributes.get("level"));
assertEquals(new ValueString("whatever01"), attributes.get("name"));
assertEquals(new ValueString("/pjwstk/whatever01"), attributes.get("owner"));
- assertEquals(new ValueTime("2012/11/09 21:12:00.000"), attributes.get("timestamp"));
+ long timestamp = ((ValueTime) attributes.get("timestamp")).getValue();
+ assertTrue(timestamp <= System.currentTimeMillis());
assertEquals(new ValueInt(1l), attributes.get("cardinality"));
assertEquals(new ValueTime("2012/10/18 07:03:00.000"), attributes.get("creation"));
assertEquals(new ValueDouble(0.1), attributes.get("cpu_usage"));
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java
index ab13642..1ca8608 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java
@@ -157,7 +157,7 @@ public class StanikTest {
public void dontApplyWithStaleTimestamp() throws Exception {
AttributesMap attributes = new AttributesMap();
attributes.add("foo", new ValueInt(1337l));
- attributes.add("timestamp", new ValueTime("2012/12/21 04:20:00.000"));
+ attributes.add("timestamp", (ValueTime) testTime.subtract(new ValueDuration(61 * 1000l)));
attributes.add("name", new ValueString("new"));
UpdateAttributesMessage message = new UpdateAttributesMessage("test_msg", 0, "/new", attributes);
stanik.handleTyped(message);