m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas/agent
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-12-27 19:11:38 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-12-27 19:11:38 +0100
commit614e4e0d4fd07967f928fac122cc36b66a513944 (patch)
tree77ebe0b143c4a438a484ba9681b5f4c7e5481ecf /src/test/java/pl/edu/mimuw/cloudatlas/agent
parentafa32431d242d60471e5431d654784ee64b63bbf (diff)
Test GET_HIERARCHY deep copies
Diffstat (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java19
1 files changed, 19 insertions, 0 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 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"));
+ }
}