@Test public void update_nullSites() { WhitelistedSite oldSite = Mockito.mock(WhitelistedSite.class); WhitelistedSite newSite = Mockito.mock(WhitelistedSite.class); try { service.update(null, newSite); fail("Old site input is null. Expected a IllegalArgumentException."); } catch (IllegalArgumentException e) { assertThat(e, is(notNullValue())); } try { service.update(oldSite, null); fail("New site input is null. Expected a IllegalArgumentException."); } catch (IllegalArgumentException e) { assertThat(e, is(notNullValue())); } try { service.update(null, null); fail("Both site inputs are null. Expected a IllegalArgumentException."); } catch (IllegalArgumentException e) { assertThat(e, is(notNullValue())); } }
@Override public WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite) { if (oldWhitelistedSite == null || whitelistedSite == null) { throw new IllegalArgumentException("Neither the old or new sites may be null"); } return repository.update(oldWhitelistedSite, whitelistedSite); }
DefaultWhitelistedSiteService implements WhitelistedSiteService { @Override public WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite) { if (oldWhitelistedSite == null || whitelistedSite == null) { throw new IllegalArgumentException("Neither the old or new sites may be null"); } return repository.update(oldWhitelistedSite, whitelistedSite); } }
DefaultWhitelistedSiteService implements WhitelistedSiteService { @Override public WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite) { if (oldWhitelistedSite == null || whitelistedSite == null) { throw new IllegalArgumentException("Neither the old or new sites may be null"); } return repository.update(oldWhitelistedSite, whitelistedSite); }  }
DefaultWhitelistedSiteService implements WhitelistedSiteService { @Override public WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite) { if (oldWhitelistedSite == null || whitelistedSite == null) { throw new IllegalArgumentException("Neither the old or new sites may be null"); } return repository.update(oldWhitelistedSite, whitelistedSite); }  @Override WhitelistedSite getById(Long id); @Override void remove(WhitelistedSite whitelistedSite); @Override WhitelistedSite saveNew(WhitelistedSite whitelistedSite); @Override Collection<WhitelistedSite> getAll(); @Override WhitelistedSite getByClientId(String clientId); @Override Collection<WhitelistedSite> getByCreator(String creatorId); @Override WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite); }
DefaultWhitelistedSiteService implements WhitelistedSiteService { @Override public WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite) { if (oldWhitelistedSite == null || whitelistedSite == null) { throw new IllegalArgumentException("Neither the old or new sites may be null"); } return repository.update(oldWhitelistedSite, whitelistedSite); }  @Override WhitelistedSite getById(Long id); @Override void remove(WhitelistedSite whitelistedSite); @Override WhitelistedSite saveNew(WhitelistedSite whitelistedSite); @Override Collection<WhitelistedSite> getAll(); @Override WhitelistedSite getByClientId(String clientId); @Override Collection<WhitelistedSite> getByCreator(String creatorId); @Override WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite);  }