Search in sources :

Example 16 with Response

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());
}
Also used : Response(jakarta.ws.rs.core.Response) Test(org.junit.jupiter.api.Test)

Example 17 with Response

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());
}
Also used : Response(jakarta.ws.rs.core.Response) Test(org.junit.jupiter.api.Test)

Example 18 with Response

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()));
}
Also used : Response(jakarta.ws.rs.core.Response) HistoryDTO(org.opengrok.web.api.v1.controller.HistoryController.HistoryDTO) HistoryController.getHistoryDTO(org.opengrok.web.api.v1.controller.HistoryController.getHistoryDTO) History(org.opengrok.indexer.history.History) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 19 with Response

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());
}
Also used : Response(jakarta.ws.rs.core.Response) ApiTaskManager(org.opengrok.web.api.ApiTaskManager) ApiTask(org.opengrok.web.api.ApiTask) Test(org.junit.jupiter.api.Test)

Example 20 with Response

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());
}
Also used : Response(jakarta.ws.rs.core.Response) ApiTaskManager(org.opengrok.web.api.ApiTaskManager) ApiTask(org.opengrok.web.api.ApiTask) Test(org.junit.jupiter.api.Test)

Aggregations

Response (jakarta.ws.rs.core.Response)665 Test (org.junit.jupiter.api.Test)551 AsyncInvoker (jakarta.ws.rs.client.AsyncInvoker)78 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)71 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)67 Invocation (jakarta.ws.rs.client.Invocation)65 CompletionStageRxInvoker (jakarta.ws.rs.client.CompletionStageRxInvoker)51 Path (jakarta.ws.rs.Path)44 IOException (java.io.IOException)43 SyncInvoker (jakarta.ws.rs.client.SyncInvoker)41 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)33 POST (jakarta.ws.rs.POST)27 Client (jakarta.ws.rs.client.Client)25 WebTarget (jakarta.ws.rs.client.WebTarget)24 Link (jakarta.ws.rs.core.Link)23 Status (jakarta.ws.rs.core.Response.Status)23 MediaType (jakarta.ws.rs.core.MediaType)22 Annotation (java.lang.annotation.Annotation)22 Date (java.util.Date)21 GET (jakarta.ws.rs.GET)18