Search in sources :

Example 1 with TaskResultJson

use of com.enonic.xp.task.TaskResultJson 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);
}
Also used : TaskId(com.enonic.xp.task.TaskId) PropertyTree(com.enonic.xp.data.PropertyTree) TaskResultJson(com.enonic.xp.task.TaskResultJson)

Example 2 with TaskResultJson

use of com.enonic.xp.task.TaskResultJson in project xp by enonic.

the class RepositoryResourceTest method exportNodes.

@Test
public void exportNodes() throws Exception {
    Mockito.when(taskService.submitTask(Mockito.isA(ExportRunnableTask.class), eq("export"))).thenReturn(TaskId.from("task-id"));
    final ExportNodesRequestJson json = Mockito.mock(ExportNodesRequestJson.class);
    final TaskResultJson result = resource.exportNodes(json);
    assertEquals("task-id", result.getTaskId());
}
Also used : ExportRunnableTask(com.enonic.xp.impl.server.rest.task.ExportRunnableTask) TaskResultJson(com.enonic.xp.task.TaskResultJson) ExportNodesRequestJson(com.enonic.xp.impl.server.rest.model.ExportNodesRequestJson) Test(org.junit.jupiter.api.Test)

Example 3 with TaskResultJson

use of com.enonic.xp.task.TaskResultJson in project xp by enonic.

the class AuditLogResourceTest method cleanUpAuditLog.

@Test
public void cleanUpAuditLog() throws Exception {
    Mockito.when(taskService.submitTask(isA(SubmitTaskParams.class))).thenReturn(TaskId.from("task-id"));
    final CleanUpAuditLogRequestJson requestJson = new CleanUpAuditLogRequestJson("PT1s");
    final TaskResultJson result = resource.cleanup(requestJson);
    final ArgumentCaptor<SubmitTaskParams> captor = ArgumentCaptor.forClass(SubmitTaskParams.class);
    Mockito.verify(taskService, Mockito.times(1)).submitTask(captor.capture());
    assertEquals("task-id", result.getTaskId());
    assertEquals(1, captor.getValue().getData().getTotalSize());
    assertEquals("PT1s", captor.getValue().getData().getString("ageThreshold"));
}
Also used : SubmitTaskParams(com.enonic.xp.task.SubmitTaskParams) TaskResultJson(com.enonic.xp.task.TaskResultJson) CleanUpAuditLogRequestJson(com.enonic.xp.impl.server.rest.model.CleanUpAuditLogRequestJson) Test(org.junit.jupiter.api.Test)

Example 4 with TaskResultJson

use of com.enonic.xp.task.TaskResultJson in project xp by enonic.

the class SystemResourceTest method load.

@Test
public void load() throws Exception {
    Mockito.when(taskService.submitTask(Mockito.isA(LoadRunnableTask.class), eq("load"))).thenReturn(TaskId.from("task-id"));
    final SystemLoadRequestJson json = Mockito.mock(SystemLoadRequestJson.class);
    final TaskResultJson result = resource.load(json);
    assertEquals("task-id", result.getTaskId());
}
Also used : SystemLoadRequestJson(com.enonic.xp.impl.server.rest.model.SystemLoadRequestJson) LoadRunnableTask(com.enonic.xp.impl.server.rest.task.LoadRunnableTask) TaskResultJson(com.enonic.xp.task.TaskResultJson) Test(org.junit.jupiter.api.Test)

Example 5 with TaskResultJson

use of com.enonic.xp.task.TaskResultJson in project xp by enonic.

the class VacuumCommand method execute.

public TaskResultJson execute() {
    PropertyTree config = new PropertyTree();
    if (params.getAgeThreshold() != null) {
        config.addString("ageThreshold", params.getAgeThreshold());
    }
    if (params.getTasks() != null) {
        config.addStrings("tasks", params.getTasks());
    }
    final TaskId taskId = taskService.submitTask(SubmitTaskParams.create().descriptorKey(DescriptorKey.from("com.enonic.xp.app.system:vacuum")).data(config).build());
    return new TaskResultJson(taskId);
}
Also used : TaskId(com.enonic.xp.task.TaskId) PropertyTree(com.enonic.xp.data.PropertyTree) TaskResultJson(com.enonic.xp.task.TaskResultJson)

Aggregations

TaskResultJson (com.enonic.xp.task.TaskResultJson)9 Test (org.junit.jupiter.api.Test)7 PropertyTree (com.enonic.xp.data.PropertyTree)2 SubmitTaskParams (com.enonic.xp.task.SubmitTaskParams)2 TaskId (com.enonic.xp.task.TaskId)2 CleanUpAuditLogRequestJson (com.enonic.xp.impl.server.rest.model.CleanUpAuditLogRequestJson)1 ExportNodesRequestJson (com.enonic.xp.impl.server.rest.model.ExportNodesRequestJson)1 ImportNodesRequestJson (com.enonic.xp.impl.server.rest.model.ImportNodesRequestJson)1 SystemDumpRequestJson (com.enonic.xp.impl.server.rest.model.SystemDumpRequestJson)1 SystemDumpUpgradeRequestJson (com.enonic.xp.impl.server.rest.model.SystemDumpUpgradeRequestJson)1 SystemLoadRequestJson (com.enonic.xp.impl.server.rest.model.SystemLoadRequestJson)1 DumpRunnableTask (com.enonic.xp.impl.server.rest.task.DumpRunnableTask)1 ExportRunnableTask (com.enonic.xp.impl.server.rest.task.ExportRunnableTask)1 ImportRunnableTask (com.enonic.xp.impl.server.rest.task.ImportRunnableTask)1 LoadRunnableTask (com.enonic.xp.impl.server.rest.task.LoadRunnableTask)1 UpgradeRunnableTask (com.enonic.xp.impl.server.rest.task.UpgradeRunnableTask)1