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());
}
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());
}
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));
}
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());
}
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();
}
Aggregations