@Test public void punish() { ActivePunishmentService service = mock(ActivePunishmentService.class); Excuse excuse = mock(Excuse.class); ProxyKick proxyKick = mock(ProxyKick.class); Ban ban = new Ban( service, excuse, proxyKick ); PunishmentParameters punishmentParameters = new PunishmentParameters( "target", "punisher", "reason", Duration.ofDays(10) ); PunishResult returnResult = new PunishResult( mock(PunishmentRecord.class), PunishResultType.OK ); when(service.punish(eq(punishmentParameters), eq(ActivePunishmentType.BAN))) .thenReturn(returnResult); PunishResult result = ban.punish( punishmentParameters ); assertSame(returnResult, result); verify(proxyKick).kick(eq("target"), eq("reason")); }
@Override public PunishResult punish(PunishmentParameters punishmentParameters) { return punishmentService .punish(punishmentParameters, ActivePunishmentType.BAN) .ifPresent(record -> proxyKick.kick( punishmentParameters.getTargetName(), punishmentParameters.getReason() )); }
Ban implements ActivePunishment { @Override public PunishResult punish(PunishmentParameters punishmentParameters) { return punishmentService .punish(punishmentParameters, ActivePunishmentType.BAN) .ifPresent(record -> proxyKick.kick( punishmentParameters.getTargetName(), punishmentParameters.getReason() )); } }
Ban implements ActivePunishment { @Override public PunishResult punish(PunishmentParameters punishmentParameters) { return punishmentService .punish(punishmentParameters, ActivePunishmentType.BAN) .ifPresent(record -> proxyKick.kick( punishmentParameters.getTargetName(), punishmentParameters.getReason() )); }  }
Ban implements ActivePunishment { @Override public PunishResult punish(PunishmentParameters punishmentParameters) { return punishmentService .punish(punishmentParameters, ActivePunishmentType.BAN) .ifPresent(record -> proxyKick.kick( punishmentParameters.getTargetName(), punishmentParameters.getReason() )); }  @Override PunishResult punish(PunishmentParameters punishmentParameters); @Override void excuse(UUID uuid); }
Ban implements ActivePunishment { @Override public PunishResult punish(PunishmentParameters punishmentParameters) { return punishmentService .punish(punishmentParameters, ActivePunishmentType.BAN) .ifPresent(record -> proxyKick.kick( punishmentParameters.getTargetName(), punishmentParameters.getReason() )); }  @Override PunishResult punish(PunishmentParameters punishmentParameters); @Override void excuse(UUID uuid);  }