@Test(expected = IllegalArgumentException.class) public void testUpdate_nullId() { ResourceSet rs = new ResourceSet(); rs.setId(1L); ResourceSet rs2 = new ResourceSet(); resourceSetService.update(rs, rs2); }
@Override public ResourceSet update(ResourceSet oldRs, ResourceSet newRs) { if (oldRs.getId() == null || newRs.getId() == null || !oldRs.getId().equals(newRs.getId())) { throw new IllegalArgumentException("Resource set IDs mismatched"); } if (!checkScopeConsistency(newRs)) { throw new IllegalArgumentException("Can't save a resource set with inconsistent claims."); } newRs.setOwner(oldRs.getOwner()); newRs.setClientId(oldRs.getClientId()); ResourceSet saved = repository.save(newRs); return saved; }
DefaultResourceSetService implements ResourceSetService { @Override public ResourceSet update(ResourceSet oldRs, ResourceSet newRs) { if (oldRs.getId() == null || newRs.getId() == null || !oldRs.getId().equals(newRs.getId())) { throw new IllegalArgumentException("Resource set IDs mismatched"); } if (!checkScopeConsistency(newRs)) { throw new IllegalArgumentException("Can't save a resource set with inconsistent claims."); } newRs.setOwner(oldRs.getOwner()); newRs.setClientId(oldRs.getClientId()); ResourceSet saved = repository.save(newRs); return saved; } }
DefaultResourceSetService implements ResourceSetService { @Override public ResourceSet update(ResourceSet oldRs, ResourceSet newRs) { if (oldRs.getId() == null || newRs.getId() == null || !oldRs.getId().equals(newRs.getId())) { throw new IllegalArgumentException("Resource set IDs mismatched"); } if (!checkScopeConsistency(newRs)) { throw new IllegalArgumentException("Can't save a resource set with inconsistent claims."); } newRs.setOwner(oldRs.getOwner()); newRs.setClientId(oldRs.getClientId()); ResourceSet saved = repository.save(newRs); return saved; }  }
DefaultResourceSetService implements ResourceSetService { @Override public ResourceSet update(ResourceSet oldRs, ResourceSet newRs) { if (oldRs.getId() == null || newRs.getId() == null || !oldRs.getId().equals(newRs.getId())) { throw new IllegalArgumentException("Resource set IDs mismatched"); } if (!checkScopeConsistency(newRs)) { throw new IllegalArgumentException("Can't save a resource set with inconsistent claims."); } newRs.setOwner(oldRs.getOwner()); newRs.setClientId(oldRs.getClientId()); ResourceSet saved = repository.save(newRs); return saved; }  @Override ResourceSet saveNew(ResourceSet rs); @Override ResourceSet getById(Long id); @Override ResourceSet update(ResourceSet oldRs, ResourceSet newRs); @Override void remove(ResourceSet rs); @Override Collection<ResourceSet> getAllForOwner(String owner); @Override Collection<ResourceSet> getAllForOwnerAndClient(String owner, String clientId); @Override Collection<ResourceSet> getAllForClient(ClientDetailsEntity client); }
DefaultResourceSetService implements ResourceSetService { @Override public ResourceSet update(ResourceSet oldRs, ResourceSet newRs) { if (oldRs.getId() == null || newRs.getId() == null || !oldRs.getId().equals(newRs.getId())) { throw new IllegalArgumentException("Resource set IDs mismatched"); } if (!checkScopeConsistency(newRs)) { throw new IllegalArgumentException("Can't save a resource set with inconsistent claims."); } newRs.setOwner(oldRs.getOwner()); newRs.setClientId(oldRs.getClientId()); ResourceSet saved = repository.save(newRs); return saved; }  @Override ResourceSet saveNew(ResourceSet rs); @Override ResourceSet getById(Long id); @Override ResourceSet update(ResourceSet oldRs, ResourceSet newRs); @Override void remove(ResourceSet rs); @Override Collection<ResourceSet> getAllForOwner(String owner); @Override Collection<ResourceSet> getAllForOwnerAndClient(String owner, String clientId); @Override Collection<ResourceSet> getAllForClient(ClientDetailsEntity client);  }