Search in sources :

Example 6 with TaskResultJson

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

the class SystemResourceTest method vacuum.

@Test
public void vacuum() throws Exception {
    Mockito.when(taskService.submitTask(isA(SubmitTaskParams.class))).thenReturn(TaskId.from("task-id"));
    final TaskResultJson result = resource.vacuum(null);
    assertEquals("task-id", result.getTaskId());
}
Also used : SubmitTaskParams(com.enonic.xp.task.SubmitTaskParams) TaskResultJson(com.enonic.xp.task.TaskResultJson) Test(org.junit.jupiter.api.Test)

Example 7 with TaskResultJson

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

the class SystemResourceTest method upgrade.

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

Example 8 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)

Example 9 with TaskResultJson

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

the class RepositoryResourceTest method importNodes.

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

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