use of org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException in project syncope by apache.
the class PlainAttrTest method saveWithEnum.
@Test
public void saveWithEnum() throws ClassNotFoundException {
User user = userDAO.find("1417acbe-cbf6-4277-9372-e75e04f97000");
assertNotNull(user);
PlainSchema gender = plainSchemaDAO.find("gender");
assertNotNull(gender);
assertNotNull(gender.getType());
assertNotNull(gender.getEnumerationValues());
UPlainAttr attribute = entityFactory.newEntity(UPlainAttr.class);
attribute.setOwner(user);
attribute.setSchema(gender);
user.add(attribute);
Exception thrown = null;
try {
attribute.add("A", anyUtilsFactory.getInstance(AnyTypeKind.USER));
} catch (ValidationException e) {
thrown = e;
}
assertNotNull(thrown);
attribute.add("M", anyUtilsFactory.getInstance(AnyTypeKind.USER));
InvalidEntityException iee = null;
try {
userDAO.save(user);
} catch (InvalidEntityException e) {
iee = e;
}
assertNull(iee);
}
use of org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException in project syncope by apache.
the class ResourceTest method issueSYNCOPE418.
@Test
public void issueSYNCOPE418() {
ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
resource.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
try {
resourceDAO.save(resource);
fail("This should not happen");
} catch (InvalidEntityException e) {
assertTrue(e.hasViolation(EntityViolationType.InvalidKey));
}
}
use of org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException in project syncope by apache.
the class TaskTest method savePullTask.
@Test
public void savePullTask() {
ExternalResource resource = resourceDAO.find("ws-target-resource-1");
assertNotNull(resource);
AnyTemplatePullTask template = entityFactory.newEntity(AnyTemplatePullTask.class);
template.set(new UserTO());
PullTask task = entityFactory.newEntity(PullTask.class);
task.setName("savePullTask");
task.setDescription("PullTask description");
task.setActive(true);
task.setPullMode(PullMode.FULL_RECONCILIATION);
task.add(template);
task.setCronExpression("BLA BLA");
task.setMatchingRule(MatchingRule.UPDATE);
task.setUnmatchingRule(UnmatchingRule.PROVISION);
// this save() fails because of an invalid Cron Expression
InvalidEntityException exception = null;
try {
taskDAO.save(task);
} catch (InvalidEntityException e) {
exception = e;
}
assertNotNull(exception);
task.setCronExpression(null);
// this save() fails because a PullTask requires a target resource
exception = null;
try {
taskDAO.save(task);
} catch (InvalidEntityException e) {
exception = e;
}
assertNotNull(exception);
task.setResource(resource);
Implementation pullActions = entityFactory.newEntity(Implementation.class);
pullActions.setKey("PullActions" + UUID.randomUUID().toString());
pullActions.setEngine(ImplementationEngine.JAVA);
pullActions.setType(ImplementationType.PULL_ACTIONS);
pullActions.setBody(PullActions.class.getName());
pullActions = implementationDAO.save(pullActions);
task.add(pullActions);
// this save() finally works
task = taskDAO.save(task);
assertNotNull(task);
PullTask actual = taskDAO.find(task.getKey());
assertEquals(task, actual);
}
Aggregations