use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class ResourceTest method delete.
@Test
public void delete() {
ExternalResource resource = resourceDAO.find("ws-target-resource-2");
assertNotNull(resource);
resourceDAO.delete(resource.getKey());
ExternalResource actual = resourceDAO.find("ws-target-resource-2");
assertNull(actual);
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource 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);
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class TaskTest method save.
@Test
public void save() {
ExternalResource resource = resourceDAO.find("ws-target-resource-1");
assertNotNull(resource);
User user = userDAO.findByUsername("verdi");
assertNotNull(user);
PropagationTask task = entityFactory.newEntity(PropagationTask.class);
task.setResource(resource);
task.setAnyTypeKind(AnyTypeKind.USER);
task.setAnyType(AnyTypeKind.USER.name());
task.setOperation(ResourceOperation.CREATE);
task.setConnObjectKey("one@two.com");
Set<Attribute> attributes = new HashSet<>();
attributes.add(AttributeBuilder.build("testAttribute", "testValue1", "testValue2"));
attributes.add(AttributeBuilder.buildPassword("password".toCharArray()));
task.setAttributes(attributes);
task = taskDAO.save(task);
assertNotNull(task);
PropagationTask actual = taskDAO.find(task.getKey());
assertEquals(task, actual);
taskDAO.flush();
resource = resourceDAO.find("ws-target-resource-1");
assertTrue(taskDAO.findAll(TaskType.PROPAGATION, resource, null, null, null, -1, -1, Collections.<OrderByClause>emptyList()).contains(task));
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class TaskTest method savePropagationTask.
@Test
public void savePropagationTask() {
ExternalResource resource = resourceDAO.find("ws-target-resource-1");
assertNotNull(resource);
User user = userDAO.find("74cd8ece-715a-44a4-a736-e17b46c4e7e6");
assertNotNull(user);
PropagationTask task = entityFactory.newEntity(PropagationTask.class);
task.setResource(resource);
task.setAnyTypeKind(AnyTypeKind.USER);
task.setAnyType(AnyTypeKind.USER.name());
task.setOperation(ResourceOperation.CREATE);
task.setConnObjectKey("one@two.com");
Set<Attribute> attributes = new HashSet<>();
attributes.add(AttributeBuilder.build("testAttribute", "testValue1", "testValue2"));
attributes.add(AttributeBuilder.buildPassword("password".toCharArray()));
task.setAttributes(attributes);
task = taskDAO.save(task);
assertNotNull(task);
PropagationTask actual = taskDAO.find(task.getKey());
assertEquals(task, actual);
}
Aggregations