@Test(expected = InvalidClientException.class) public void deleteClient_badId() { Long id = 12345L; ClientDetailsEntity client = Mockito.mock(ClientDetailsEntity.class); Mockito.when(client.getId()).thenReturn(id); Mockito.when(clientRepository.getById(id)).thenReturn(null); service.deleteClient(client); }
@Override public void deleteClient(ClientDetailsEntity client) throws InvalidClientException { if (clientRepository.getById(client.getId()) == null) { throw new InvalidClientException("Client with id " + client.getClientId() + " was not found"); } tokenRepository.clearTokensForClient(client); approvedSiteService.clearApprovedSitesForClient(client); WhitelistedSite whitelistedSite = whitelistedSiteService.getByClientId(client.getClientId()); if (whitelistedSite != null) { whitelistedSiteService.remove(whitelistedSite); } clientRepository.deleteClient(client); statsService.resetCache(); }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public void deleteClient(ClientDetailsEntity client) throws InvalidClientException { if (clientRepository.getById(client.getId()) == null) { throw new InvalidClientException("Client with id " + client.getClientId() + " was not found"); } tokenRepository.clearTokensForClient(client); approvedSiteService.clearApprovedSitesForClient(client); WhitelistedSite whitelistedSite = whitelistedSiteService.getByClientId(client.getClientId()); if (whitelistedSite != null) { whitelistedSiteService.remove(whitelistedSite); } clientRepository.deleteClient(client); statsService.resetCache(); } }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public void deleteClient(ClientDetailsEntity client) throws InvalidClientException { if (clientRepository.getById(client.getId()) == null) { throw new InvalidClientException("Client with id " + client.getClientId() + " was not found"); } tokenRepository.clearTokensForClient(client); approvedSiteService.clearApprovedSitesForClient(client); WhitelistedSite whitelistedSite = whitelistedSiteService.getByClientId(client.getClientId()); if (whitelistedSite != null) { whitelistedSiteService.remove(whitelistedSite); } clientRepository.deleteClient(client); statsService.resetCache(); }  }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public void deleteClient(ClientDetailsEntity client) throws InvalidClientException { if (clientRepository.getById(client.getId()) == null) { throw new InvalidClientException("Client with id " + client.getClientId() + " was not found"); } tokenRepository.clearTokensForClient(client); approvedSiteService.clearApprovedSitesForClient(client); WhitelistedSite whitelistedSite = whitelistedSiteService.getByClientId(client.getClientId()); if (whitelistedSite != null) { whitelistedSiteService.remove(whitelistedSite); } clientRepository.deleteClient(client); statsService.resetCache(); }  @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 void deleteClient(ClientDetailsEntity client) throws InvalidClientException { if (clientRepository.getById(client.getId()) == null) { throw new InvalidClientException("Client with id " + client.getClientId() + " was not found"); } tokenRepository.clearTokensForClient(client); approvedSiteService.clearApprovedSitesForClient(client); WhitelistedSite whitelistedSite = whitelistedSiteService.getByClientId(client.getClientId()); if (whitelistedSite != null) { whitelistedSiteService.remove(whitelistedSite); } clientRepository.deleteClient(client); statsService.resetCache(); }  @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);  }