@Test public void ignore() { PlayerProfileRepository playerRepository = mock(PlayerProfileRepository.class); IgnoreRepository ignoreRepository = mock(IgnoreRepository.class); IgnoreService ignoreService = new IgnoreService(playerRepository, ignoreRepository); PlayerProfile profile = mock(PlayerProfile.class); UUID src = UUID.randomUUID(); when(playerRepository.find(any(), any())).thenReturn(Optional.of(profile)); when(ignoreRepository.ignore(eq(src), eq(profile))).thenReturn( true ); assertEquals(IgnoreResult.IGNORED, ignoreService.ignore(src, "target")); }
public IgnoreResult ignore(UUID who, String target) { return playerProfileRepository .find(new PlayerNameSpecification(target)) .map(profile -> ignoreRepository.ignore(who, profile) ? IgnoreResult.IGNORED : IgnoreResult.ALREADY_IGNORING) .orElse(IgnoreResult.NOT_FOUND); }
IgnoreService { public IgnoreResult ignore(UUID who, String target) { return playerProfileRepository .find(new PlayerNameSpecification(target)) .map(profile -> ignoreRepository.ignore(who, profile) ? IgnoreResult.IGNORED : IgnoreResult.ALREADY_IGNORING) .orElse(IgnoreResult.NOT_FOUND); } }
IgnoreService { public IgnoreResult ignore(UUID who, String target) { return playerProfileRepository .find(new PlayerNameSpecification(target)) .map(profile -> ignoreRepository.ignore(who, profile) ? IgnoreResult.IGNORED : IgnoreResult.ALREADY_IGNORING) .orElse(IgnoreResult.NOT_FOUND); }  }
IgnoreService { public IgnoreResult ignore(UUID who, String target) { return playerProfileRepository .find(new PlayerNameSpecification(target)) .map(profile -> ignoreRepository.ignore(who, profile) ? IgnoreResult.IGNORED : IgnoreResult.ALREADY_IGNORING) .orElse(IgnoreResult.NOT_FOUND); }  IgnoreResult ignore(UUID who, String target); IgnoreRemoveResult removeIgnore(UUID who, String target); List<IgnoreHistoryElement> getHistory(UUID who, int page); boolean isIgnoring(UUID who, String target); }
IgnoreService { public IgnoreResult ignore(UUID who, String target) { return playerProfileRepository .find(new PlayerNameSpecification(target)) .map(profile -> ignoreRepository.ignore(who, profile) ? IgnoreResult.IGNORED : IgnoreResult.ALREADY_IGNORING) .orElse(IgnoreResult.NOT_FOUND); }  IgnoreResult ignore(UUID who, String target); IgnoreRemoveResult removeIgnore(UUID who, String target); List<IgnoreHistoryElement> getHistory(UUID who, int page); boolean isIgnoring(UUID who, String target);  }