diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2020-01-06 16:55:11 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2020-01-06 16:55:11 +0100 |
commit | 4aaa6218b853873c632aba0ed8696f29640041d1 (patch) | |
tree | f7a62eedf42972b879d78162fda3ec8ef286fafa /src/test/java/pl/edu/mimuw | |
parent | edd8c9d09b89a68a0d654dd6b08dc23a22d50293 (diff) |
Setup GossipGirl
Diffstat (limited to 'src/test/java/pl/edu/mimuw')
-rw-r--r-- | src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java | 37 |
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()); + } +} |