Search in sources :

Example 11 with PropagationTask

use of org.apache.syncope.core.persistence.api.entity.task.PropagationTask in project syncope by apache.

the class TaskTest method addPropagationTaskExecution.

@Test
public void addPropagationTaskExecution() {
    PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
    assertNotNull(task);
    int executionNumber = task.getExecs().size();
    TaskExec execution = entityFactory.newEntity(TaskExec.class);
    execution.setTask(task);
    execution.setStatus(PropagationTaskExecStatus.CREATED.name());
    execution.setStart(new Date());
    task.add(execution);
    taskDAO.save(task);
    taskDAO.flush();
    task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
    assertNotNull(task);
    assertEquals(executionNumber + 1, task.getExecs().size());
}
Also used : PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) TaskExec(org.apache.syncope.core.persistence.api.entity.task.TaskExec) Date(java.util.Date) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 12 with PropagationTask

use of org.apache.syncope.core.persistence.api.entity.task.PropagationTask in project syncope by apache.

the class TaskTest method read.

@Test
public void read() {
    PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
    assertNotNull(task);
    assertNotNull(task.getExecs());
    assertFalse(task.getExecs().isEmpty());
    assertEquals(1, task.getExecs().size());
}
Also used : PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 13 with PropagationTask

use of org.apache.syncope.core.persistence.api.entity.task.PropagationTask in project syncope by apache.

the class TaskExecTest method findAll.

@Test
public void findAll() {
    PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
    assertNotNull(task);
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.set(2015, 11, 18, 0, 0, 0);
    List<TaskExec> execs = taskExecDAO.findAll(task, calendar.getTime(), null, null, null);
    assertNotNull(execs);
    assertEquals(1, execs.size());
}
Also used : PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) Calendar(java.util.Calendar) TaskExec(org.apache.syncope.core.persistence.api.entity.task.TaskExec) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 14 with PropagationTask

use of org.apache.syncope.core.persistence.api.entity.task.PropagationTask in project syncope by apache.

the class TaskExecTest method issueSYNCOPE214.

@Test
public void issueSYNCOPE214() {
    PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
    assertNotNull(task);
    String faultyMessage = "A faulty message";
    faultyMessage = faultyMessage.replace('a', '\0');
    TaskExec exec = entityFactory.newEntity(TaskExec.class);
    exec.setStart(new Date());
    exec.setEnd(new Date());
    exec.setStatus(PropagationTaskExecStatus.SUCCESS.name());
    exec.setMessage(faultyMessage);
    task.add(exec);
    exec.setTask(task);
    exec = taskExecDAO.save(exec);
    assertNotNull(exec);
    assertEquals(faultyMessage.replace('\0', '\n'), exec.getMessage());
}
Also used : PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) TaskExec(org.apache.syncope.core.persistence.api.entity.task.TaskExec) Date(java.util.Date) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 15 with PropagationTask

use of org.apache.syncope.core.persistence.api.entity.task.PropagationTask 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

PropagationTask (org.apache.syncope.core.persistence.api.entity.task.PropagationTask)15 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)10 Test (org.junit.jupiter.api.Test)10 TaskExec (org.apache.syncope.core.persistence.api.entity.task.TaskExec)9 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)8 Collections (java.util.Collections)5 Date (java.util.Date)5 HashSet (java.util.HashSet)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)5 ExternalResourceDAO (org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 Optional (java.util.Optional)4 Set (java.util.Set)4 StringUtils (org.apache.commons.lang3.StringUtils)4 ExecTO (org.apache.syncope.common.lib.to.ExecTO)4 PropagationTaskExecStatus (org.apache.syncope.common.lib.types.PropagationTaskExecStatus)4