assertNotNull(connObjectTO);
// -----------------------------------
// Remove the first membership: de-provisioning shouldn't happen
// -----------------------------------
UserMod userMod = new UserMod();
userMod.setId(actual.getId());
userMod.addMembershipToBeRemoved(actual.getMemberships().get(0).getId());
actual = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
assertNotNull(actual);
assertEquals(1, actual.getMemberships().size());
connObjectTO = restTemplate.getForObject(BASE_URL
+ "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, "resource-csv",
actual.getDerivedAttributeMap().get("csvuserid").getValues().get(0));
assertNotNull(connObjectTO);
// -----------------------------------
// -----------------------------------
// Remove the resource assigned directly: de-provisioning shouldn't happen
// -----------------------------------
userMod = new UserMod();
userMod.setId(actual.getId());
userMod.addResourceToBeRemoved(actual.getResources().iterator().next());
actual = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
assertNotNull(actual);
assertEquals(1, actual.getMemberships().size());
assertFalse(actual.getResources().isEmpty());
connObjectTO = restTemplate.getForObject(BASE_URL
+ "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, "resource-csv", actual.
getDerivedAttributeMap().get("csvuserid").getValues().get(0));
assertNotNull(connObjectTO);
// -----------------------------------
// -----------------------------------
// Remove the first membership: de-provisioning should happen
// -----------------------------------
userMod = new UserMod();
userMod.setId(actual.getId());
userMod.addMembershipToBeRemoved(actual.getMemberships().get(0).getId());
actual = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
assertNotNull(actual);
assertTrue(actual.getMemberships().isEmpty());
assertTrue(actual.getResources().isEmpty());