use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class ObjectMappingITest method whenRequestContentTypeIsJsonAndCharsetIsUtf16ThenRestAssuredSerializesToJSON.
@Test
public void whenRequestContentTypeIsJsonAndCharsetIsUtf16ThenRestAssuredSerializesToJSON() throws Exception {
final Greeting object = new Greeting();
object.setFirstName("John");
object.setLastName("Doe");
final Greeting actual = given().contentType("application/json; charset=UTF-16").and().body(object).when().post("/reflect").as(Greeting.class);
assertThat(object, equalTo(actual));
}
use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class ObjectMappingITest method serializesUsingJAXBWhenJAXBObjectMapperIsSpecified.
@Test
public void serializesUsingJAXBWhenJAXBObjectMapperIsSpecified() throws Exception {
final Greeting object = new Greeting();
object.setFirstName("John");
object.setLastName("Doe");
final Greeting actual = given().body(object, ObjectMapperType.JAXB).when().post("/reflect").as(Greeting.class, ObjectMapperType.JAXB);
assertThat(object, equalTo(actual));
}
use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class ObjectMappingITest method mapResponseToObjectUsingJaxb.
@Test
public void mapResponseToObjectUsingJaxb() throws Exception {
final Greeting object = given().parameters("firstName", "John", "lastName", "Doe").when().get("/greetXML").as(Greeting.class);
assertThat(object.getFirstName(), equalTo("John"));
assertThat(object.getLastName(), equalTo("Doe"));
}
use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class ObjectMappingITest method serializesUsingJacksonWhenJacksonObjectMapperIsSpecified.
@Test
public void serializesUsingJacksonWhenJacksonObjectMapperIsSpecified() throws Exception {
final Greeting object = new Greeting();
object.setFirstName("John");
object.setLastName("Doe");
final Greeting actual = given().body(object, ObjectMapperType.JACKSON_1).when().post("/reflect").as(Greeting.class, ObjectMapperType.JACKSON_1);
assertThat(object, equalTo(actual));
}
use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class CustomObjectMappingITest method using_custom_object_mapper_factory.
@Test
public void using_custom_object_mapper_factory() {
final Greeting greeting = new Greeting();
greeting.setFirstName("John");
greeting.setLastName("Doe");
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(objectMapperConfig().gsonObjectMapperFactory(new GsonObjectMapperFactory() {
public Gson create(Type cls, String charset) {
return new GsonBuilder().setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES).create();
}
}));
final Greeting returnedGreeting = given().contentType("application/json").body(greeting, GSON).expect().body("first_name", equalTo("John")).when().post("/reflect").as(Greeting.class, GSON);
assertThat(returnedGreeting.getFirstName(), equalTo("John"));
assertThat(returnedGreeting.getLastName(), equalTo("Doe"));
}
Aggregations