Search in sources :

Example 81 with Response

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

the class ConstraintViolationExceptionMapperTest method returnPartialValidatedRequestEntities.

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

Example 82 with Response

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

the class ConstraintViolationExceptionMapperTest method invalidRequestSingleCollectionEntities.

@Test
public void invalidRequestSingleCollectionEntities() {
    final Response response = target("/valid/validExampleCollection").request().post(Entity.json("[{\"id\":1}, {\"id\":-2}]"));
    assertThat(response.getStatus()).isEqualTo(422);
    assertThat(response.readEntity(String.class)).containsOnlyOnce("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 83 with Response

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

the class ConstraintViolationExceptionMapperTest method getInvalidatedBeanParamsIs400.

@Test
public void getInvalidatedBeanParamsIs400() throws Exception {
    // bean parameter is too short and so will fail validation
    final Response response = target("/valid/zoo2").request().get();
    assertThat(response.getStatus()).isEqualTo(400);
    assertThat(response.readEntity(String.class)).containsOnlyOnce("\"name must be Coda\"").containsOnlyOnce("\"query param name may not be empty\"");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 84 with Response

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

the class ConstraintViolationExceptionMapperTest method getInvalidMatrixParamIs400.

@Test
public void getInvalidMatrixParamIs400() throws Exception {
    final Response response = target("/valid/matrix").matrixParam("bob", "").request().get();
    assertThat(response.getStatus()).isEqualTo(400);
    String ret = "{\"errors\":[\"matrix param bob may not be empty\"]}";
    assertThat(response.readEntity(String.class)).isEqualTo(ret);
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 85 with Response

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

the class ConstraintViolationExceptionMapperTest method returnRequestArrayEntities.

@Test
public void returnRequestArrayEntities() {
    final Response response = target("/valid/validExampleArray").request().post(Entity.json("[{\"id\":1}, {\"id\":2}]"));
    final Example ex1 = new Example();
    final Example ex2 = new Example();
    ex1.id = 1;
    ex2.id = 2;
    assertThat(response.getStatus()).isEqualTo(200);
    assertThat(response.readEntity(Example[].class)).containsExactly(ex1, ex2);
}
Also used : Response(javax.ws.rs.core.Response) Example(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.Example) PartialExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.PartialExample) ListExample(io.dropwizard.jersey.jackson.JacksonMessageBodyProviderTest.ListExample) 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