@Test public void updateClient_nullClients() { ClientDetailsEntity oldClient = Mockito.mock(ClientDetailsEntity.class); ClientDetailsEntity newClient = Mockito.mock(ClientDetailsEntity.class); try { service.updateClient(oldClient, null); fail("New client is null. Expected an IllegalArgumentException."); } catch (IllegalArgumentException e) { assertThat(e, is(notNullValue())); } try { service.updateClient(null, newClient); fail("Old client is null. Expected an IllegalArgumentException."); } catch (IllegalArgumentException e) { assertThat(e, is(notNullValue())); } try { service.updateClient(null, null); fail("Both clients are null. Expected an IllegalArgumentException."); } catch (IllegalArgumentException e) { assertThat(e, is(notNullValue())); } }
@Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); } }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); }  }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); }  @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 updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); }  @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);  }