}
@Test
public void issue186() {
// 1. create an user with strict mandatory attributes only
UserTO userTO = new UserTO();
String userId = getUUIDString() + "issue186@syncope.apache.org";
userTO.setUsername(userId);
userTO.setPassword("password");
userTO.addAttribute(attributeTO("userId", userId));
userTO.addAttribute(attributeTO("fullname", userId));
userTO.addAttribute(attributeTO("surname", userId));
userTO = createUser(userTO);
assertNotNull(userTO);
assertTrue(userTO.getResources().isEmpty());
// 2. update assigning a resource forcing mandatory constraints: must fail with RequiredValuesMissing
UserMod userMod = new UserMod();
userMod.setId(userTO.getId());
userMod.setPassword("newPassword");
userMod.addResourceToBeAdded("ws-target-resource-2");
SyncopeClientException sce = null;
try {
userTO = userService.update(userMod.getId(), userMod);
} catch (SyncopeClientCompositeErrorException scce) {
sce = scce.getException(SyncopeClientExceptionType.RequiredValuesMissing);
}
assertNotNull(sce);
// 3. update assigning a resource NOT forcing mandatory constraints
// AND primary: must fail with PropagationException
userMod = new UserMod();
userMod.setId(userTO.getId());
userMod.setPassword("newPassword");
userMod.addResourceToBeAdded("ws-target-resource-1");
sce = null;
try {
userTO = userService.update(userMod.getId(), userMod);
} catch (SyncopeClientCompositeErrorException scce) {
sce = scce.getException(SyncopeClientExceptionType.Propagation);
}
assertNotNull(sce);
// 4. update assigning a resource NOT forcing mandatory constraints
// BUT not primary: must succeed
userMod = new UserMod();
userMod.setId(userTO.getId());
userMod.setPassword("newPassword");
userMod.addResourceToBeAdded("resource-db");
sce = null;
try {