Search in sources :

Example 71 with Response

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

the class ConstraintViolationExceptionMapperTest method returnInvalidatedEntityIs500.

@Test
public void returnInvalidatedEntityIs500() throws Exception {
    assumeThat(Locale.getDefault().getLanguage(), is("en"));
    final Response response = target("/valid/fooValidated").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 72 with Response

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

the class ConstraintViolationExceptionMapperTest method postValidGroupsIs400.

@Test
public void postValidGroupsIs400() throws Exception {
    final Response response = target("/valid/sub-valid-group-zoo").queryParam("address", "42 WALLABY WAY").queryParam("name", "Coda").request().post(Entity.json("{}"));
    assertThat(response.getStatus()).isEqualTo(400);
    assertThat(response.readEntity(String.class)).containsOnlyOnce("[\"address must not be uppercase\"]");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 73 with Response

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

the class ConstraintViolationExceptionMapperTest method invalidEmbeddedListEntities.

@Test
public void invalidEmbeddedListEntities() {
    final Response response = target("/valid/validExampleEmbeddedList").request().post(Entity.json("[ {\"examples\": [ {\"id\":1 } ] }, { } ]"));
    assertThat(response.getStatus()).isEqualTo(422);
    assertThat(response.readEntity(String.class)).containsOnlyOnce("examples may not be empty");
}
Also used : Response(javax.ws.rs.core.Response) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 74 with Response

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

the class ConstraintViolationExceptionMapperTest method postInvalidatedEntityIs422.

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

Example 75 with Response

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

the class ConstraintViolationExceptionMapperTest method getInvalidPathParamsIs400.

@Test
public void getInvalidPathParamsIs400() throws Exception {
    final Response response = target("/valid/goods/11").request().get();
    assertThat(response.getStatus()).isEqualTo(400);
    String ret = "{\"errors\":[\"path param id not a well-formed email address\"]}";
    assertThat(response.readEntity(String.class)).isEqualTo(ret);
}
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