### Question:
PunishmentLink extends LoginChainLink { @Override protected void proceed(LoginDetails loginDetails) { this.load(loginDetails); this.checkBanned(loginDetails); super.proceedNext(loginDetails); }    }### Answer:
@Test(expected = LoginProcessingException.class) public void whenBannedThenDisallowed() { PunishmentChecker checker = mock(PunishmentChecker.class); PunishmentDataRepository repository = mock(PunishmentDataRepository.class); PunishmentLink link = new PunishmentLink(checker, repository); UUID uuid = UUID.randomUUID(); LoginDetails loginDetails = new LoginDetails( uuid, "target" ); when(repository.findPunishmentData(eq(uuid))).thenReturn( Optional.of(new PunishmentData(uuid)) ); when(checker.checkPunishment(eq(uuid), eq(ActivePunishmentType.BAN))) .thenReturn(Optional.of(mock(ActivePunishmentRecord.class))); try { link.proceed(loginDetails); } finally { verify(repository).put(eq(uuid), any()); verify(repository).invalidate(eq(uuid)); } }