use of com.enonic.xp.task.TaskId in project xp by enonic.
the class ContentResourceTest method reprocess_task_skip_children.
@Test
public void reprocess_task_skip_children() throws Exception {
Content content = createContent("content-id", ContentPath.from("/path/to/content"));
Content reprocessedContent = Content.create(content).displayName("new name").build();
TaskId taskId = TaskId.from("task-id");
Mockito.when(this.contentService.getByPath(content.getPath())).thenReturn(content);
Mockito.when(this.contentService.reprocess(content.getId())).thenReturn(reprocessedContent);
Mockito.when(this.taskService.submitTask(Mockito.any(RunnableTask.class), Mockito.anyString())).thenReturn(taskId);
final String result = request().path("content/reprocessTask").entity(readFromFile("reprocess_params_skip_children.json"), MediaType.APPLICATION_JSON_TYPE).post().getAsString();
assertEquals("{\"taskId\":\"task-id\"}", result);
}
use of com.enonic.xp.task.TaskId in project xp by enonic.
the class TaskResource method getTask.
@GET
@Path("/{taskId}")
public TaskInfoJson getTask(@PathParam("taskId") final String taskIdString) {
final TaskId taskId = TaskId.from(taskIdString);
final TaskInfo taskInfo = taskService.getTaskInfo(taskId);
if (taskInfo == null) {
throw new WebApplicationException(String.format("Task [%s] was not found", taskIdString), Response.Status.NOT_FOUND);
}
return new TaskInfoJson(taskInfo);
}
use of com.enonic.xp.task.TaskId in project xp by enonic.
the class CleanUpAuditLogCommand method execute.
public TaskResultJson execute() {
PropertyTree config = new PropertyTree();
if (params.getAgeThreshold() != null) {
config.addString("ageThreshold", params.getAgeThreshold());
}
final TaskId taskId = taskService.submitTask(SubmitTaskParams.create().descriptorKey(DescriptorKey.from("com.enonic.xp.app.system:audit-log-cleanup")).data(config).build());
return new TaskResultJson(taskId);
}
use of com.enonic.xp.task.TaskId in project xp by enonic.
the class TaskResourceTest method getTask.
@Test
public void getTask() throws Exception {
final TaskId taskId = TaskId.from("123");
final TaskInfo taskInfo = TaskInfo.create().id(taskId).description("My task").state(TaskState.RUNNING).application(ApplicationKey.from("com.enonic.myapp")).user(PrincipalKey.from("user:store:me")).startTime(Instant.parse("2017-10-01T09:00:00Z")).progress(TaskProgress.create().current(2).total(10).info("Processing items").build()).build();
Mockito.when(this.taskService.getTaskInfo(taskId)).thenReturn(taskInfo);
String response = request().path("task/123").get().getAsString();
assertJson("get_task_result.json", response);
}
use of com.enonic.xp.task.TaskId in project xp by enonic.
the class VacuumTaskHandlerTest method vacuumDefaultParams.
@Test
public void vacuumDefaultParams() throws Exception {
final TaskId taskId = TaskId.from("task");
Mockito.when(vacuumService.vacuum(isA(VacuumParameters.class))).thenReturn(VacuumResult.create().build());
TaskProgressReporterContext.withContext((id, progressReporter) -> runFunction("/test/VacuumTaskHandlerTest.js", "vacuumDefault")).run(taskId, progressReporter);
Mockito.verify(vacuumService, Mockito.times(1)).vacuum(paramsCaptor.capture());
assertNull(paramsCaptor.getValue().getAgeThreshold());
assertEquals(2, paramsCaptor.getValue().getTaskNames().size());
assertTrue(paramsCaptor.getValue().getTaskNames().containsAll(Set.of("SegmentVacuumTask", "VersionTableVacuumTask")));
assertNotNull(paramsCaptor.getValue().getVacuumListener());
}
Aggregations