Search in sources :

Example 66 with Response

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

the class OptionalFormParamResourceTest method shouldReturnUUIDWhenValidUUIDIsPresent.

@Test
public void shouldReturnUUIDWhenValidUUIDIsPresent() throws IOException {
    final String uuid = "fd94b00d-bd50-46b3-b42f-905a9c9e7d78";
    final Form form = new Form("uuid", uuid);
    final Response response = target("/optional/uuid").request().post(Entity.form(form));
    assertThat(response.readEntity(String.class)).isEqualTo(uuid);
}
Also used : Response(javax.ws.rs.core.Response) Form(javax.ws.rs.core.Form) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 67 with Response

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

the class OptionalFormParamResourceTest method shouldReturnMyMessageWhenMyMessageIsPresent.

@Test
public void shouldReturnMyMessageWhenMyMessageIsPresent() throws IOException {
    final String myMessage = "My Message";
    final Form form = new Form("mymessage", myMessage);
    final Response response = target("/optional/my-message").request().post(Entity.form(form));
    assertThat(response.readEntity(String.class)).isEqualTo(myMessage);
}
Also used : Response(javax.ws.rs.core.Response) Form(javax.ws.rs.core.Form) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 68 with Response

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

the class ConstraintViolationExceptionMapperTest method maxMessageContainsParameterName.

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

Example 69 with Response

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

the class ConstraintViolationExceptionMapperTest method getInvalidCookieParamsIs400.

@Test
public void getInvalidCookieParamsIs400() throws Exception {
    final Response response = target("/valid/cooks").request().get();
    assertThat(response.getStatus()).isEqualTo(400);
    String ret = "{\"errors\":[\"cookie user_id 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 70 with Response

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

the class ConstraintViolationExceptionMapperTest method getInvalidNestedReturnIs500.

@Test
public void getInvalidNestedReturnIs500() throws Exception {
    final Response response = target("/valid/nested").request().get();
    assertThat(response.getStatus()).isEqualTo(500);
    String ret = "{\"errors\":[\"server response representation.name 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)

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