Consistent declarations and assertions in MockMultipartFile
See gh-26261
This commit is contained in:
parent
b3a47c76f8
commit
fbd2ffdd23
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
|
@ -21,6 +21,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
|
@ -42,10 +43,10 @@ public class MockMultipartFile implements MultipartFile {
|
|||
|
||||
private final String name;
|
||||
|
||||
private String originalFilename;
|
||||
private final String originalFilename;
|
||||
|
||||
@Nullable
|
||||
private String contentType;
|
||||
private final String contentType;
|
||||
|
||||
private final byte[] content;
|
||||
|
||||
|
|
@ -79,7 +80,7 @@ public class MockMultipartFile implements MultipartFile {
|
|||
public MockMultipartFile(
|
||||
String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) {
|
||||
|
||||
Assert.hasLength(name, "Name must not be null");
|
||||
Assert.hasLength(name, "Name must not be empty");
|
||||
this.name = name;
|
||||
this.originalFilename = (originalFilename != null ? originalFilename : "");
|
||||
this.contentType = contentType;
|
||||
|
|
@ -108,6 +109,7 @@ public class MockMultipartFile implements MultipartFile {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String getOriginalFilename() {
|
||||
return this.originalFilename;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
|
@ -21,6 +21,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
|
@ -42,10 +43,10 @@ public class MockMultipartFile implements MultipartFile {
|
|||
|
||||
private final String name;
|
||||
|
||||
private String originalFilename;
|
||||
private final String originalFilename;
|
||||
|
||||
@Nullable
|
||||
private String contentType;
|
||||
private final String contentType;
|
||||
|
||||
private final byte[] content;
|
||||
|
||||
|
|
@ -79,7 +80,7 @@ public class MockMultipartFile implements MultipartFile {
|
|||
public MockMultipartFile(
|
||||
String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) {
|
||||
|
||||
Assert.hasLength(name, "Name must not be null");
|
||||
Assert.hasLength(name, "Name must not be empty");
|
||||
this.name = name;
|
||||
this.originalFilename = (originalFilename != null ? originalFilename : "");
|
||||
this.contentType = contentType;
|
||||
|
|
@ -108,6 +109,7 @@ public class MockMultipartFile implements MultipartFile {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String getOriginalFilename() {
|
||||
return this.originalFilename;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue