Search in sources :

Example 11 with Response

use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.

the class MessagesControllerTest method addMessageNegativeDurationTest.

@Test
public void addMessageNegativeDurationTest() throws Exception {
    Message m = new Message("text", Collections.singleton("test"), Message.MessageLevel.INFO, Duration.ofMinutes(1));
    setDuration(m, Duration.ofMinutes(-10));
    Response r = target("messages").request().post(Entity.json(m));
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
}
Also used : Response(jakarta.ws.rs.core.Response) AcceptedMessage(org.opengrok.indexer.web.messages.MessagesContainer.AcceptedMessage) Message(org.opengrok.indexer.web.messages.Message) Test(org.junit.jupiter.api.Test)

Example 12 with Response

use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.

the class MessagesControllerTest method addEmptyMessageTest.

@Test
public void addEmptyMessageTest() throws Exception {
    Message m = new Message("text", Collections.singleton("test"), Message.MessageLevel.INFO, Duration.ofMinutes(1));
    setText(m, "");
    Response r = target("messages").request().post(Entity.json(m));
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
}
Also used : Response(jakarta.ws.rs.core.Response) AcceptedMessage(org.opengrok.indexer.web.messages.MessagesContainer.AcceptedMessage) Message(org.opengrok.indexer.web.messages.Message) Test(org.junit.jupiter.api.Test)

Example 13 with Response

use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.

the class ApiTaskManagerTest method taskSubmitCallableWithExceptionMapping.

@Test
void taskSubmitCallableWithExceptionMapping() {
    ApiTaskManager apiTaskManager = ApiTaskManager.getInstance();
    String name = "exceptionMap";
    apiTaskManager.addPool(name, 1);
    final String exceptionText = "exception text";
    ApiTask apiTask = new ApiTask("foo", () -> {
        throw new IllegalStateException(exceptionText);
    }, Response.Status.NO_CONTENT, Map.of(IllegalStateException.class, Response.Status.NOT_ACCEPTABLE));
    apiTaskManager.submitApiTask(name, apiTask);
    await().atMost(3, TimeUnit.SECONDS).until(apiTask::isDone);
    Response response = apiTask.getResponse();
    assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatus());
    assertTrue(response.getEntity().toString().contains(exceptionText));
}
Also used : Response(jakarta.ws.rs.core.Response) Test(org.junit.jupiter.api.Test)

Example 14 with Response

use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.

the class ConfigurationControllerTest method testApplySetOptionInvalidBoolean2.

@Test
void testApplySetOptionInvalidBoolean2() {
    Response r = setValue("chattyStatusPage", "anything");
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
}
Also used : Response(jakarta.ws.rs.core.Response) Test(org.junit.jupiter.api.Test)

Example 15 with Response

use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.

the class ConfigurationControllerTest method testSuggesterServiceNotifiedOnConfigurationChange.

@Test
void testSuggesterServiceNotifiedOnConfigurationChange() throws InterruptedException {
    reset(suggesterService);
    Response response = target("configuration").request().put(Entity.xml(new Configuration().getXMLRepresentationAsString()));
    waitForTask(response);
    verify(suggesterService).refresh();
}
Also used : Response(jakarta.ws.rs.core.Response) Configuration(org.opengrok.indexer.configuration.Configuration) 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