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());
}
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());
}
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());
}
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;
}
Aggregations