use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.
the class ConfigurationControllerTest method testApplySetOptionInvalidInteger.
@Test
void testApplySetOptionInvalidInteger() {
Response r = setValue("hitsPerPage", "abcd");
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
}
use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.
the class ConfigurationControllerTest method testApplySetInvalidMethod.
@Test
void testApplySetInvalidMethod() {
Response r = setValue("noMethodExists", "1000");
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
}
use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.
the class HistoryControllerTest method testHistoryGet.
@Test
public void testHistoryGet() throws Exception {
final String path = "git";
int size = 5;
int start = 2;
Response response = target("history").queryParam("path", path).queryParam("max", size).queryParam("start", start).request().get();
HistoryDTO history = response.readEntity(new GenericType<>() {
});
assertEquals(size, history.getEntries().size());
assertEquals("Kryštof Tulinger <krystof.tulinger@oracle.com>", history.getEntries().get(0).getAuthor());
History repoHistory = HistoryGuru.getInstance().getHistory(new File(repository.getSourceRoot(), path));
assertEquals(history, getHistoryDTO(repoHistory.getHistoryEntries(size, start), repoHistory.getTags(), start, size, repoHistory.getHistoryEntries().size()));
}
use of jakarta.ws.rs.core.Response 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 jakarta.ws.rs.core.Response 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());
}
Aggregations