@Test public void sendFinalStage() { MessagingService messagingService = mock(MessagingService.class); PlayerProfileRepository repository = mock(PlayerProfileRepository.class); PrivateMessageRepository pmRepository = mock(PrivateMessageRepository.class); FinalStage finalStage = new FinalStage( messagingService, repository, pmRepository); PlayerProfile targetProfile = mock(PlayerProfile.class); PrivateMessage privateMessage = new PrivateMessage( UUID.randomUUID(), "to", "text","fromName" ); when(repository.get(eq(privateMessage.getFrom()))).thenReturn(targetProfile); Assert.assertEquals( MessageSendResponse.OK, finalStage.sendFinalStage( targetProfile, privateMessage, "proxy") ); }
public MessageSendResponse sendFinalStage(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy) { PlayerProfile senderProfile = playerProfileRepository.get(privateMessage.getFrom()); PrivateMessageRecord privateMessageRecord = new PrivateMessageRecord(senderProfile, targetProfile, privateMessage.getText()); privateMessageRepository.save(privateMessageRecord); messagingService.send(new PrivateMessageCommand(senderProfile.getName(), privateMessage.getText()), targetProxy); return MessageSendResponse.OK; }
FinalStage { public MessageSendResponse sendFinalStage(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy) { PlayerProfile senderProfile = playerProfileRepository.get(privateMessage.getFrom()); PrivateMessageRecord privateMessageRecord = new PrivateMessageRecord(senderProfile, targetProfile, privateMessage.getText()); privateMessageRepository.save(privateMessageRecord); messagingService.send(new PrivateMessageCommand(senderProfile.getName(), privateMessage.getText()), targetProxy); return MessageSendResponse.OK; } }
FinalStage { public MessageSendResponse sendFinalStage(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy) { PlayerProfile senderProfile = playerProfileRepository.get(privateMessage.getFrom()); PrivateMessageRecord privateMessageRecord = new PrivateMessageRecord(senderProfile, targetProfile, privateMessage.getText()); privateMessageRepository.save(privateMessageRecord); messagingService.send(new PrivateMessageCommand(senderProfile.getName(), privateMessage.getText()), targetProxy); return MessageSendResponse.OK; }  }
FinalStage { public MessageSendResponse sendFinalStage(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy) { PlayerProfile senderProfile = playerProfileRepository.get(privateMessage.getFrom()); PrivateMessageRecord privateMessageRecord = new PrivateMessageRecord(senderProfile, targetProfile, privateMessage.getText()); privateMessageRepository.save(privateMessageRecord); messagingService.send(new PrivateMessageCommand(senderProfile.getName(), privateMessage.getText()), targetProxy); return MessageSendResponse.OK; }  MessageSendResponse sendFinalStage(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy); }
FinalStage { public MessageSendResponse sendFinalStage(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy) { PlayerProfile senderProfile = playerProfileRepository.get(privateMessage.getFrom()); PrivateMessageRecord privateMessageRecord = new PrivateMessageRecord(senderProfile, targetProfile, privateMessage.getText()); privateMessageRepository.save(privateMessageRecord); messagingService.send(new PrivateMessageCommand(senderProfile.getName(), privateMessage.getText()), targetProxy); return MessageSendResponse.OK; }  MessageSendResponse sendFinalStage(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy);  }