### Question:
PartyService { public boolean partyChat(String member, String text) { return partyRepository.getPartyOwner(member) .map(owner -> { playerMessaging.distribute(partyRepository.getPartyMembers(owner), s -> new PartyChat(s, text, member) ); return true; }).orElse(Boolean.FALSE); }  CreateResult create(String playerName); Set<String> getInvitedMembers(String playerName); RemoveResult remove(String applicant, String playerName); AcceptResult accept(String owner, String player); DisbandResult disband(String playerName); InviteResult invite(String owner, String player); boolean partyChat(String member, String text); static final int EXPIRATION_TIME; }### Answer:
@Test public void chat() { PartyRepository partyRepository = mock(PartyRepository.class); PlayerMessaging playerMessaging = mock(PlayerMessaging.class); PartyService partyService = new PartyService( partyRepository, mock(PreferencesRepository.class), playerMessaging ); when(partyRepository.getPartyOwner(eq("member"))).thenReturn( Optional.of("owner") ); when(partyRepository.getPartyMembers("owner")).thenReturn( new HashSet<>(Arrays.asList("a", "b", "c", "owner") )); partyService.partyChat("member", "hello world"); verify(playerMessaging).distribute( eq(new HashSet<>(Arrays.asList("a", "b", "c", "owner"))), any() ); }