use of org.opengrok.web.api.ApiTaskManager in project OpenGrok by OpenGrok.
the class StatusControllerTest method testGet.
@Test
void testGet() throws InterruptedException {
int sleepTime = 3000;
ApiTask apiTask = new ApiTask("foo", () -> {
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}, Response.Status.CREATED);
String uuidString = apiTask.getUuid().toString();
ApiTaskManager apiTaskManager = ApiTaskManager.getInstance();
String poolName = "foo";
apiTaskManager.addPool(poolName, 1);
apiTaskManager.submitApiTask(poolName, apiTask);
Response response = target(StatusController.PATH).path(uuidString).request().get();
assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus());
Thread.sleep(sleepTime);
response = target(StatusController.PATH).path(uuidString).request().get();
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
}
use of org.opengrok.web.api.ApiTaskManager in project OpenGrok by OpenGrok.
the class StatusControllerTest method testDelete.
@Test
void testDelete() throws InterruptedException {
ApiTask apiTask = new ApiTask("foo", this::doNothing);
String uuidString = apiTask.getUuid().toString();
ApiTaskManager apiTaskManager = ApiTaskManager.getInstance();
String poolName = "deleteCompleted";
apiTaskManager.addPool(poolName, 1);
apiTaskManager.submitApiTask(poolName, apiTask);
Thread.sleep(1000);
Response response = target(StatusController.PATH).path(uuidString).request().delete();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.opengrok.web.api.ApiTaskManager in project OpenGrok by OpenGrok.
the class StatusControllerTest method testDeleteNotCompleted.
@Test
void testDeleteNotCompleted() {
int sleepTime = 3000;
ApiTask apiTask = new ApiTask("foo", () -> {
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
});
String uuidString = apiTask.getUuid().toString();
ApiTaskManager apiTaskManager = ApiTaskManager.getInstance();
String poolName = "deleteNotCompleted";
apiTaskManager.addPool(poolName, 1);
apiTaskManager.submitApiTask(poolName, apiTask);
Response response = target(StatusController.PATH).path(uuidString).request().delete();
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
}
Aggregations