m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent/modules')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java49
1 files changed, 49 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
new file mode 100644
index 0000000..7c869e7
--- /dev/null
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java
@@ -0,0 +1,49 @@
+package pl.edu.mimuw.cloudatlas.agent.modules;
+
+import java.util.List;
+import java.util.Map.Entry;
+
+import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage;
+import pl.edu.mimuw.cloudatlas.agent.messages.GetHierarchyMessage;
+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.Value;
+import pl.edu.mimuw.cloudatlas.model.ZMI;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class StanikTest {
+ private Stanik stanik;
+ private MockExecutor executor;
+
+ @Before
+ public void setupEventBus() {
+ stanik = new Stanik();
+ executor = new MockExecutor(stanik);
+ }
+
+ @Test
+ public void getEmptyHierarchy() throws Exception {
+ GetHierarchyMessage message = new GetHierarchyMessage("test_msg", 0, ModuleType.TEST, 42);
+ stanik.handleTyped(message);
+ assertEquals(1, executor.messagesToPass.size());
+ ResponseMessage receivedMessage = (ResponseMessage) executor.messagesToPass.take();
+ assertEquals(ModuleType.TEST, receivedMessage.getDestinationModule());
+ assertEquals(ResponseMessage.Type.HIERARCHY, receivedMessage.getType());
+ assertEquals(42, receivedMessage.getRequestId());
+ HierarchyMessage hierarchyMessage = (HierarchyMessage) receivedMessage;
+ ZMI zmi = hierarchyMessage.getZMI();
+ assertNull(zmi.getFather());
+ assertTrue(zmi.getSons().isEmpty());
+ boolean empty = true;
+ for (Entry<Attribute, Value> entry : zmi.getAttributes()) {
+ empty = false;
+ break;
+ }
+ assertTrue(empty);
+ }
+}