Search in sources :

Example 16 with TaskExec

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

the class TaskTest method addPushTaskExecution.

@Test
public void addPushTaskExecution() {
    PushTask task = taskDAO.find("af558be4-9d2f-4359-bf85-a554e6e90be1");
    assertNotNull(task);
    int executionNumber = task.getExecs().size();
    TaskExec execution = entityFactory.newEntity(TaskExec.class);
    execution.setStatus("Text-free status");
    execution.setTask(task);
    execution.setStart(new Date());
    execution.setMessage("A message");
    task.add(execution);
    taskDAO.save(task);
    taskDAO.flush();
    task = taskDAO.find("af558be4-9d2f-4359-bf85-a554e6e90be1");
    assertNotNull(task);
    assertEquals(executionNumber + 1, task.getExecs().size());
}
Also used : TaskExec(org.apache.syncope.core.persistence.api.entity.task.TaskExec) PushTask(org.apache.syncope.core.persistence.api.entity.task.PushTask) Date(java.util.Date) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 17 with TaskExec

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

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

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

the class PropagationTaskValidator method isValid.

@Override
public boolean isValid(final PropagationTask task, final ConstraintValidatorContext context) {
    boolean isValid;
    if (task == null) {
        isValid = true;
    } else {
        isValid = task.getOperation() != null && !task.getAttributes().isEmpty() && task.getResource() != null;
        if (isValid) {
            List<? extends TaskExec> executions = task.getExecs();
            for (TaskExec execution : executions) {
                try {
                    PropagationTaskExecStatus.valueOf(execution.getStatus());
                } catch (IllegalArgumentException e) {
                    LOG.error("Invalid execution status '" + execution.getStatus() + "'", e);
                    isValid = false;
                }
            }
        }
        if (!isValid) {
            context.disableDefaultConstraintViolation();
            context.buildConstraintViolationWithTemplate(getTemplate(EntityViolationType.InvalidPropagationTask, "Invalid task")).addPropertyNode(task.getClass().getSimpleName()).addConstraintViolation();
        }
    }
    return isValid;
}
Also used : TaskExec(org.apache.syncope.core.persistence.api.entity.task.TaskExec)

Aggregations

TaskExec (org.apache.syncope.core.persistence.api.entity.task.TaskExec)19 Date (java.util.Date)9 PropagationTask (org.apache.syncope.core.persistence.api.entity.task.PropagationTask)7 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)7 ExecTO (org.apache.syncope.common.lib.to.ExecTO)5 Test (org.junit.jupiter.api.Test)5 Collectors (java.util.stream.Collectors)4 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)4 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)4 NotificationTask (org.apache.syncope.core.persistence.api.entity.task.NotificationTask)4 Transactional (org.springframework.transaction.annotation.Transactional)4 List (java.util.List)3 Map (java.util.Map)3 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 ExternalResourceDAO (org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO)3 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)3 SchedTask (org.apache.syncope.core.persistence.api.entity.task.SchedTask)3 Task (org.apache.syncope.core.persistence.api.entity.task.Task)3 TaskUtils (org.apache.syncope.core.persistence.api.entity.task.TaskUtils)3 TaskUtilsFactory (org.apache.syncope.core.persistence.api.entity.task.TaskUtilsFactory)3