### Question:
ActivePunishmentService { public PunishResult punish(PunishmentParameters punishmentParameters, ActivePunishmentType activePunishmentType) { return playerProfileRepository.find(new PlayerNameSpecification(punishmentParameters.getTargetName())) .map(playerProfile -> { PunishmentData punishmentData = punishmentDataProvider.getPunishmentsFor(playerProfile.getUuid()); ActivePunishmentRecord activePunishmentRecord = this.newPunishmentRecord(punishmentParameters, playerProfile, activePunishmentType); this.addActiveRecord(punishmentData, activePunishmentRecord, activePunishmentType); return new PunishResult(activePunishmentRecord, PunishResultType.OK); }) .orElse(PunishResult.NOT_FOUND); }  PunishResult punish(PunishmentParameters punishmentParameters, ActivePunishmentType activePunishmentType);  }### Answer:
@Test public void punish() { PunishmentDataProvider provider = mock(PunishmentDataProvider.class); PunishmentDataRepository dataRepository = mock(PunishmentDataRepository.class); PunishmentRepository repository = mock(PunishmentRepository.class); PlayerProfileRepository profileRepository = mock(PlayerProfileRepository.class); PlayerProfile profile = mock(PlayerProfile.class); UUID uuid = UUID.randomUUID(); when(profile.getUuid()).thenReturn(uuid); when(profileRepository.find(eq(new PlayerNameSpecification("target")))) .thenReturn(Optional.of(profile)); when(provider.getPunishmentsFor(eq(uuid))).thenReturn( mock(PunishmentData.class) ); ActivePunishmentService service = new ActivePunishmentService( provider, dataRepository, repository, profileRepository ); PunishmentParameters punishmentParameters = new PunishmentParameters( "target", "console", "Reason", Duration.of(10, ChronoUnit.DAYS) ); final PunishResult punish = service.punish( punishmentParameters, ActivePunishmentType.MUTE ); Assert.assertEquals(PunishResultType.OK, punish.getResultType()); PunishmentRecord punishmentRecord = punish.getPunishmentRecord(); assertSame(profile, punishmentRecord.getTarget()); Assert.assertEquals(PunishmentType.MUTE, punishmentRecord.getPunishmentType()); assertEquals("console", punishmentRecord.getPunisher()); }