@Test public void anAddedTagSendsAPlayerEvent() { final Player player = playerWithTags(); when(playerRepository.findById(PLAYER_ID)).thenReturn(player); when(playerRepository.lock(PLAYER_ID)).thenReturn(player); underTest.processRequest(new PlayerTaggingRequest(PLAYER_ID, "abc", ADD)); verify(playerEventService).send(anEventWithTags("abc")); }
@Test public void anAddedTagIsSaved() { final Player player = playerWithTags(); when(playerRepository.findById(PLAYER_ID)).thenReturn(player); when(playerRepository.lock(PLAYER_ID)).thenReturn(player); underTest.processRequest(new PlayerTaggingRequest(PLAYER_ID, "abc", ADD)); verify(playerRepository).save(playerWithTags("abc")); }
@Test public void aTagCanBeRemoved() { final Player player = playerWithTags("abc"); when(playerRepository.findById(PLAYER_ID)).thenReturn(player); when(playerRepository.lock(PLAYER_ID)).thenReturn(player); underTest.processRequest(new PlayerTaggingRequest(PLAYER_ID, "abc", REMOVE)); verify(playerRepository).save(playerWithTags()); }
@Test public void removingANonExistentTagIsIgnored() { final Player player = playerWithTags(); when(playerRepository.findById(PLAYER_ID)).thenReturn(player); when(playerRepository.lock(PLAYER_ID)).thenReturn(player); underTest.processRequest(new PlayerTaggingRequest(PLAYER_ID, "abc", REMOVE)); verify(playerRepository, never()).save(any(Player.class)); verify(playerEventService, never()).send(any(PlayerEvent.class)); }