Search in sources :

Example 56 with ExternalResource

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);
}
Also used : ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 57 with ExternalResource

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);
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) PullTask(org.apache.syncope.core.persistence.api.entity.task.PullTask) AnyTemplatePullTask(org.apache.syncope.core.persistence.api.entity.task.AnyTemplatePullTask) AnyTemplatePullTask(org.apache.syncope.core.persistence.api.entity.task.AnyTemplatePullTask) PullActions(org.apache.syncope.core.provisioning.api.pushpull.PullActions) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) InvalidEntityException(org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 58 with ExternalResource

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));
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) Attribute(org.identityconnectors.framework.common.objects.Attribute) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 59 with ExternalResource

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);
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) Attribute(org.identityconnectors.framework.common.objects.Attribute) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)59 Test (org.junit.jupiter.api.Test)30 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)28 Provision (org.apache.syncope.core.persistence.api.entity.resource.Provision)23 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)21 ConnInstance (org.apache.syncope.core.persistence.api.entity.ConnInstance)15 List (java.util.List)14 Collectors (java.util.stream.Collectors)14 HashSet (java.util.HashSet)13 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)13 Autowired (org.springframework.beans.factory.annotation.Autowired)13 Set (java.util.Set)12 Transactional (org.springframework.transaction.annotation.Transactional)12 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)10 ExternalResourceDAO (org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO)10 Collections (java.util.Collections)9 AnyTypeDAO (org.apache.syncope.core.persistence.api.dao.AnyTypeDAO)9 Realm (org.apache.syncope.core.persistence.api.entity.Realm)9 PasswordPolicy (org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy)9 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)8