diff options
author | Martin <marcin.j.chrzanowski@gmail.com> | 2019-12-30 14:27:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-30 14:27:03 +0100 |
commit | 71452a391ecb6620ff3a06b80da5824b88cb4ad0 (patch) | |
tree | 665e88a50176b115bd0ea5ad9706dc64a3b8bdbf /src/test/java/pl/edu/mimuw | |
parent | 00b7eaac7f87f73d9492bd7f917719fd364b5731 (diff) | |
parent | 4def2fc74f86df8eb15ef8ecd6b0ed37e83f0803 (diff) |
Merge pull request #80 from m-chrzan/stanik-removal
Implement ZMI removals in Stanik
Diffstat (limited to 'src/test/java/pl/edu/mimuw')
-rw-r--r-- | src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java | 38 | ||||
-rw-r--r-- | src/test/java/pl/edu/mimuw/cloudatlas/model/TestUtil.java | 4 |
2 files changed, 38 insertions, 4 deletions
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 8958472..495a012 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 @@ -8,6 +8,7 @@ import java.util.Map.Entry; import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage; import pl.edu.mimuw.cloudatlas.agent.messages.GetStateMessage; import pl.edu.mimuw.cloudatlas.agent.messages.StateMessage; +import pl.edu.mimuw.cloudatlas.agent.messages.RemoveZMIMessage; import pl.edu.mimuw.cloudatlas.agent.messages.ResponseMessage; import pl.edu.mimuw.cloudatlas.agent.messages.UpdateAttributesMessage; import pl.edu.mimuw.cloudatlas.agent.messages.UpdateQueriesMessage; @@ -198,4 +199,41 @@ public class StanikTest { assertEquals(new ValueTime(43l), timestampedQuery4.getValue()); assertEquals(new ValueQuery("SELECT 1000 AS foo"), timestampedQuery4.getKey()); } + + @Test + public void removeZMI() throws Exception { + AttributesMap attributes = new AttributesMap(); + attributes.add("foo", new ValueInt(1337l)); + attributes.add("bar", new ValueString("baz")); + attributes.add("name", new ValueString("new")); + attributes.add("timestamp", new ValueTime(42l)); + UpdateAttributesMessage message = new UpdateAttributesMessage("test_msg", 0, "/new", attributes); + stanik.handleTyped(message); + + RemoveZMIMessage removeMessage = new RemoveZMIMessage("test_msg2", 0, "/new", new ValueTime(43l)); + stanik.handleTyped(removeMessage); + boolean noSuchZone = false; + try { + stanik.getHierarchy().findDescendant("/new"); + } catch (ZMI.NoSuchZoneException e) { + noSuchZone = true; + } + assertTrue(noSuchZone); + } + + @Test + public void dontRemoveZMIIfTimestampOlder() throws Exception { + AttributesMap attributes = new AttributesMap(); + attributes.add("foo", new ValueInt(1337l)); + attributes.add("bar", new ValueString("baz")); + attributes.add("name", new ValueString("new")); + attributes.add("timestamp", new ValueTime(42l)); + UpdateAttributesMessage message = new UpdateAttributesMessage("test_msg", 0, "/new", attributes); + stanik.handleTyped(message); + + RemoveZMIMessage removeMessage = new RemoveZMIMessage("test_msg2", 0, "/new", new ValueTime(41l)); + stanik.handleTyped(removeMessage); + + stanik.getHierarchy().findDescendant("/new"); + } } diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/model/TestUtil.java b/src/test/java/pl/edu/mimuw/cloudatlas/model/TestUtil.java index ed633d7..ddc61a9 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/model/TestUtil.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/model/TestUtil.java @@ -1,10 +1,6 @@ package pl.edu.mimuw.cloudatlas.model; public class TestUtil { - public static boolean valueLower(Value a, Value b) { - return ((ValueBoolean) a.isLowerThan(b)).getValue(); - } - public static <T> int iterableSize(Iterable<T> iterable) { int count = 0; for (T attribute : iterable) { |