From c9a84787cd8d3ebb142b11096c5693ca44cfcff2 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Mon, 30 Dec 2019 14:24:22 +0100 Subject: Implement ZMI removals in Stanik --- .../mimuw/cloudatlas/agent/modules/StanikTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent') 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"); + } } -- cgit v1.2.3