use of io.restassured.builder.MultiPartSpecBuilder 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.builder.MultiPartSpecBuilder 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.builder.MultiPartSpecBuilder 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.builder.MultiPartSpecBuilder 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("{"));
}
use of io.restassured.builder.MultiPartSpecBuilder 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("<"));
}
Aggregations