### Question:
TokenValidator implements AuthorizationProvider { @Override public IdentifyingToken validate(IdentifyingToken identification, @Nullable ChargingStationId chargingStationId) { LOG.debug("validate({}, {})", identification.getToken(), chargingStationId); try { String hiddenId = identification.getToken(); String visibleId = identification.getVisibleId(); Token token = null; if (hiddenId != null) { token = ocpiRepository.findTokenByUid(hiddenId); } else { token = ocpiRepository.findTokenByVisualNumber(visibleId); } if (token != null) { if (token.isValid()) { LOG.debug("Token valid: {}", token.getUid()); return new TextualToken(identification.getToken(), AuthenticationStatus.ACCEPTED, token.getIssuingCompany(), token.getVisualNumber()); } else { LOG.debug("Token not valid: {}", token.getUid()); } } else { LOG.debug("Token not found: {}", identification.getToken()); } } catch (Exception e) { LOG.error("Exception OCPI authorization", e); } return identification; }  @Override IdentifyingToken validate(IdentifyingToken identification, @Nullable ChargingStationId chargingStationId); void setOcpiRepository(OcpiRepository ocpiRepository);  }### Answer:
@Test public void testIsValidByUid() { when(ocpiRepository.findTokenByUid(IDENTIFYING_TOKEN.getToken())) .thenReturn(getToken(IDENTIFYING_TOKEN.getToken(), Boolean.TRUE)); assertTrue(tokenValidator.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).isValid()); assertEquals(tokenValidator.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).getToken(), IDENTIFYING_TOKEN.getToken()); }
@Test public void testIsInvalidByUid() { when(ocpiRepository.findTokenByUid(IDENTIFYING_TOKEN.getToken())) .thenReturn(getToken(IDENTIFYING_TOKEN.getToken(), Boolean.FALSE)); assertFalse(tokenValidator.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).isValid()); assertEquals(tokenValidator.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).getToken(), IDENTIFYING_TOKEN.getToken()); }