use of com.github.dedis.popstellar.model.network.method.message.data.election.ElectionResultQuestion in project popstellar by dedis.
the class ElectionHandlerTest method testHandleElectionResult.
@Test
public void testHandleElectionResult() throws DataHandlingException {
// Create the result Election message
QuestionResult questionResult = new QuestionResult(electionQuestion.getBallotOptions().get(0), 2);
ElectionResultQuestion electionResultQuestion = new ElectionResultQuestion("id", Collections.singletonList(questionResult));
ElectionResult electionResult = new ElectionResult(Collections.singletonList(electionResultQuestion));
MessageGeneral message = new MessageGeneral(SENDER_KEY, electionResult, GSON);
// Call the message handler
messageHandler.handleMessage(laoRepository, messageSender, LAO_CHANNEL.subChannel(election.getId()), message);
// Check the Election is present with state RESULTS_READY and the results
Optional<Election> electionOpt = laoRepository.getLaoByChannel(LAO_CHANNEL).getElection(election.getId());
assertTrue(electionOpt.isPresent());
assertEquals(EventState.RESULTS_READY, electionOpt.get().getState());
assertEquals(Collections.singletonList(questionResult), electionOpt.get().getResultsForQuestionId("id"));
}
Aggregations