use of javax.ws.rs.core.Response in project druid by druid-io.
the class AbstractListenerHandlerTest method testExceptionalHandleAll.
@Test
public void testExceptionalHandleAll() throws Exception {
shouldFail.set(true);
final Response response = abstractListenerHandler.handleGETAll();
Assert.assertEquals(500, response.getStatus());
Assert.assertEquals(ImmutableMap.of("error", error_message), response.getEntity());
}
use of javax.ws.rs.core.Response in project druid by druid-io.
the class AbstractListenerHandlerTest method testMissingDELETE.
@Test
public void testMissingDELETE() throws Exception {
final Response response = abstractListenerHandler.handleDELETE("not going to find it");
Assert.assertEquals(404, response.getStatus());
}
use of javax.ws.rs.core.Response in project druid by druid-io.
the class AbstractListenerHandlerTest method testHandleAll.
@Test
public void testHandleAll() throws Exception {
final Response response = abstractListenerHandler.handleGETAll();
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(all, response.getEntity());
}
use of javax.ws.rs.core.Response in project druid by druid-io.
the class AbstractListenerHandlerTest method testHandle.
@Test
public void testHandle() throws Exception {
final Response response = abstractListenerHandler.handleGET(good_id);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(good_object, response.getEntity());
}
use of javax.ws.rs.core.Response in project druid by druid-io.
the class ExceptionalAbstractListenerHandler method testAbstractPostHandler.
@Test
public // Take a list of strings wrap them in a JSON POJO and get them back as an array string in the POST function
void testAbstractPostHandler() throws Exception {
final AbstractListenerHandler handler = new ExceptionalAbstractListenerHandler() {
@Nullable
@Override
public String post(@NotNull Map<String, SomeBeanClass> inputObject) throws Exception {
return mapper.writeValueAsString(inputObject);
}
};
final ListenerResource resource = new ListenerResource(mapper, mapper, handler) {
};
final List<String> strings = ImmutableList.of("test1", "test2");
final Map<String, SomeBeanClass> expectedMap = new HashMap<>();
for (final String str : strings) {
expectedMap.put(str, new SomeBeanClass(str));
}
final String expectedString = mapper.writeValueAsString(expectedMap);
final Response response = resource.serviceAnnouncementPOSTAll(new ByteArrayInputStream(StringUtils.toUtf8(expectedString)), req);
Assert.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus());
Assert.assertEquals(expectedString, response.getEntity());
}
Aggregations