@Test public void loadClientByClientId_badId() { try { service.loadClientByClientId(null); fail("Null client id. Expected an IllegalArgumentException."); } catch (IllegalArgumentException e) { assertThat(e, is(notNullValue())); } try { service.loadClientByClientId(""); fail("Empty client id. Expected an IllegalArgumentException."); } catch (IllegalArgumentException e) { assertThat(e, is(notNullValue())); } String clientId = "b00g3r"; Mockito.when(clientRepository.getClientByClientId(clientId)).thenReturn(null); try { service.loadClientByClientId(clientId); fail("Client id not found. Expected an InvalidClientException."); } catch (InvalidClientException e) { assertThat(e, is(notNullValue())); } }
@Override public ClientDetailsEntity loadClientByClientId(String clientId) throws OAuth2Exception, InvalidClientException, IllegalArgumentException { if (!Strings.isNullOrEmpty(clientId)) { ClientDetailsEntity client = clientRepository.getClientByClientId(clientId); if (client == null) { throw new InvalidClientException("Client with id " + clientId + " was not found"); } else { return client; } } throw new IllegalArgumentException("Client id must not be empty!"); }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity loadClientByClientId(String clientId) throws OAuth2Exception, InvalidClientException, IllegalArgumentException { if (!Strings.isNullOrEmpty(clientId)) { ClientDetailsEntity client = clientRepository.getClientByClientId(clientId); if (client == null) { throw new InvalidClientException("Client with id " + clientId + " was not found"); } else { return client; } } throw new IllegalArgumentException("Client id must not be empty!"); } }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity loadClientByClientId(String clientId) throws OAuth2Exception, InvalidClientException, IllegalArgumentException { if (!Strings.isNullOrEmpty(clientId)) { ClientDetailsEntity client = clientRepository.getClientByClientId(clientId); if (client == null) { throw new InvalidClientException("Client with id " + clientId + " was not found"); } else { return client; } } throw new IllegalArgumentException("Client id must not be empty!"); }  }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity loadClientByClientId(String clientId) throws OAuth2Exception, InvalidClientException, IllegalArgumentException { if (!Strings.isNullOrEmpty(clientId)) { ClientDetailsEntity client = clientRepository.getClientByClientId(clientId); if (client == null) { throw new InvalidClientException("Client with id " + clientId + " was not found"); } else { return client; } } throw new IllegalArgumentException("Client id must not be empty!"); }  @Override ClientDetailsEntity saveNewClient(ClientDetailsEntity client); @Override ClientDetailsEntity getClientById(Long id); @Override ClientDetailsEntity loadClientByClientId(String clientId); @Override void deleteClient(ClientDetailsEntity client); @Override ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient); @Override Collection<ClientDetailsEntity> getAllClients(); @Override ClientDetailsEntity generateClientId(ClientDetailsEntity client); @Override ClientDetailsEntity generateClientSecret(ClientDetailsEntity client); }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity loadClientByClientId(String clientId) throws OAuth2Exception, InvalidClientException, IllegalArgumentException { if (!Strings.isNullOrEmpty(clientId)) { ClientDetailsEntity client = clientRepository.getClientByClientId(clientId); if (client == null) { throw new InvalidClientException("Client with id " + clientId + " was not found"); } else { return client; } } throw new IllegalArgumentException("Client id must not be empty!"); }  @Override ClientDetailsEntity saveNewClient(ClientDetailsEntity client); @Override ClientDetailsEntity getClientById(Long id); @Override ClientDetailsEntity loadClientByClientId(String clientId); @Override void deleteClient(ClientDetailsEntity client); @Override ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient); @Override Collection<ClientDetailsEntity> getAllClients(); @Override ClientDetailsEntity generateClientId(ClientDetailsEntity client); @Override ClientDetailsEntity generateClientSecret(ClientDetailsEntity client);  }