From 4aaa6218b853873c632aba0ed8696f29640041d1 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Mon, 6 Jan 2020 16:55:11 +0100 Subject: Setup GossipGirl --- .../cloudatlas/agent/modules/GossipGirlTest.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java (limited to 'src/test/java/pl/edu') 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()); + } +} -- cgit v1.2.3