use of io.restassured.mapper.factory.GsonObjectMapperFactory 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