Search in sources :

Example 1 with Form

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

the class OptionalFormParamResourceTest method shouldReturnMessageWhenMessageIsPresent.

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

Example 2 with Form

use of javax.ws.rs.core.Form 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 3 with Form

use of javax.ws.rs.core.Form 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 4 with Form

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

the class OptionalFormParamResourceTest method shouldReturnMessageWhenMessageBlank.

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

Example 5 with Form

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

the class OptionalFormParamResourceTest method shouldThrowBadRequestExceptionWhenInvalidUUIDIsPresent.

@Test
public void shouldThrowBadRequestExceptionWhenInvalidUUIDIsPresent() throws IOException {
    final String invalidUUID = "invalid-uuid";
    final Form form = new Form("uuid", invalidUUID);
    final Response response = target("/optional/uuid").request().post(Entity.form(form));
    assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
}
Also used : Response(javax.ws.rs.core.Response) Form(javax.ws.rs.core.Form) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Aggregations

Form (javax.ws.rs.core.Form)83 Test (org.junit.Test)60 Response (javax.ws.rs.core.Response)48 JerseyTest (org.glassfish.jersey.test.JerseyTest)26 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)14 AbstractJerseyTest (io.dropwizard.jersey.AbstractJerseyTest)11 Map (java.util.Map)6 List (java.util.List)5 WebTarget (javax.ws.rs.client.WebTarget)4 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)4 HashMap (java.util.HashMap)3 Consumes (javax.ws.rs.Consumes)3 Produces (javax.ws.rs.Produces)3 Builder (javax.ws.rs.client.Invocation.Builder)3 Cookie (javax.ws.rs.core.Cookie)3 Aircraft (org.glassfish.jersey.examples.flight.model.Aircraft)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 IOException (java.io.IOException)2