From 614e4e0d4fd07967f928fac122cc36b66a513944 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Fri, 27 Dec 2019 19:11:38 +0100 Subject: Test GET_HIERARCHY deep copies --- .../mimuw/cloudatlas/agent/modules/StanikTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent/modules') 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 7c869e7..1c1e216 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 @@ -9,7 +9,9 @@ import pl.edu.mimuw.cloudatlas.agent.messages.HierarchyMessage; import pl.edu.mimuw.cloudatlas.agent.messages.ResponseMessage; import pl.edu.mimuw.cloudatlas.agent.MockExecutor; import pl.edu.mimuw.cloudatlas.model.Attribute; +import pl.edu.mimuw.cloudatlas.model.AttributesMap; import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueInt; import pl.edu.mimuw.cloudatlas.model.ZMI; import org.junit.Before; @@ -46,4 +48,21 @@ public class StanikTest { } assertTrue(empty); } + + @Test + public void hierarchyIsDeepCopy() throws Exception { + GetHierarchyMessage message = new GetHierarchyMessage("test_msg", 0, ModuleType.TEST, 42); + stanik.handleTyped(message); + HierarchyMessage receivedMessage = (HierarchyMessage) executor.messagesToPass.poll(); + assertNotNull(receivedMessage); + AttributesMap attributes = receivedMessage.getZMI().getAttributes(); + assertNull(attributes.getOrNull("foo")); + attributes.add("foo", new ValueInt(1337l)); + + GetHierarchyMessage newMessage = new GetHierarchyMessage("test_msg2", 123, ModuleType.TEST, 43); + stanik.handleTyped(newMessage); + HierarchyMessage newReceivedMessage = (HierarchyMessage) executor.messagesToPass.poll(); + AttributesMap newAttributes = newReceivedMessage.getZMI().getAttributes(); + assertNull(newAttributes.getOrNull("foo")); + } } -- cgit v1.2.3