Search in sources :

Example 76 with Response

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

the class ConstraintViolationExceptionMapperTest method testInvalidFieldQueryParam.

@Test
public void testInvalidFieldQueryParam() {
    final Response response = target("/valid/bar").queryParam("sort", "foo").request().get();
    assertThat(response.getStatus()).isEqualTo(422);
    assertThat(response.readEntity(String.class)).containsOnlyOnce("sortParam must match \\\"^(asc|desc)$\\\"");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 77 with Response

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

the class ConstraintViolationExceptionMapperTest method getInvalidNested2ReturnIs500.

@Test
public void getInvalidNested2ReturnIs500() throws Exception {
    final Response response = target("/valid/nested2").request().get();
    assertThat(response.getStatus()).isEqualTo(500);
    String ret = "{\"errors\":[\"server response example must have a false thing\"]}";
    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 78 with Response

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

the class ConstraintViolationExceptionMapperTest method throwsAConstraintViolationExceptionForEmptyRequestEntities.

@Test
public void throwsAConstraintViolationExceptionForEmptyRequestEntities() {
    final Response response = target("/valid/validExample").request().post(Entity.json(null));
    assertThat(response.getStatus()).isEqualTo(422);
    assertThat(response.readEntity(String.class)).isEqualTo("{\"errors\":[\"The request body may not be null\"]}");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 79 with Response

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

the class ConstraintViolationExceptionMapperTest method notPresentEnumParameter.

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

Example 80 with Response

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

the class ConstraintViolationExceptionMapperTest method getInvalidSubBeanParamsIs400.

@Test
public void getInvalidSubBeanParamsIs400() throws Exception {
    final Response response = target("/valid/sub-zoo").queryParam("address", "42 Wallaby Way").request().get();
    assertThat(response.getStatus()).isEqualTo(400);
    assertThat(response.readEntity(String.class)).containsOnlyOnce("query param name may not be empty").containsOnlyOnce("name must be Coda");
}
Also used : Response(javax.ws.rs.core.Response) 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