Search in sources :

Example 1 with MultivaluedStringMap

use of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap in project dropwizard by dropwizard.

the class OptionalFormParamResourceTest method shouldReturnDefaultMessageWhenMessageIsNotPresent.

@Test
public void shouldReturnDefaultMessageWhenMessageIsNotPresent() throws IOException {
    final String defaultMessage = "Default Message";
    final Response response = target("/optional/message").request().post(Entity.form(new MultivaluedStringMap()));
    assertThat(response.readEntity(String.class)).isEqualTo(defaultMessage);
}
Also used : Response(javax.ws.rs.core.Response) MultivaluedStringMap(org.glassfish.jersey.internal.util.collection.MultivaluedStringMap) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 2 with MultivaluedStringMap

use of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap in project dropwizard by dropwizard.

the class OptionalFormParamResourceTest method shouldReturnDefaultMessageWhenMyMessageIsNotPresent.

@Test
public void shouldReturnDefaultMessageWhenMyMessageIsNotPresent() throws IOException {
    final String defaultMessage = "My Default Message";
    final Response response = target("/optional/my-message").request().post(Entity.form(new MultivaluedStringMap()));
    assertThat(response.readEntity(String.class)).isEqualTo(defaultMessage);
}
Also used : Response(javax.ws.rs.core.Response) MultivaluedStringMap(org.glassfish.jersey.internal.util.collection.MultivaluedStringMap) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 3 with MultivaluedStringMap

use of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap in project dropwizard by dropwizard.

the class OptionalFormParamResourceTest method shouldReturnDefaultUUIDWhenUUIDIsNotPresent.

@Test
public void shouldReturnDefaultUUIDWhenUUIDIsNotPresent() throws IOException {
    final String defaultUUID = "d5672fa8-326b-40f6-bf71-d9dacf44bcdc";
    final Response response = target("/optional/uuid").request().post(Entity.form(new MultivaluedStringMap()));
    assertThat(response.readEntity(String.class)).isEqualTo(defaultUUID);
}
Also used : Response(javax.ws.rs.core.Response) MultivaluedStringMap(org.glassfish.jersey.internal.util.collection.MultivaluedStringMap) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 4 with MultivaluedStringMap

use of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap in project dropwizard by dropwizard.

the class OptionalFormParamResourceTest method shouldReturnDefaultMessageWhenMyMessageIsNotPresent.

@Test
public void shouldReturnDefaultMessageWhenMyMessageIsNotPresent() throws IOException {
    final String defaultMessage = "My Default Message";
    final Response response = target("/optional/my-message").request().post(Entity.form(new MultivaluedStringMap()));
    assertThat(response.readEntity(String.class)).isEqualTo(defaultMessage);
}
Also used : Response(javax.ws.rs.core.Response) MultivaluedStringMap(org.glassfish.jersey.internal.util.collection.MultivaluedStringMap) AbstractJerseyTest(io.dropwizard.jersey.AbstractJerseyTest) Test(org.junit.Test)

Example 5 with MultivaluedStringMap

use of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap in project jersey by jersey.

the class EntityTypesTest method testFormMultivaluedMapRepresentation.

@Test
public void testFormMultivaluedMapRepresentation() {
    final MultivaluedMap<String, String> fp = new MultivaluedStringMap();
    fp.add("Email", "johndoe@gmail.com");
    fp.add("Passwd", "north 23AZ");
    fp.add("service", "cl");
    fp.add("source", "Gulp-CalGul-1.05");
    fp.add("source", "foo.java");
    fp.add("source", "bar.java");
    final WebTarget target = target("FormMultivaluedMapResource");
    final MultivaluedMap _fp = target.request().post(Entity.entity(fp, "application/x-www-form-urlencoded"), MultivaluedMap.class);
    assertEquals(fp, _fp);
}
Also used : MultivaluedStringMap(org.glassfish.jersey.internal.util.collection.MultivaluedStringMap) WebTarget(javax.ws.rs.client.WebTarget) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Test(org.junit.Test)

Aggregations

MultivaluedStringMap (org.glassfish.jersey.internal.util.collection.MultivaluedStringMap)8 Test (org.junit.Test)8 Response (javax.ws.rs.core.Response)7 AbstractJerseyTest (io.dropwizard.jersey.AbstractJerseyTest)6 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 WebTarget (javax.ws.rs.client.WebTarget)1 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1