Use Supplier variants of Assert methods
See gh-22699
This commit is contained in:
committed by
Stephane Nicoll
parent
bb3066f61a
commit
e49e2dfff1
@@ -65,7 +65,7 @@ public class JarModeLibrary extends Library {
|
||||
public InputStream openStream() throws IOException {
|
||||
String path = "META-INF/jarmode/" + getCoordinates().getArtifactId() + ".jar";
|
||||
URL resource = getClass().getClassLoader().getResource(path);
|
||||
Assert.state(resource != null, "Unable to find resource " + path);
|
||||
Assert.state(resource != null, () -> "Unable to find resource " + path);
|
||||
return resource.openStream();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public abstract class Packager {
|
||||
protected Packager(File source, LayoutFactory layoutFactory) {
|
||||
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();
|
||||
this.layoutFactory = layoutFactory;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CustomLayers implements Layers {
|
||||
Layer layer = selector.getLayer();
|
||||
Assert.state(layer != null, "Missing content selector layer");
|
||||
Assert.state(layers.contains(layer),
|
||||
"Content selector layer '" + selector.getLayer() + "' not found in " + layers);
|
||||
() -> "Content selector layer '" + selector.getLayer() + "' not found in " + layers);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -130,7 +130,7 @@ class LayersIndexTests {
|
||||
String actualContent = getContent();
|
||||
String name = "LayersIndexTests-" + LayersIndexTests.this.testMethodName + ".txt";
|
||||
InputStream in = LayersIndexTests.class.getResourceAsStream(name);
|
||||
Assert.state(in != null, "Can't read " + name);
|
||||
Assert.state(in != null, () -> "Can't read " + name);
|
||||
String expectedContent = new String(FileCopyUtils.copyToByteArray(in), StandardCharsets.UTF_8);
|
||||
expectedContent = expectedContent.replace("\r", "");
|
||||
assertThat(actualContent).isEqualTo(expectedContent);
|
||||
|
||||
Reference in New Issue
Block a user