Search in sources :

Example 21 with Greeting

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

the class ObjectMappingITest method serializesNormalParams.

@Test
public void serializesNormalParams() throws Exception {
    final Greeting object = new Greeting();
    object.setFirstName("John");
    object.setLastName("Doe");
    final Greeting actual = given().contentType(ContentType.JSON).param("something", "something").param("serialized", object).when().put("/serializedJsonParameter").as(Greeting.class);
    assertThat(actual, equalTo(object));
}
Also used : Greeting(io.restassured.itest.java.objects.Greeting) Test(org.junit.Test)

Example 22 with Greeting

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

the class ObjectMappingITest method whenRequestContentTypeIsXmlThenRestAssuredSerializesToXML.

@Test
public void whenRequestContentTypeIsXmlThenRestAssuredSerializesToXML() throws Exception {
    final Greeting object = new Greeting();
    object.setFirstName("John");
    object.setLastName("Doe");
    final Greeting actual = given().contentType(ContentType.XML).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 23 with Greeting

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

the class ObjectMappingITest method whenRequestContentTypeIsJsonAndCharsetIsUsAsciiThenRestAssuredSerializesToJSON.

@Test
public void whenRequestContentTypeIsJsonAndCharsetIsUsAsciiThenRestAssuredSerializesToJSON() throws Exception {
    final Greeting object = new Greeting();
    object.setFirstName("John");
    object.setLastName("Doe");
    final Greeting actual = given().contentType("application/json; charset=US-ASCII").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 24 with Greeting

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

the class ObjectMappingITest method whenRequestContentTypeIsXmlAndCharsetIsUsAsciiThenRestAssuredSerializesToJSON.

@Test
public void whenRequestContentTypeIsXmlAndCharsetIsUsAsciiThenRestAssuredSerializesToJSON() throws Exception {
    final Greeting object = new Greeting();
    object.setFirstName("John");
    object.setLastName("Doe");
    final Greeting actual = given().contentType("application/xml; charset=US-ASCII").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)

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