Search in sources :

Example 6 with Greeting

use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.

the class MultiPartUploadITest method multiPartUploadingUsesEncoderConfigToKnowHowToSerializeCustomMimeTypesToXml.

@Test
public void multiPartUploadingUsesEncoderConfigToKnowHowToSerializeCustomMimeTypesToXml() throws Exception {
    // Given
    final Greeting greeting = new Greeting();
    greeting.setFirstName("John");
    greeting.setLastName("Doe");
    // When
    given().config(config().encoderConfig(EncoderConfig.encoderConfig().encodeContentTypeAs("application/vnd.ms-excel", ContentType.XML))).multiPart(new MultiPartSpecBuilder(greeting).fileName("RoleBasedAccessFeaturePlan.csv").controlName("text").mimeType("application/vnd.ms-excel").build()).when().post("/multipart/text").then().statusCode(200).body(containsString("John"), containsString("Doe"), containsString("<"));
}
Also used : Greeting(io.restassured.itest.java.objects.Greeting) MultiPartSpecBuilder(io.restassured.builder.MultiPartSpecBuilder) Test(org.junit.Test)

Example 7 with Greeting

use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.

the class ObjectMappingITest method serializesUsingJAXBWhenJAXBObjectMapperIsSpecifiedForPatchVerb.

@Test
public void serializesUsingJAXBWhenJAXBObjectMapperIsSpecifiedForPatchVerb() throws Exception {
    final Greeting object = new Greeting();
    object.setFirstName("John");
    object.setLastName("Doe");
    final Greeting actual = given().body(object, ObjectMapperType.JAXB).when().patch("/reflect").as(Greeting.class, ObjectMapperType.JAXB);
    assertThat(object, equalTo(actual));
}
Also used : Greeting(io.restassured.itest.java.objects.Greeting) Test(org.junit.Test)

Example 8 with Greeting

use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.

the class ObjectMappingITest method mapResponseToObjectUsingJaxbWithJaxObjectMapperDefined.

@Test
public void mapResponseToObjectUsingJaxbWithJaxObjectMapperDefined() throws Exception {
    final Greeting object = given().parameters("firstName", "John", "lastName", "Doe").when().get("/greetXML").as(Greeting.class, ObjectMapperType.JAXB);
    assertThat(object.getFirstName(), equalTo("John"));
    assertThat(object.getLastName(), equalTo("Doe"));
}
Also used : Greeting(io.restassured.itest.java.objects.Greeting) Test(org.junit.Test)

Example 9 with Greeting

use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.

the class ObjectMappingITest method whenRequestContentTypeIsXmlAndCharsetIsUtf16ThenRestAssuredSerializesToJSON.

@Test
public void whenRequestContentTypeIsXmlAndCharsetIsUtf16ThenRestAssuredSerializesToJSON() throws Exception {
    final Greeting object = new Greeting();
    object.setFirstName("John");
    object.setLastName("Doe");
    final Greeting actual = given().contentType("application/xml; charset=UTF-16").and().body(object).when().post("/reflect").as(Greeting.class);
    assertThat(object, equalTo(actual));
}
Also used : Greeting(io.restassured.itest.java.objects.Greeting) Test(org.junit.Test)

Example 10 with Greeting

use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.

the class ObjectMappingITest method serializesUsingGsonWhenGsonObjectMapperIsSpecified.

@Test
public void serializesUsingGsonWhenGsonObjectMapperIsSpecified() throws Exception {
    final Greeting object = new Greeting();
    object.setFirstName("John");
    object.setLastName("Doe");
    final Greeting actual = given().body(object, ObjectMapperType.GSON).when().post("/reflect").as(Greeting.class, ObjectMapperType.GSON);
    assertThat(object, equalTo(actual));
}
Also used : Greeting(io.restassured.itest.java.objects.Greeting) Test(org.junit.Test)

Aggregations

Greeting (io.restassured.itest.java.objects.Greeting)24 Test (org.junit.Test)24 MultiPartSpecBuilder (io.restassured.builder.MultiPartSpecBuilder)6 PrintStream (java.io.PrintStream)2 StringWriter (java.io.StringWriter)2 Type (java.lang.reflect.Type)2 WriterOutputStream (org.apache.commons.io.output.WriterOutputStream)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 LogConfig (io.restassured.config.LogConfig)1 Jackson2Mapper (io.restassured.internal.mapping.Jackson2Mapper)1 DefaultJackson2ObjectMapperFactory (io.restassured.mapper.factory.DefaultJackson2ObjectMapperFactory)1 GsonObjectMapperFactory (io.restassured.mapper.factory.GsonObjectMapperFactory)1 InputStream (java.io.InputStream)1 Map (java.util.Map)1