This commit is contained in:
Rossen Stoyanchev
2019-07-02 09:30:06 +01:00
parent 27b5d2b288
commit 29b7659094
2 changed files with 24 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,9 +53,13 @@ import org.springframework.web.reactive.BindingContext;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.ServerWebInputException;
import static org.junit.Assert.*;
import static org.springframework.core.ResolvableType.*;
import static org.springframework.web.method.MvcAnnotationPredicates.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.springframework.core.ResolvableType.forClass;
import static org.springframework.web.method.MvcAnnotationPredicates.requestPart;
/**
* Unit tests for {@link RequestPartMethodArgumentResolver}.
@@ -132,13 +136,13 @@ public class RequestPartMethodArgumentResolverTests {
assertEquals("James", actual.get(1).getName());
}
@Test
@Test // gh-23060
public void listPersonNotRequired() {
MethodParameter param = this.testMethod.annot(requestPart().notRequired()).arg(List.class, Person.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
List<Person> actual = resolveArgument(param, bodyBuilder);
assertThat(actual).isEmpty();
assertEquals(Collections.emptyList(), actual);
}
@Test
@@ -151,13 +155,13 @@ public class RequestPartMethodArgumentResolverTests {
assertEquals("Jones", actual.block().getName());
}
@Test
@Test // gh-23060
public void monoPersonNotRequired() {
MethodParameter param = this.testMethod.annot(requestPart().notRequired()).arg(Mono.class, Person.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
Mono<Person> actual = resolveArgument(param, bodyBuilder);
assertThat(actual.block()).isNull();
assertNull(actual.block());
}
@Test
@@ -173,13 +177,13 @@ public class RequestPartMethodArgumentResolverTests {
assertEquals("James", persons.get(1).getName());
}
@Test
@Test // gh-23060
public void fluxPersonNotRequired() {
MethodParameter param = this.testMethod.annot(requestPart().notRequired()).arg(Flux.class, Person.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
Flux<Person> actual = resolveArgument(param, bodyBuilder);
assertThat(actual.collectList().block()).isEmpty();
assertEquals(Collections.emptyList(), actual.collectList().block());
}
@Test
@@ -205,13 +209,13 @@ public class RequestPartMethodArgumentResolverTests {
assertEquals("{\"name\":\"James\"}", partToUtf8String(actual.get(1)));
}
@Test
@Test // gh-23060
public void listPartNotRequired() {
MethodParameter param = this.testMethod.annot(requestPart().notRequired()).arg(List.class, Part.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
List<Part> actual = resolveArgument(param, bodyBuilder);
assertThat(actual).isEmpty();
assertEquals(Collections.emptyList(), actual);
}
@Test
@@ -225,13 +229,13 @@ public class RequestPartMethodArgumentResolverTests {
assertEquals("{\"name\":\"Jones\"}", partToUtf8String(part));
}
@Test
@Test // gh-23060
public void monoPartNotRequired() {
MethodParameter param = this.testMethod.annot(requestPart().notRequired()).arg(Mono.class, Part.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
Mono<Part> actual = resolveArgument(param, bodyBuilder);
assertThat(actual.block()).isNull();
assertNull(actual.block());
}
@Test
@@ -247,13 +251,13 @@ public class RequestPartMethodArgumentResolverTests {
assertEquals("{\"name\":\"James\"}", partToUtf8String(parts.get(1)));
}
@Test
@Test // gh-23060
public void fluxPartNotRequired() {
MethodParameter param = this.testMethod.annot(requestPart().notRequired()).arg(Flux.class, Part.class);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
Flux<Part> actual = resolveArgument(param, bodyBuilder);
assertThat(actual.collectList().block()).isEmpty();
assertEquals(Collections.emptyList(), actual.collectList().block());
}
@Test