Insist on using CollectionUtils.isEmpty() and StringUtils.hasLength()
search `(\w+) != null && !(\1).isEmpty\(\)`
This commit is contained in:
committed by
Juergen Hoeller
parent
8137cc9566
commit
a02861f7db
@@ -36,6 +36,7 @@ import org.springframework.http.client.MultipartBodyBuilder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -271,7 +272,7 @@ public class MultipartControllerTests {
|
||||
public String processMultipartFileList(@RequestParam(required = false) List<MultipartFile> file,
|
||||
@RequestPart(required = false) Map<String, String> json) throws IOException {
|
||||
|
||||
if (file != null && !file.isEmpty()) {
|
||||
if (!CollectionUtils.isEmpty(file)) {
|
||||
byte[] content = file.get(0).getBytes();
|
||||
assertThat(file.get(1).getBytes()).isEqualTo(content);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.mock.web.MockPart;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@@ -271,7 +272,7 @@ class MultipartControllerTests {
|
||||
public String processMultipartFileList(@RequestParam(required = false) List<MultipartFile> file,
|
||||
@RequestPart(required = false) Map<String, String> json) throws IOException {
|
||||
|
||||
if (file != null && !file.isEmpty()) {
|
||||
if (!CollectionUtils.isEmpty(file)) {
|
||||
byte[] content = file.get(0).getBytes();
|
||||
assertThat(file.get(1).getBytes()).isEqualTo(content);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user