Search in sources :

Example 91 with Response

use of javax.ws.rs.core.Response in project dropwizard by dropwizard.

the class ConstraintViolationExceptionMapperTest method emptyParameterMessageContainsParameterName.

@Test
public void emptyParameterMessageContainsParameterName() {
    final Response response = target("/valid/paramValidation").queryParam("length", "").request().get();
    assertThat(response.getStatus()).isEqualTo(400);
    assertThat(response.readEntity(String.class)).containsOnlyOnce("query param length may not be null");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 92 with Response

use of javax.ws.rs.core.Response in project dropwizard by dropwizard.

the class ConstraintViolationExceptionMapperTest method returnInvalidEntityIs500.

@Test
public void returnInvalidEntityIs500() throws Exception {
    assumeThat(Locale.getDefault().getLanguage(), is("en"));
    final Response response = target("/valid/foo").request(MediaType.APPLICATION_JSON).post(Entity.entity("{ \"name\": \"Coda\" }", MediaType.APPLICATION_JSON));
    assertThat(response.getStatus()).isEqualTo(500);
    assertThat(response.readEntity(String.class)).isEqualTo("{\"errors\":[\"server response name may not be empty\"]}");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 93 with Response

use of javax.ws.rs.core.Response in project dropwizard by dropwizard.

the class ConstraintViolationExceptionMapperTest method invalidRequestListEntities.

@Test
public void invalidRequestListEntities() {
    final Response response = target("/valid/validExampleList").request().post(Entity.json("[{\"id\":-1}, {\"id\":-2}]"));
    assertThat(response.getStatus()).isEqualTo(422);
    assertThat(response.readEntity(String.class)).isEqualTo("{\"errors\":[\"id must be greater than or equal to 0\"," + "\"id must be greater than or equal to 0\"]}");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 94 with Response

use of javax.ws.rs.core.Response in project dropwizard by dropwizard.

the class ConstraintViolationExceptionMapperTest method minMessageContainsParameterName.

@Test
public void minMessageContainsParameterName() {
    final Response response = target("/valid/paramValidation").queryParam("length", 1).request().get();
    assertThat(response.getStatus()).isEqualTo(400);
    assertThat(response.readEntity(String.class)).containsOnlyOnce("query param length must be greater than or equal to 2");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 95 with Response

use of javax.ws.rs.core.Response in project dropwizard by dropwizard.

the class ConstraintViolationExceptionMapperTest method returnPartialBothValidatedRequestEntities.

@Test
public void returnPartialBothValidatedRequestEntities() {
    final Response response = target("/valid/validatedPartialExampleBoth").request().post(Entity.json("{\"id\":1,\"text\":\"hello Cemo\"}"));
    assertThat(response.getStatus()).isEqualTo(200);
    PartialExample ex = response.readEntity(PartialExample.class);
    assertThat(ex.id).isEqualTo(1);
    assertThat(ex.text).isEqualTo("hello Cemo");
}
Also used : Response(javax.ws.rs.core.Response) PartialExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.PartialExample) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Aggregations

Response (javax.ws.rs.core.Response)3808 Test (org.junit.Test)2883 JerseyTest (org.glassfish.jersey.test.JerseyTest)849 Test (org.testng.annotations.Test)342 Builder (javax.ws.rs.client.Invocation.Builder)298 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)287 WebTarget (javax.ws.rs.client.WebTarget)278 BaseTest (org.xdi.oxauth.BaseTest)274 Parameters (org.testng.annotations.Parameters)271 DBUnitTest (org.orcid.test.DBUnitTest)270 JSONException (org.codehaus.jettison.json.JSONException)253 URI (java.net.URI)230 JSONObject (org.codehaus.jettison.json.JSONObject)181 Path (javax.ws.rs.Path)153 Matchers.containsString (org.hamcrest.Matchers.containsString)142 URISyntaxException (java.net.URISyntaxException)124 ResponseType (org.xdi.oxauth.model.common.ResponseType)120 Produces (javax.ws.rs.Produces)113 RelationshipRepresentationTest (org.neo4j.server.rest.repr.RelationshipRepresentationTest)105 GET (javax.ws.rs.GET)104