use of org.springframework.http.client.MultipartBodyBuilder in project spring-framework by spring-projects.
the class RequestPartMethodArgumentResolverTests method personNotRequired.
@Test
void personNotRequired() {
MethodParameter param = this.testMethod.annot(requestPart().notRequired()).arg(Person.class);
ServerWebExchange exchange = createExchange(new MultipartBodyBuilder());
Mono<Object> result = this.resolver.resolveArgument(param, new BindingContext(), exchange);
StepVerifier.create(result).verifyComplete();
}
use of org.springframework.http.client.MultipartBodyBuilder in project spring-framework by spring-projects.
the class RequestPartMethodArgumentResolverTests method listPart.
@Test
void listPart() {
MethodParameter param = this.testMethod.annot(requestPart()).arg(List.class, Part.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
bodyBuilder.part("name", new Person("Jones"));
bodyBuilder.part("name", new Person("James"));
List<Part> actual = resolveArgument(param, bodyBuilder);
assertThat(partToUtf8String(actual.get(0))).isEqualTo("{\"name\":\"Jones\"}");
assertThat(partToUtf8String(actual.get(1))).isEqualTo("{\"name\":\"James\"}");
}
use of org.springframework.http.client.MultipartBodyBuilder in project spring-framework by spring-projects.
the class RequestPartMethodArgumentResolverTests method partNotRequired.
@Test
void partNotRequired() {
MethodParameter param = this.testMethod.annot(requestPart().notRequired()).arg(Part.class);
ServerWebExchange exchange = createExchange(new MultipartBodyBuilder());
Mono<Object> result = this.resolver.resolveArgument(param, new BindingContext(), exchange);
StepVerifier.create(result).verifyComplete();
}
use of org.springframework.http.client.MultipartBodyBuilder in project spring-framework by spring-projects.
the class RequestPartMethodArgumentResolverTests method listPerson.
@Test
void listPerson() {
MethodParameter param = this.testMethod.annot(requestPart()).arg(List.class, Person.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
bodyBuilder.part("name", Arrays.asList(new Person("Jones"), new Person("James")));
List<Person> actual = resolveArgument(param, bodyBuilder);
assertThat(actual.get(0).getName()).isEqualTo("Jones");
assertThat(actual.get(1).getName()).isEqualTo("James");
}
use of org.springframework.http.client.MultipartBodyBuilder in project spring-framework by spring-projects.
the class RequestPartMethodArgumentResolverTests method fluxPerson.
@Test
void fluxPerson() {
MethodParameter param = this.testMethod.annot(requestPart()).arg(Flux.class, Person.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
bodyBuilder.part("name", new Person("Jones"));
bodyBuilder.part("name", new Person("James"));
Flux<Person> actual = resolveArgument(param, bodyBuilder);
List<Person> persons = actual.collectList().block();
assertThat(persons.get(0).getName()).isEqualTo("Jones");
assertThat(persons.get(1).getName()).isEqualTo("James");
}
Aggregations