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/GossipGirlTest.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java
new file mode 100644
index 0000000..0658b65
--- /dev/null
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java
@@ -0,0 +1,37 @@
+package pl.edu.mimuw.cloudatlas.agent.modules;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import pl.edu.mimuw.cloudatlas.agent.MockExecutor;
+import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage;
+import pl.edu.mimuw.cloudatlas.agent.messages.GetStateMessage;
+import pl.edu.mimuw.cloudatlas.agent.messages.GossipGirlMessage;
+import pl.edu.mimuw.cloudatlas.agent.messages.InitiateGossipMessage;
+import pl.edu.mimuw.cloudatlas.agent.messages.StanikMessage;
+
+public class GossipGirlTest {
+ private GossipGirl gossipGirl;
+ private MockExecutor executor;
+
+ @Before
+ public void setupLocals() {
+ gossipGirl = new GossipGirl();
+ executor = new MockExecutor(gossipGirl);
+ }
+
+ @Test
+ public void initiateGossipRequestsState() throws Exception {
+ InitiateGossipMessage message = new InitiateGossipMessage("test_msg", 0);
+ gossipGirl.handleTyped(message);
+
+ AgentMessage receivedMessage = executor.messagesToPass.poll();
+ assertNotNull(receivedMessage);
+ assertEquals(ModuleType.STATE, receivedMessage.getDestinationModule());
+ StanikMessage stanikMessage = (StanikMessage) receivedMessage;
+ assertEquals(StanikMessage.Type.GET_STATE, stanikMessage.getType());
+ GetStateMessage getStateMessage = (GetStateMessage) stanikMessage;
+ assertEquals(ModuleType.GOSSIP, getStateMessage.getRequestingModule());
+ }
+}