### Question:
LocalAuthorization implements AuthorizationProvider { @Override public IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId) { LOG.debug("validate({}, {})", identifyingToken.getToken(), chargingStationId); String stationIdentifier = null; if (chargingStationId != null) { stationIdentifier = chargingStationId.getId(); } LocalToken localToken = tokenRepository.findToken(identifyingToken.getToken(), stationIdentifier); if (localToken != null) { if (localToken.isValid()) { LOG.debug("Token valid: {}", localToken.getHiddenId()); return new TextualToken(localToken.getHiddenId(), IdentifyingToken.AuthenticationStatus.ACCEPTED, null, localToken.getVisualId()); } else { LOG.debug("Token not valid: {}", localToken.getHiddenId()); } } else { LOG.debug("Token {} not found for charging station {}", identifyingToken.getToken(), chargingStationId); } return identifyingToken; }  @Override IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId); void setTokenRepository(TokenRepository tokenRepository); void setChargingStationRepository(ChargingStationRepository chargingStationRepository);  }### Answer:
@Test public void validateShouldNotThrowExceptionIfTokenNotFound() { when(tokenRepository.findToken(IDENTIFYING_TOKEN.getToken(), CHARGING_STATION_ID.getId())).thenReturn(null); assertFalse(localAuthorization.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).isValid()); }
@Test public void validateShouldNotThrowExceptionIfChargingStationIdNull() { when(tokenRepository.findToken(IDENTIFYING_TOKEN.getToken(), null)).thenReturn(null); assertFalse(localAuthorization.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).isValid()); }
@Test public void validateShouldCheckTokenStatus() { when(tokenRepository.findToken(IDENTIFYING_TOKEN.getToken(), CHARGING_STATION_ID.getId())).thenReturn( new LocalToken(IDENTIFYING_TOKEN.getToken(), IDENTIFYING_TOKEN.getVisibleId(), true) ); assertTrue(localAuthorization.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).isValid()); when(tokenRepository.findToken(IDENTIFYING_TOKEN.getToken(), CHARGING_STATION_ID.getId())).thenReturn( new LocalToken(IDENTIFYING_TOKEN.getToken(), IDENTIFYING_TOKEN.getVisibleId(), false) ); assertFalse(localAuthorization.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).isValid()); }