use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class LoggingITest method logBodyWithPrettyPrintingUsingRequestLogSpecAndObjectMappingWhenXML.
@Test
public void logBodyWithPrettyPrintingUsingRequestLogSpecAndObjectMappingWhenXML() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
final Greeting greeting = new Greeting();
greeting.setFirstName("John");
greeting.setLastName("Doe");
given().contentType(ContentType.XML).config(config().logConfig(new LogConfig(captor, true))).log().body().body(greeting).when().post("/body");
assertThat(writer.toString(), equalTo("Body:\n<greeting>\n <firstName>John</firstName>\n <lastName>Doe</lastName>\n</greeting>" + LINE_SEPARATOR));
}
use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class MultiPartUploadITest method multiPartSupportsSpecifyingAnObjectMapperToMultiPartSpecBuilder.
@Test
public void multiPartSupportsSpecifyingAnObjectMapperToMultiPartSpecBuilder() throws Exception {
// Given
final Greeting greeting = new Greeting();
greeting.setFirstName("John");
greeting.setLastName("Doe");
// When
given().multiPart(new MultiPartSpecBuilder(greeting, new Jackson2Mapper(new DefaultJackson2ObjectMapperFactory())).fileName("RoleBasedAccessFeaturePlan.csv").controlName("text").mimeType("application/vnd.ms-excel").build()).when().post("/multipart/text").then().statusCode(200).body(containsString("John"), containsString("Doe"), containsString("{"));
}
use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class MultiPartUploadITest method multiPartUploadingUsesEncoderConfigToKnowHowToSerializeCustomMimeTypesToJson.
@Test
public void multiPartUploadingUsesEncoderConfigToKnowHowToSerializeCustomMimeTypesToJson() 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.JSON))).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("{"));
}
use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class MultiPartUploadITest method multiPartUploadingThrowsExceptionWhenUsingEncoderConfigToSpecifyNonSerializableContentType.
@Test
public void multiPartUploadingThrowsExceptionWhenUsingEncoderConfigToSpecifyNonSerializableContentType() throws Exception {
// Given
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Cannot serialize because cannot determine how to serialize content-type application/vnd.ms-excel as HTML (no serializer supports this format)");
final Greeting greeting = new Greeting();
greeting.setFirstName("John");
greeting.setLastName("Doe");
// When
given().config(config().encoderConfig(EncoderConfig.encoderConfig().encodeContentTypeAs("application/vnd.ms-excel", ContentType.HTML))).multiPart(new MultiPartSpecBuilder(greeting).fileName("RoleBasedAccessFeaturePlan.csv").controlName("text").mimeType("application/vnd.ms-excel").build()).when().post("/multipart/text");
}
use of io.restassured.itest.java.objects.Greeting in project rest-assured by rest-assured.
the class MultiPartUploadITest method multiPartSupportsSpecifyingAnObjectMapperTypeToMultiPartSpecBuilder.
@Test
public void multiPartSupportsSpecifyingAnObjectMapperTypeToMultiPartSpecBuilder() throws Exception {
// Given
final Greeting greeting = new Greeting();
greeting.setFirstName("John");
greeting.setLastName("Doe");
// When
given().multiPart(new MultiPartSpecBuilder(greeting, ObjectMapperType.JACKSON_2).fileName("RoleBasedAccessFeaturePlan.csv").controlName("text").mimeType("application/vnd.ms-excel").build()).when().post("/multipart/text").then().statusCode(200).body(containsString("John"), containsString("Doe"), containsString("{"));
}
Aggregations