Use consistent exception messages in Assert calls
See gh-44044 Signed-off-by: Johnny Lim <izeye@naver.com>
This commit is contained in:
committed by
Moritz Halbritter
parent
c8afa398f1
commit
c9320de559
@@ -40,7 +40,7 @@ public class Layer {
|
||||
* @param name the name of the layer.
|
||||
*/
|
||||
public Layer(String name) {
|
||||
Assert.hasText(name, "Name must not be empty");
|
||||
Assert.hasText(name, "'name' must not be empty");
|
||||
Assert.isTrue(PATTERN.matcher(name).matches(), () -> "Malformed layer name '" + name + "'");
|
||||
Assert.isTrue(!name.equalsIgnoreCase("ext") && !name.toLowerCase(Locale.ROOT).startsWith("springboot"),
|
||||
() -> "Layer name '" + name + "' is reserved");
|
||||
|
||||
@@ -107,9 +107,9 @@ public abstract class Packager {
|
||||
* @param source the source archive file to package
|
||||
*/
|
||||
protected Packager(File source) {
|
||||
Assert.notNull(source, "Source file must not be null");
|
||||
Assert.notNull(source, "'source' file must not be null");
|
||||
Assert.isTrue(source.exists() && source.isFile(),
|
||||
() -> "Source must refer to an existing file, got " + source.getAbsolutePath());
|
||||
() -> "'source' must refer to an existing file, got " + source.getAbsolutePath());
|
||||
this.source = source.getAbsoluteFile();
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public abstract class Packager {
|
||||
* @param layers the jar layers
|
||||
*/
|
||||
public void setLayers(Layers layers) {
|
||||
Assert.notNull(layers, "Layers must not be null");
|
||||
Assert.notNull(layers, "'layers' must not be null");
|
||||
this.layers = layers;
|
||||
this.layersIndex = new LayersIndex(layers);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public abstract class Packager {
|
||||
|
||||
protected final void write(JarFile sourceJar, Libraries libraries, AbstractJarWriter writer,
|
||||
boolean ensureReproducibleBuild) throws IOException {
|
||||
Assert.notNull(libraries, "Libraries must not be null");
|
||||
Assert.notNull(libraries, "'libraries' must not be null");
|
||||
write(sourceJar, writer, new PackagedLibraries(libraries, ensureReproducibleBuild));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ApplicationContentFilter implements ContentFilter<String> {
|
||||
private final String pattern;
|
||||
|
||||
public ApplicationContentFilter(String pattern) {
|
||||
Assert.hasText(pattern, "Pattern must not be empty");
|
||||
Assert.hasText(pattern, "'pattern' must not be empty");
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ public class CustomLayers implements Layers {
|
||||
|
||||
public CustomLayers(List<Layer> layers, List<ContentSelector<String>> applicationSelectors,
|
||||
List<ContentSelector<Library>> librarySelectors) {
|
||||
Assert.notNull(layers, "Layers must not be null");
|
||||
Assert.notNull(applicationSelectors, "ApplicationSelectors must not be null");
|
||||
Assert.notNull(layers, "'layers' must not be null");
|
||||
Assert.notNull(applicationSelectors, "'applicationSelectors' must not be null");
|
||||
validateSelectorLayers(applicationSelectors, layers);
|
||||
Assert.notNull(librarySelectors, "LibrarySelectors must not be null");
|
||||
Assert.notNull(librarySelectors, "'librarySelectors' must not be null");
|
||||
validateSelectorLayers(librarySelectors, layers);
|
||||
this.layers = new ArrayList<>(layers);
|
||||
this.applicationSelectors = new ArrayList<>(applicationSelectors);
|
||||
|
||||
@@ -47,8 +47,8 @@ public class IncludeExcludeContentSelector<T> implements ContentSelector<T> {
|
||||
|
||||
public <S> IncludeExcludeContentSelector(Layer layer, List<S> includes, List<S> excludes,
|
||||
Function<S, ContentFilter<T>> filterFactory) {
|
||||
Assert.notNull(layer, "Layer must not be null");
|
||||
Assert.notNull(filterFactory, "FilterFactory must not be null");
|
||||
Assert.notNull(layer, "'layer' must not be null");
|
||||
Assert.notNull(filterFactory, "'filterFactory' must not be null");
|
||||
this.layer = layer;
|
||||
this.includes = (includes != null) ? adapt(includes, filterFactory) : Collections.emptyList();
|
||||
this.excludes = (excludes != null) ? adapt(excludes, filterFactory) : Collections.emptyList();
|
||||
|
||||
@@ -36,7 +36,7 @@ public class LibraryContentFilter implements ContentFilter<Library> {
|
||||
private final Pattern pattern;
|
||||
|
||||
public LibraryContentFilter(String coordinatesPattern) {
|
||||
Assert.hasText(coordinatesPattern, "CoordinatesPattern must not be empty");
|
||||
Assert.hasText(coordinatesPattern, "'coordinatesPattern' must not be empty");
|
||||
StringBuilder regex = new StringBuilder();
|
||||
for (int i = 0; i < coordinatesPattern.length(); i++) {
|
||||
char c = coordinatesPattern.charAt(i);
|
||||
|
||||
@@ -182,7 +182,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
|
||||
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
|
||||
P packager = createPackager();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> execute(packager, null))
|
||||
.withMessageContaining("Libraries must not be null");
|
||||
.withMessageContaining("'libraries' must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -31,12 +31,12 @@ class LayerTests {
|
||||
|
||||
@Test
|
||||
void createWhenNameIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Layer(null)).withMessage("Name must not be empty");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Layer(null)).withMessage("'name' must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenNameIsEmptyThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("")).withMessage("Name must not be empty");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("")).withMessage("'name' must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -33,13 +33,13 @@ class ApplicationContentFilterTests {
|
||||
@Test
|
||||
void createWhenPatternIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ApplicationContentFilter(null))
|
||||
.withMessage("Pattern must not be empty");
|
||||
.withMessage("'pattern' must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenPatternIsEmptyThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ApplicationContentFilter(""))
|
||||
.withMessage("Pattern must not be empty");
|
||||
.withMessage("'pattern' must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -42,14 +42,14 @@ class IncludeExcludeContentSelectorTests {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(
|
||||
() -> new IncludeExcludeContentSelector<>(null, Collections.emptyList(), Collections.emptyList()))
|
||||
.withMessage("Layer must not be null");
|
||||
.withMessage("'layer' must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenFactoryIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new IncludeExcludeContentSelector<>(LAYER, null, null, null))
|
||||
.withMessage("FilterFactory must not be null");
|
||||
.withMessage("'filterFactory' must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,13 +38,13 @@ class LibraryContentFilterTests {
|
||||
@Test
|
||||
void createWhenCoordinatesPatternIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new LibraryContentFilter(null))
|
||||
.withMessage("CoordinatesPattern must not be empty");
|
||||
.withMessage("'coordinatesPattern' must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenCoordinatesPatternIsEmptyThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new LibraryContentFilter(""))
|
||||
.withMessage("CoordinatesPattern must not be empty");
|
||||
.withMessage("'coordinatesPattern' must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user