Use consistent exception messages in Assert calls

Update `Assert` calls to consistently use messages of the form
"'item' must [not] ...".

Closes gh-43780
This commit is contained in:
Phillip Webb
2025-01-09 15:33:44 -08:00
parent f08188d5cf
commit a49719d73e
559 changed files with 2001 additions and 2003 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -84,7 +84,7 @@ class BuildOwner implements Owner {
* @throws IllegalStateException if the env does not contain the correct CNB variables
*/
static BuildOwner fromEnv(Map<String, String> env) {
Assert.notNull(env, "Env must not be null");
Assert.notNull(env, "'env' must not be null");
return new BuildOwner(env);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -108,8 +108,8 @@ public class BuildRequest {
private final ImagePlatform platform;
BuildRequest(ImageReference name, Function<Owner, TarArchive> applicationContent) {
Assert.notNull(name, "Name must not be null");
Assert.notNull(applicationContent, "ApplicationContent must not be null");
Assert.notNull(name, "'name' must not be null");
Assert.notNull(applicationContent, "'applicationContent' must not be null");
this.name = name.inTaggedForm();
this.applicationContent = applicationContent;
this.builder = DEFAULT_BUILDER;
@@ -170,7 +170,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withBuilder(ImageReference builder) {
Assert.notNull(builder, "Builder must not be null");
Assert.notNull(builder, "'builder' must not be null");
return new BuildRequest(this.name, this.applicationContent, builder.inTaggedOrDigestForm(), this.trustBuilder,
this.runImage, this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy,
this.publish, this.buildpacks, this.bindings, this.network, this.tags, this.buildWorkspace,
@@ -211,7 +211,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withCreator(Creator creator) {
Assert.notNull(creator, "Creator must not be null");
Assert.notNull(creator, "'creator' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish, this.buildpacks,
this.bindings, this.network, this.tags, this.buildWorkspace, this.buildCache, this.launchCache,
@@ -225,8 +225,8 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withEnv(String name, String value) {
Assert.hasText(name, "Name must not be empty");
Assert.hasText(value, "Value must not be empty");
Assert.hasText(name, "'name' must not be empty");
Assert.hasText(value, "'value' must not be empty");
Map<String, String> env = new LinkedHashMap<>(this.env);
env.put(name, value);
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
@@ -242,7 +242,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withEnv(Map<String, String> env) {
Assert.notNull(env, "Env must not be null");
Assert.notNull(env, "'env' must not be null");
Map<String, String> updatedEnv = new LinkedHashMap<>(this.env);
updatedEnv.putAll(env);
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
@@ -307,7 +307,7 @@ public class BuildRequest {
* @since 2.5.0
*/
public BuildRequest withBuildpacks(BuildpackReference... buildpacks) {
Assert.notEmpty(buildpacks, "Buildpacks must not be empty");
Assert.notEmpty(buildpacks, "'buildpacks' must not be empty");
return withBuildpacks(Arrays.asList(buildpacks));
}
@@ -318,7 +318,7 @@ public class BuildRequest {
* @since 2.5.0
*/
public BuildRequest withBuildpacks(List<BuildpackReference> buildpacks) {
Assert.notNull(buildpacks, "Buildpacks must not be null");
Assert.notNull(buildpacks, "'buildpacks' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish, buildpacks,
this.bindings, this.network, this.tags, this.buildWorkspace, this.buildCache, this.launchCache,
@@ -332,7 +332,7 @@ public class BuildRequest {
* @since 2.5.0
*/
public BuildRequest withBindings(Binding... bindings) {
Assert.notEmpty(bindings, "Bindings must not be empty");
Assert.notEmpty(bindings, "'bindings' must not be empty");
return withBindings(Arrays.asList(bindings));
}
@@ -343,7 +343,7 @@ public class BuildRequest {
* @since 2.5.0
*/
public BuildRequest withBindings(List<Binding> bindings) {
Assert.notNull(bindings, "Bindings must not be null");
Assert.notNull(bindings, "'bindings' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, bindings, this.network, this.tags, this.buildWorkspace, this.buildCache,
@@ -369,7 +369,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withTags(ImageReference... tags) {
Assert.notEmpty(tags, "Tags must not be empty");
Assert.notEmpty(tags, "'tags' must not be empty");
return withTags(Arrays.asList(tags));
}
@@ -379,7 +379,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withTags(List<ImageReference> tags) {
Assert.notNull(tags, "Tags must not be null");
Assert.notNull(tags, "'tags' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, this.bindings, this.network, tags, this.buildWorkspace, this.buildCache,
@@ -393,7 +393,7 @@ public class BuildRequest {
* @since 3.2.0
*/
public BuildRequest withBuildWorkspace(Cache buildWorkspace) {
Assert.notNull(buildWorkspace, "BuildWorkspace must not be null");
Assert.notNull(buildWorkspace, "'buildWorkspace' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, this.bindings, this.network, this.tags, buildWorkspace, this.buildCache,
@@ -406,7 +406,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withBuildCache(Cache buildCache) {
Assert.notNull(buildCache, "BuildCache must not be null");
Assert.notNull(buildCache, "'buildCache' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, this.bindings, this.network, this.tags, this.buildWorkspace, buildCache,
@@ -419,7 +419,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withLaunchCache(Cache launchCache) {
Assert.notNull(launchCache, "LaunchCache must not be null");
Assert.notNull(launchCache, "'launchCache' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, this.bindings, this.network, this.tags, this.buildWorkspace, this.buildCache,
@@ -432,7 +432,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withCreatedDate(String createdDate) {
Assert.notNull(createdDate, "CreatedDate must not be null");
Assert.notNull(createdDate, "'createdDate' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, this.bindings, this.network, this.tags, this.buildWorkspace, this.buildCache,
@@ -458,7 +458,7 @@ public class BuildRequest {
* @return an updated build request
*/
public BuildRequest withApplicationDirectory(String applicationDirectory) {
Assert.notNull(applicationDirectory, "ApplicationDirectory must not be null");
Assert.notNull(applicationDirectory, "'applicationDirectory' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, this.bindings, this.network, this.tags, this.buildWorkspace, this.buildCache,
@@ -472,7 +472,7 @@ public class BuildRequest {
* @since 3.2.0
*/
public BuildRequest withSecurityOptions(List<String> securityOptions) {
Assert.notNull(securityOptions, "SecurityOption must not be null");
Assert.notNull(securityOptions, "'securityOptions' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, this.bindings, this.network, this.tags, this.buildWorkspace, this.buildCache,
@@ -486,7 +486,7 @@ public class BuildRequest {
* @since 3.4.0
*/
public BuildRequest withImagePlatform(String platform) {
Assert.notNull(platform, "Platform must not be null");
Assert.notNull(platform, "'platform' must not be null");
return new BuildRequest(this.name, this.applicationContent, this.builder, this.trustBuilder, this.runImage,
this.creator, this.env, this.cleanCache, this.verboseLogging, this.pullPolicy, this.publish,
this.buildpacks, this.bindings, this.network, this.tags, this.buildWorkspace, this.buildCache,
@@ -715,9 +715,9 @@ public class BuildRequest {
}
private static void assertJarFile(File jarFile) {
Assert.notNull(jarFile, "JarFile must not be null");
Assert.isTrue(jarFile.exists(), "JarFile must exist");
Assert.isTrue(jarFile.isFile(), "JarFile must be a file");
Assert.notNull(jarFile, "'jarFile' must not be null");
Assert.isTrue(jarFile.exists(), "'jarFile' must exist");
Assert.isTrue(jarFile.isFile(), "'jarFile' must be a file");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -90,14 +90,14 @@ public class Builder {
}
Builder(BuildLog log, DockerApi docker, DockerConfiguration dockerConfiguration) {
Assert.notNull(log, "Log must not be null");
Assert.notNull(log, "'log' must not be null");
this.log = log;
this.docker = docker;
this.dockerConfiguration = dockerConfiguration;
}
public void build(BuildRequest request) throws DockerEngineException, IOException {
Assert.notNull(request, "Request must not be null");
Assert.notNull(request, "'request' must not be null");
this.log.start(request);
validateBindings(request.getBindings());
String domain = request.getBuilder().getDomain();
@@ -230,8 +230,8 @@ public class Builder {
}
Image fetchImage(ImageType type, ImageReference reference) throws IOException {
Assert.notNull(type, "Type must not be null");
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(type, "'type' must not be null");
Assert.notNull(reference, "'reference' must not be null");
Assert.state(this.authHeader == null || reference.getDomain().equals(this.domain),
() -> String.format("%s '%s' must be pulled from the '%s' authenticated registry",
StringUtils.capitalize(type.getDescription()), reference, this.domain));

View File

@@ -145,7 +145,7 @@ class BuilderMetadata extends MappedObject {
* @throws IOException on IO error
*/
static BuilderMetadata fromImage(Image image) throws IOException {
Assert.notNull(image, "Image must not be null");
Assert.notNull(image, "'image' must not be null");
return fromImageConfig(image.getConfig());
}
@@ -156,7 +156,7 @@ class BuilderMetadata extends MappedObject {
* @throws IOException on IO error
*/
static BuilderMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
Assert.notNull(imageConfig, "ImageConfig must not be null");
Assert.notNull(imageConfig, "'imageConfig' must not be null");
String json = imageConfig.getLabels().get(LABEL_NAME);
Assert.state(json != null, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");

View File

@@ -64,7 +64,7 @@ final class BuildpackLayersMetadata extends MappedObject {
* @throws IOException on IO error
*/
static BuildpackLayersMetadata fromImage(Image image) throws IOException {
Assert.notNull(image, "Image must not be null");
Assert.notNull(image, "'image' must not be null");
return fromImageConfig(image.getConfig());
}
@@ -75,7 +75,7 @@ final class BuildpackLayersMetadata extends MappedObject {
* @throws IOException on IO error
*/
static BuildpackLayersMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
Assert.notNull(imageConfig, "ImageConfig must not be null");
Assert.notNull(imageConfig, "'imageConfig' must not be null");
String json = imageConfig.getLabels().get(LABEL_NAME);
Assert.state(json != null, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");

View File

@@ -81,7 +81,7 @@ final class BuildpackMetadata extends MappedObject {
* @throws IOException on IO error
*/
static BuildpackMetadata fromImage(Image image) throws IOException {
Assert.notNull(image, "Image must not be null");
Assert.notNull(image, "'image' must not be null");
return fromImageConfig(image.getConfig());
}
@@ -92,7 +92,7 @@ final class BuildpackMetadata extends MappedObject {
* @throws IOException on IO error
*/
static BuildpackMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
Assert.notNull(imageConfig, "ImageConfig must not be null");
Assert.notNull(imageConfig, "'imageConfig' must not be null");
String json = imageConfig.getLabels().get(LABEL_NAME);
Assert.state(json != null, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -94,7 +94,7 @@ public final class BuildpackReference {
* @return a new {@link BuildpackReference}
*/
public static BuildpackReference of(String value) {
Assert.hasText(value, "Value must not be empty");
Assert.hasText(value, "'value' must not be empty");
return new BuildpackReference(value);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 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.
@@ -55,7 +55,7 @@ final class BuildpackResolvers {
* @return a {@link Buildpacks} instance
*/
static Buildpacks resolveAll(BuildpackResolverContext context, Collection<BuildpackReference> references) {
Assert.notNull(context, "Context must not be null");
Assert.notNull(context, "'context' must not be null");
if (CollectionUtils.isEmpty(references)) {
return Buildpacks.EMPTY;
}
@@ -67,7 +67,7 @@ final class BuildpackResolvers {
}
private static Buildpack resolve(BuildpackResolverContext context, BuildpackReference reference) {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(reference, "'reference' must not be null");
for (BuildpackResolver resolver : resolvers) {
Buildpack buildpack = resolver.resolve(context, reference);
if (buildpack != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -85,7 +85,7 @@ public class Cache {
* @return a new cache instance
*/
public static Cache volume(String name) {
Assert.notNull(name, "Name must not be null");
Assert.notNull(name, "'name' must not be null");
return new Volume(VolumeName.of(name));
}
@@ -95,7 +95,7 @@ public class Cache {
* @return a new cache instance
*/
public static Cache volume(VolumeName name) {
Assert.notNull(name, "Name must not be null");
Assert.notNull(name, "'name' must not be null");
return new Volume(name);
}
@@ -105,7 +105,7 @@ public class Cache {
* @return a new cache instance
*/
public static Cache bind(String source) {
Assert.notNull(source, "Source must not be null");
Assert.notNull(source, "'source' must not be null");
return new Bind(source);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -54,7 +54,7 @@ public class Creator {
* @return a new creator instance
*/
public static Creator withVersion(String version) {
Assert.notNull(version, "Version must not be null");
Assert.notNull(version, "'version' must not be null");
return new Creator(version);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -120,19 +120,17 @@ class LifecycleVersion implements Comparable<LifecycleVersion> {
* @throws IllegalArgumentException if the value could not be parsed
*/
static LifecycleVersion parse(String value) {
Assert.hasText(value, "Value must not be empty");
if (value.startsWith("v") || value.startsWith("V")) {
value = value.substring(1);
}
String[] components = value.split("\\.");
Assert.isTrue(components.length <= 3, "Malformed version number '" + value + "'");
Assert.hasText(value, "'value' must not be empty");
String withoutPrefix = (value.startsWith("v") || value.startsWith("V")) ? value.substring(1) : value;
String[] components = withoutPrefix.split("\\.");
Assert.isTrue(components.length <= 3, () -> "'value' [%s] must be a valid version number".formatted(value));
int[] versions = new int[3];
for (int i = 0; i < components.length; i++) {
try {
versions[i] = Integer.parseInt(components[i]);
}
catch (NumberFormatException ex) {
throw new IllegalArgumentException("Malformed version number '" + value + "'", ex);
throw new IllegalArgumentException("'value' [" + value + "] must be a valid version number", ex);
}
}
return new LifecycleVersion(versions[0], versions[1], versions[2]);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -67,7 +67,7 @@ class StackId {
* @return the extracted stack ID
*/
static StackId fromImage(Image image) {
Assert.notNull(image, "Image must not be null");
Assert.notNull(image, "'image' must not be null");
return fromImageConfig(image.getConfig());
}
@@ -87,7 +87,7 @@ class StackId {
* @return a new stack ID instance
*/
static StackId of(String value) {
Assert.hasText(value, "Value must not be empty");
Assert.hasText(value, "'value' must not be empty");
return new StackId(value);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -219,8 +219,8 @@ public class DockerApi {
*/
public Image pull(ImageReference reference, ImagePlatform platform,
UpdateListener<PullImageUpdateEvent> listener, String registryAuth) throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(listener, "Listener must not be null");
Assert.notNull(reference, "'reference' must not be null");
Assert.notNull(listener, "'listener' must not be null");
URI createUri = (platform != null)
? buildUrl(PLATFORM_API_VERSION, "/images/create", "fromImage", reference, "platform", platform)
: buildUrl("/images/create", "fromImage", reference);
@@ -249,8 +249,8 @@ public class DockerApi {
*/
public void push(ImageReference reference, UpdateListener<PushImageUpdateEvent> listener, String registryAuth)
throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(listener, "Listener must not be null");
Assert.notNull(reference, "'reference' must not be null");
Assert.notNull(listener, "'listener' must not be null");
URI pushUri = buildUrl("/images/" + reference + "/push");
ErrorCaptureUpdateListener errorListener = new ErrorCaptureUpdateListener();
listener.onStart();
@@ -274,8 +274,8 @@ public class DockerApi {
* @throws IOException on IO error
*/
public void load(ImageArchive archive, UpdateListener<LoadImageUpdateEvent> listener) throws IOException {
Assert.notNull(archive, "Archive must not be null");
Assert.notNull(listener, "Listener must not be null");
Assert.notNull(archive, "'archive' must not be null");
Assert.notNull(listener, "'listener' must not be null");
URI loadUri = buildUrl("/images/load");
LoadImageUpdateListener streamListener = new LoadImageUpdateListener(archive);
listener.onStart();
@@ -305,8 +305,8 @@ public class DockerApi {
*/
@Deprecated(since = "3.2.6", forRemoval = true)
public void exportLayerFiles(ImageReference reference, IOBiConsumer<String, Path> exports) throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(exports, "Exports must not be null");
Assert.notNull(reference, "'reference' must not be null");
Assert.notNull(exports, "'exports' must not be null");
exportLayers(reference, (name, archive) -> {
Path path = Files.createTempFile("docker-export-layer-files-", null);
try {
@@ -330,8 +330,8 @@ public class DockerApi {
*/
public void exportLayers(ImageReference reference, IOBiConsumer<String, TarArchive> exports)
throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(exports, "Exports must not be null");
Assert.notNull(reference, "'reference' must not be null");
Assert.notNull(exports, "'exports' must not be null");
URI uri = buildUrl("/images/" + reference + "/get");
try (Response response = http().get(uri)) {
try (ExportedImageTar exportedImageTar = new ExportedImageTar(reference, response.getContent())) {
@@ -347,7 +347,7 @@ public class DockerApi {
* @throws IOException on IO error
*/
public void remove(ImageReference reference, boolean force) throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(reference, "'reference' must not be null");
Collection<String> params = force ? FORCE_PARAMS : Collections.emptySet();
URI uri = buildUrl("/images/" + reference, params);
http().delete(uri).close();
@@ -364,7 +364,7 @@ public class DockerApi {
}
private Image inspect(ApiVersion apiVersion, ImageReference reference) throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(reference, "'reference' must not be null");
URI imageUri = buildUrl(apiVersion, "/images/" + reference + "/json");
try (Response response = http().get(imageUri)) {
return Image.of(response.getContent());
@@ -372,8 +372,8 @@ public class DockerApi {
}
public void tag(ImageReference sourceReference, ImageReference targetReference) throws IOException {
Assert.notNull(sourceReference, "SourceReference must not be null");
Assert.notNull(targetReference, "TargetReference must not be null");
Assert.notNull(sourceReference, "'sourceReference' must not be null");
Assert.notNull(targetReference, "'targetReference' must not be null");
String tag = targetReference.getTag();
String path = "/images/" + sourceReference + "/tag";
URI uri = (tag != null) ? buildUrl(path, "repo", targetReference.inTaglessForm(), "tag", tag)
@@ -402,8 +402,8 @@ public class DockerApi {
*/
public ContainerReference create(ContainerConfig config, ImagePlatform platform, ContainerContent... contents)
throws IOException {
Assert.notNull(config, "Config must not be null");
Assert.noNullElements(contents, "Contents must not contain null elements");
Assert.notNull(config, "'config' must not be null");
Assert.noNullElements(contents, "'contents' must not contain null elements");
ContainerReference containerReference = createContainer(config, platform);
for (ContainerContent content : contents) {
uploadContainerContent(containerReference, content);
@@ -432,7 +432,7 @@ public class DockerApi {
* @throws IOException on IO error
*/
public void start(ContainerReference reference) throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(reference, "'reference' must not be null");
URI uri = buildUrl("/containers/" + reference + "/start");
http().post(uri).close();
}
@@ -444,8 +444,8 @@ public class DockerApi {
* @throws IOException on IO error
*/
public void logs(ContainerReference reference, UpdateListener<LogUpdateEvent> listener) throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(listener, "Listener must not be null");
Assert.notNull(reference, "'reference' must not be null");
Assert.notNull(listener, "'listener' must not be null");
Object[] params = { "stdout", "1", "stderr", "1", "follow", "1" };
URI uri = buildUrl("/containers/" + reference + "/logs", params);
listener.onStart();
@@ -466,7 +466,7 @@ public class DockerApi {
* @throws IOException on IO error
*/
public ContainerStatus wait(ContainerReference reference) throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(reference, "'reference' must not be null");
URI uri = buildUrl("/containers/" + reference + "/wait");
try (Response response = http().post(uri)) {
return ContainerStatus.of(response.getContent());
@@ -480,7 +480,7 @@ public class DockerApi {
* @throws IOException on IO error
*/
public void remove(ContainerReference reference, boolean force) throws IOException {
Assert.notNull(reference, "Reference must not be null");
Assert.notNull(reference, "'reference' must not be null");
Collection<String> params = force ? FORCE_PARAMS : Collections.emptySet();
URI uri = buildUrl("/containers/" + reference, params);
http().delete(uri).close();
@@ -503,7 +503,7 @@ public class DockerApi {
* @throws IOException on IO error
*/
public void delete(VolumeName name, boolean force) throws IOException {
Assert.notNull(name, "Name must not be null");
Assert.notNull(name, "'name' must not be null");
Collection<String> params = force ? FORCE_PARAMS : Collections.emptySet();
URI uri = buildUrl("/volumes/" + name, params);
http().delete(uri).close();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -34,7 +34,7 @@ public class TotalProgressEvent {
* @param percent the progress as a percentage
*/
public TotalProgressEvent(int percent) {
Assert.isTrue(percent >= 0 && percent <= 100, "Percent must be in the range 0 to 100");
Assert.isTrue(percent >= 0 && percent <= 100, "'percent' must be in the range 0 to 100");
this.percent = percent;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -64,13 +64,13 @@ public final class DockerConfiguration {
}
public DockerConfiguration withHost(String address, boolean secure, String certificatePath) {
Assert.notNull(address, "Address must not be null");
Assert.notNull(address, "'address' must not be null");
return new DockerConfiguration(DockerHostConfiguration.forAddress(address, secure, certificatePath),
this.builderAuthentication, this.publishAuthentication, this.bindHostToBuilder);
}
public DockerConfiguration withContext(String context) {
Assert.notNull(context, "Context must not be null");
Assert.notNull(context, "'context' must not be null");
return new DockerConfiguration(DockerHostConfiguration.forContext(context), this.builderAuthentication,
this.publishAuthentication, this.bindHostToBuilder);
}
@@ -88,22 +88,22 @@ public final class DockerConfiguration {
public DockerConfiguration withBuilderRegistryUserAuthentication(String username, String password, String url,
String email) {
Assert.notNull(username, "Username must not be null");
Assert.notNull(password, "Password must not be null");
Assert.notNull(username, "'username' must not be null");
Assert.notNull(password, "'password' must not be null");
return new DockerConfiguration(this.host, new DockerRegistryUserAuthentication(username, password, url, email),
this.publishAuthentication, this.bindHostToBuilder);
}
public DockerConfiguration withPublishRegistryTokenAuthentication(String token) {
Assert.notNull(token, "Token must not be null");
Assert.notNull(token, "'token' must not be null");
return new DockerConfiguration(this.host, this.builderAuthentication,
new DockerRegistryTokenAuthentication(token), this.bindHostToBuilder);
}
public DockerConfiguration withPublishRegistryUserAuthentication(String username, String password, String url,
String email) {
Assert.notNull(username, "Username must not be null");
Assert.notNull(password, "Password must not be null");
Assert.notNull(username, "'username' must not be null");
Assert.notNull(password, "'password' must not be null");
return new DockerConfiguration(this.host, this.builderAuthentication,
new DockerRegistryUserAuthentication(username, password, url, email), this.bindHostToBuilder);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -34,8 +34,8 @@ public class DockerConnectionException extends RuntimeException {
}
private static String buildMessage(String host, Exception cause) {
Assert.notNull(host, "Host must not be null");
Assert.notNull(cause, "Cause must not be null");
Assert.notNull(host, "'host' must not be null");
Assert.notNull(cause, "'cause' must not be null");
StringBuilder message = new StringBuilder("Connection to the Docker daemon at '" + host + "' failed");
String causeMessage = getCauseMessage(cause);
if (StringUtils.hasText(causeMessage)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -83,8 +83,8 @@ public class DockerEngineException extends RuntimeException {
private static String buildMessage(String host, URI uri, int statusCode, String reasonPhrase, Errors errors,
Message responseMessage) {
Assert.notNull(host, "Host must not be null");
Assert.notNull(uri, "URI must not be null");
Assert.notNull(host, "'host' must not be null");
Assert.notNull(uri, "'uri' must not be null");
StringBuilder message = new StringBuilder(
"Docker API call to '" + host + uri + "' failed with status code " + statusCode);
if (StringUtils.hasLength(reasonPhrase)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -61,8 +61,8 @@ abstract class HttpClientTransport implements HttpTransport {
private final HttpHost host;
protected HttpClientTransport(HttpClient client, HttpHost host) {
Assert.notNull(client, "Client must not be null");
Assert.notNull(host, "Host must not be null");
Assert.notNull(client, "'client' must not be null");
Assert.notNull(host, "'host' must not be null");
this.client = client;
this.host = host;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -118,16 +118,17 @@ public final class ApiVersion {
* @throws IllegalArgumentException if the value could not be parsed
*/
public static ApiVersion parse(String value) {
Assert.hasText(value, "Value must not be empty");
Assert.hasText(value, "'value' must not be empty");
Matcher matcher = PATTERN.matcher(value);
Assert.isTrue(matcher.matches(), () -> "Malformed version number '" + value + "'");
Assert.isTrue(matcher.matches(),
() -> "'value' [%s] must contain a well formed version number".formatted(value));
try {
int major = Integer.parseInt(matcher.group(1));
int minor = Integer.parseInt(matcher.group(2));
return new ApiVersion(major, minor);
}
catch (NumberFormatException ex) {
throw new IllegalArgumentException("Malformed version number '" + value + "'", ex);
throw new IllegalArgumentException("'value' must contain a well formed version number [" + value + "]", ex);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -110,7 +110,7 @@ public final class Binding {
* @return a new {@link Binding} instance
*/
public static Binding of(String value) {
Assert.notNull(value, "Value must not be null");
Assert.notNull(value, "'value' must not be null");
return new Binding(value);
}
@@ -121,7 +121,7 @@ public final class Binding {
* @return a new {@link Binding} instance
*/
public static Binding from(VolumeName sourceVolume, String destination) {
Assert.notNull(sourceVolume, "SourceVolume must not be null");
Assert.notNull(sourceVolume, "'sourceVolume' must not be null");
return from(sourceVolume.toString(), destination);
}
@@ -132,8 +132,8 @@ public final class Binding {
* @return a new {@link Binding} instance
*/
public static Binding from(String source, String destination) {
Assert.notNull(source, "Source must not be null");
Assert.notNull(destination, "Destination must not be null");
Assert.notNull(source, "'source' must not be null");
Assert.notNull(destination, "'destination' must not be null");
return new Binding(source + ":" + destination);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -51,8 +51,8 @@ public class ContainerConfig {
ContainerConfig(String user, ImageReference image, String command, List<String> args, Map<String, String> labels,
List<Binding> bindings, Map<String, String> env, String networkMode, List<String> securityOptions)
throws IOException {
Assert.notNull(image, "Image must not be null");
Assert.hasText(command, "Command must not be empty");
Assert.notNull(image, "'image' must not be null");
Assert.hasText(command, "'command' must not be empty");
ObjectMapper objectMapper = SharedObjectMapper.get();
ObjectNode node = objectMapper.createObjectNode();
if (StringUtils.hasText(user)) {
@@ -100,8 +100,8 @@ public class ContainerConfig {
* @return a new {@link ContainerConfig} instance
*/
public static ContainerConfig of(ImageReference imageReference, Consumer<Update> update) {
Assert.notNull(imageReference, "ImageReference must not be null");
Assert.notNull(update, "Update must not be null");
Assert.notNull(imageReference, "'imageReference' must not be null");
Assert.notNull(update, "'update' must not be null");
return new Update(imageReference).run(update);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -56,8 +56,8 @@ public interface ContainerContent {
* @return a new {@link ContainerContent} instance
*/
static ContainerContent of(TarArchive archive, String destinationPath) {
Assert.notNull(archive, "Archive must not be null");
Assert.hasText(destinationPath, "DestinationPath must not be empty");
Assert.notNull(archive, "'archive' must not be null");
Assert.hasText(destinationPath, "'destinationPath' must not be empty");
return new ContainerContent() {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -29,7 +29,7 @@ public final class ContainerReference {
private final String value;
private ContainerReference(String value) {
Assert.hasText(value, "Value must not be empty");
Assert.hasText(value, "'value' must not be empty");
this.value = value;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -289,7 +289,7 @@ public class ImageArchive implements TarArchive {
* @param layer the layer to add
*/
public void withNewLayer(Layer layer) {
Assert.notNull(layer, "Layer must not be null");
Assert.notNull(layer, "'layer' must not be null");
this.newLayers.add(layer);
}
@@ -298,7 +298,7 @@ public class ImageArchive implements TarArchive {
* @param createDate the create date
*/
public void withCreateDate(Instant createDate) {
Assert.notNull(createDate, "CreateDate must not be null");
Assert.notNull(createDate, "'createDate' must not be null");
this.createDate = createDate;
}
@@ -307,7 +307,7 @@ public class ImageArchive implements TarArchive {
* @param tag the tag
*/
public void withTag(ImageReference tag) {
Assert.notNull(tag, "Tag must not be null");
Assert.notNull(tag, "'tag' must not be null");
this.tag = tag.inTaggedForm();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 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.
@@ -42,7 +42,7 @@ public class ImageName {
private final String string;
ImageName(String domain, String path) {
Assert.hasText(path, "Path must not be empty");
Assert.hasText(path, "'path' must not be empty");
this.domain = getDomainOrDefault(domain);
this.name = getNameWithDefaultPath(this.domain, path);
this.string = this.domain + "/" + this.name;
@@ -126,13 +126,12 @@ public class ImageName {
* @return an {@link ImageName} instance
*/
public static ImageName of(String value) {
Assert.hasText(value, "Value must not be empty");
Assert.hasText(value, "'value' must not be empty");
String domain = parseDomain(value);
String path = (domain != null) ? value.substring(domain.length() + 1) : value;
Assert.isTrue(Regex.PATH.matcher(path).matches(),
() -> "Unable to parse name \"" + value + "\". "
+ "Image name must be in the form '[domainHost:port/][path/]name', "
+ "with 'path' and 'name' containing only [a-z0-9][.][_][-]");
() -> "'value' [" + value + "] must be a parsable name in the form '[domainHost:port/][path/]name' ("
+ "with 'path' and 'name' containing only [a-z0-9][.][_][-])");
return new ImageName(domain, path);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -35,7 +35,7 @@ public class ImagePlatform {
private final String variant;
ImagePlatform(String os, String architecture, String variant) {
Assert.hasText(os, "OS must not be empty");
Assert.hasText(os, "'os' must not be empty");
this.os = os;
this.architecture = architecture;
this.variant = variant;
@@ -78,14 +78,14 @@ public class ImagePlatform {
* @return an {@link ImagePlatform} instance
*/
public static ImagePlatform of(String value) {
Assert.hasText(value, "Value must not be empty");
Assert.hasText(value, "'value' must not be empty");
String[] split = value.split("/+");
return switch (split.length) {
case 1 -> new ImagePlatform(split[0], null, null);
case 2 -> new ImagePlatform(split[0], split[1], null);
case 3 -> new ImagePlatform(split[0], split[1], split[2]);
default -> throw new IllegalArgumentException(
"ImagePlatform value '" + value + "' must be in the form of os[/architecture[/variant]]");
"'value' [" + value + "] must be in the form 'os[/architecture[/variant]]'");
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -48,7 +48,7 @@ public final class ImageReference {
private final String string;
private ImageReference(ImageName name, String tag, String digest) {
Assert.notNull(name, "Name must not be null");
Assert.notNull(name, "'name' must not be null");
this.name = name;
this.tag = tag;
this.digest = digest;
@@ -186,8 +186,10 @@ public final class ImageReference {
* @return an {@link ImageName} for the jar file.
*/
public static ImageReference forJarFile(File jarFile) {
Assert.notNull(jarFile, "'jarFile' must not be null");
String filename = jarFile.getName();
Assert.isTrue(filename.toLowerCase(Locale.ROOT).endsWith(".jar"), () -> "File '" + jarFile + "' is not a JAR");
Assert.isTrue(filename.toLowerCase(Locale.ROOT).endsWith(".jar"),
() -> "'jarFile' must end with '.jar' [" + jarFile + "]");
filename = filename.substring(0, filename.length() - 4);
int firstDot = filename.indexOf('.');
if (firstDot == -1) {
@@ -236,7 +238,7 @@ public final class ImageReference {
* @return an {@link ImageName} instance
*/
public static ImageReference of(String value) {
Assert.hasText(value, "Value must not be null");
Assert.hasText(value, "'value' must not be null");
String domain = ImageName.parseDomain(value);
String path = (domain != null) ? value.substring(domain.length() + 1) : value;
String digest = null;
@@ -261,11 +263,10 @@ public final class ImageReference {
path = path.substring(0, tagSplit) + remainder;
}
}
Assert.isTrue(isLowerCase(path) && matchesPathRegex(path),
() -> "Unable to parse image reference \"" + value + "\". "
+ "Image reference must be in the form '[domainHost:port/][path/]name[:tag][@digest]', "
+ "with 'path' and 'name' containing only [a-z0-9][.][_][-]");
() -> "'value' [" + value + "] must be an image reference in the form "
+ "'[domainHost:port/][path/]name[:tag][@digest]' "
+ "(with 'path' and 'name' containing only [a-z0-9][.][_][-])");
ImageName name = new ImageName(domain, path);
return new ImageReference(name, tag, digest);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -71,7 +71,7 @@ public class Layer implements Content {
* @throws IOException on IO error
*/
public static Layer of(IOConsumer<Layout> layout) throws IOException {
Assert.notNull(layout, "Layout must not be null");
Assert.notNull(layout, "'layout' must not be null");
return fromTarArchive(TarArchive.of(layout));
}
@@ -82,7 +82,7 @@ public class Layer implements Content {
* @throws IOException on error
*/
public static Layer fromTarArchive(TarArchive tarArchive) throws IOException {
Assert.notNull(tarArchive, "TarArchive must not be null");
Assert.notNull(tarArchive, "'tarArchive' must not be null");
try {
return new Layer(tarArchive);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -83,9 +83,9 @@ public final class LayerId {
* @return a new layer ID instance
*/
public static LayerId of(String value) {
Assert.hasText(value, "Value must not be empty");
Assert.hasText(value, "'value' must not be empty");
int i = value.indexOf(':');
Assert.isTrue(i >= 0, () -> "Invalid layer ID '" + value + "'");
Assert.isTrue(i >= 0, () -> "'value' [%s] must contain a valid layer ID".formatted(value));
return new LayerId(value, value.substring(0, i), value.substring(i + 1));
}
@@ -95,8 +95,8 @@ public final class LayerId {
* @return a new layer ID instance
*/
public static LayerId ofSha256Digest(byte[] digest) {
Assert.notNull(digest, "Digest must not be null");
Assert.isTrue(digest.length == 32, "Digest must be exactly 32 bytes");
Assert.notNull(digest, "'digest' must not be null");
Assert.isTrue(digest.length == 32, "'digest' must be exactly 32 bytes");
String algorithm = "sha256";
String hash = String.format("%064x", new BigInteger(1, digest));
return new LayerId(algorithm + ":" + hash, algorithm, hash);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.
@@ -34,7 +34,7 @@ final class RandomString {
}
static String generate(String prefix, int randomLength) {
Assert.notNull(prefix, "Prefix must not be null");
Assert.notNull(prefix, "'prefix' must not be null");
return prefix + generateRandom(randomLength);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2025 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.
@@ -106,10 +106,10 @@ public final class VolumeName {
*/
public static <S> VolumeName basedOn(S source, Function<S, String> nameExtractor, String prefix, String suffix,
int digestLength) {
Assert.notNull(source, "Source must not be null");
Assert.notNull(nameExtractor, "NameExtractor must not be null");
Assert.notNull(prefix, "Prefix must not be null");
Assert.notNull(suffix, "Suffix must not be null");
Assert.notNull(source, "'source' must not be null");
Assert.notNull(nameExtractor, "'nameExtractor' must not be null");
Assert.notNull(prefix, "'prefix' must not be null");
Assert.notNull(suffix, "'suffix' must not be null");
return of(prefix + getDigest(nameExtractor.apply(source), digestLength) + suffix);
}
@@ -125,7 +125,7 @@ public final class VolumeName {
private static String asHexString(byte[] digest, int digestLength) {
Assert.isTrue(digestLength <= digest.length,
() -> "DigestLength must be less than or equal to " + digest.length);
() -> "'digestLength' must be less than or equal to " + digest.length);
return HexFormat.of().formatHex(digest, 0, digestLength);
}
@@ -135,7 +135,7 @@ public final class VolumeName {
* @return a new {@link VolumeName} instance
*/
public static VolumeName of(String value) {
Assert.notNull(value, "Value must not be null");
Assert.notNull(value, "'value' must not be null");
return new VolumeName(value);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 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.
@@ -54,7 +54,7 @@ public interface Content {
* @return a new {@link Content} instance
*/
static Content of(String string) {
Assert.notNull(string, "String must not be null");
Assert.notNull(string, "'string' must not be null");
return of(string.getBytes(StandardCharsets.UTF_8));
}
@@ -64,7 +64,7 @@ public interface Content {
* @return a new {@link Content} instance
*/
static Content of(byte[] bytes) {
Assert.notNull(bytes, "Bytes must not be null");
Assert.notNull(bytes, "'bytes' must not be null");
return of(bytes.length, () -> new ByteArrayInputStream(bytes));
}
@@ -74,7 +74,7 @@ public interface Content {
* @return a new {@link Content} instance
*/
static Content of(File file) {
Assert.notNull(file, "File must not be null");
Assert.notNull(file, "'file' must not be null");
return of((int) file.length(), () -> new FileInputStream(file));
}
@@ -86,8 +86,8 @@ public interface Content {
* @return a new {@link Content} instance
*/
static Content of(int size, IOSupplier<InputStream> supplier) {
Assert.isTrue(size >= 0, "Size must not be negative");
Assert.notNull(supplier, "Supplier must not be null");
Assert.isTrue(size >= 0, "'size' must not be negative");
Assert.notNull(supplier, "'supplier' must not be null");
return new Content() {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 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.
@@ -45,7 +45,7 @@ public final class FilePermissions {
* @throws IOException if path permissions cannot be read
*/
public static int umaskForPath(Path path) throws IOException {
Assert.notNull(path, "Path must not be null");
Assert.notNull(path, "'path' must not be null");
PosixFileAttributeView attributeView = Files.getFileAttributeView(path, PosixFileAttributeView.class);
Assert.state(attributeView != null, "Unsupported file type for retrieving Posix attributes");
return posixPermissionsToUmask(attributeView.readAttributes().permissions());
@@ -59,7 +59,7 @@ public final class FilePermissions {
* @return the integer representation
*/
public static int posixPermissionsToUmask(Collection<PosixFilePermission> permissions) {
Assert.notNull(permissions, "Permissions must not be null");
Assert.notNull(permissions, "'permissions' must not be null");
int owner = permissionToUmask(permissions, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_WRITE,
PosixFilePermission.OWNER_READ);
int group = permissionToUmask(permissions, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.GROUP_WRITE,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -76,7 +76,7 @@ public class InspectedContent implements Content {
* @throws IOException on IO error
*/
public static InspectedContent of(InputStream inputStream, Inspector... inspectors) throws IOException {
Assert.notNull(inputStream, "InputStream must not be null");
Assert.notNull(inputStream, "'inputStream' must not be null");
return of((outputStream) -> FileCopyUtils.copy(inputStream, outputStream), inspectors);
}
@@ -88,7 +88,7 @@ public class InspectedContent implements Content {
* @throws IOException on IO error
*/
public static InspectedContent of(Content content, Inspector... inspectors) throws IOException {
Assert.notNull(content, "Content must not be null");
Assert.notNull(content, "'content' must not be null");
return of(content::writeTo, inspectors);
}
@@ -101,7 +101,7 @@ public class InspectedContent implements Content {
* @throws IOException on IO error
*/
public static InspectedContent of(IOConsumer<OutputStream> writer, Inspector... inspectors) throws IOException {
Assert.notNull(writer, "Writer must not be null");
Assert.notNull(writer, "'writer' must not be null");
InspectingOutputStream outputStream = new InspectingOutputStream(inspectors);
try (outputStream) {
writer.accept(outputStream);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 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,8 +53,8 @@ public class ZipFileTarArchive implements TarArchive {
* @param owner the owner of the tar entries
*/
public ZipFileTarArchive(File zip, Owner owner) {
Assert.notNull(zip, "Zip must not be null");
Assert.notNull(owner, "Owner must not be null");
Assert.notNull(zip, "'zip' must not be null");
Assert.notNull(owner, "'owner' must not be null");
assertArchiveHasEntries(zip);
this.zip = zip;
this.owner = owner;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -47,7 +47,7 @@ class BuildOwnerTests {
@Test
void fromEnvWhenEnvIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> BuildOwner.fromEnv(null))
.withMessage("Env must not be null");
.withMessage("'env' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -88,20 +88,20 @@ class BuildRequestTests {
@Test
void forJarFileWhenJarFileIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> BuildRequest.forJarFile(null))
.withMessage("JarFile must not be null");
.withMessage("'jarFile' must not be null");
}
@Test
void forJarFileWhenJarFileIsMissingThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> BuildRequest.forJarFile(new File(this.tempDir, "missing.jar")))
.withMessage("JarFile must exist");
.withMessage("'jarFile' must exist");
}
@Test
void forJarFileWhenJarFileIsDirectoryThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> BuildRequest.forJarFile(this.tempDir))
.withMessage("JarFile must be a file");
.withMessage("'jarFile' must be a file");
}
@Test
@@ -217,14 +217,14 @@ class BuildRequestTests {
void withEnvWhenKeyIsNullThrowsException() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
assertThatIllegalArgumentException().isThrownBy(() -> request.withEnv(null, "test"))
.withMessage("Name must not be empty");
.withMessage("'name' must not be empty");
}
@Test
void withEnvWhenValueIsNullThrowsException() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
assertThatIllegalArgumentException().isThrownBy(() -> request.withEnv("test", null))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test
@@ -241,7 +241,7 @@ class BuildRequestTests {
void withBuildpacksWhenBuildpacksIsNullThrowsException() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
assertThatIllegalArgumentException().isThrownBy(() -> request.withBuildpacks((List<BuildpackReference>) null))
.withMessage("Buildpacks must not be null");
.withMessage("'buildpacks' must not be null");
}
@Test
@@ -258,7 +258,7 @@ class BuildRequestTests {
void withBindingsWhenBindingsIsNullThrowsException() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
assertThatIllegalArgumentException().isThrownBy(() -> request.withBindings((List<Binding>) null))
.withMessage("Bindings must not be null");
.withMessage("'bindings' must not be null");
}
@Test
@@ -283,7 +283,7 @@ class BuildRequestTests {
void withTagsWhenTagsIsNullThrowsException() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
assertThatIllegalArgumentException().isThrownBy(() -> request.withTags((List<ImageReference>) null))
.withMessage("Tags must not be null");
.withMessage("'tags' must not be null");
}
@Test
@@ -322,7 +322,7 @@ class BuildRequestTests {
void withBuildVolumeCacheWhenCacheIsNullThrowsException() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
assertThatIllegalArgumentException().isThrownBy(() -> request.withBuildCache(null))
.withMessage("BuildCache must not be null");
.withMessage("'buildCache' must not be null");
}
@Test
@@ -345,7 +345,7 @@ class BuildRequestTests {
void withLaunchVolumeCacheWhenCacheIsNullThrowsException() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
assertThatIllegalArgumentException().isThrownBy(() -> request.withLaunchCache(null))
.withMessage("LaunchCache must not be null");
.withMessage("'launchCache' must not be null");
}
@Test

View File

@@ -90,14 +90,14 @@ class BuilderMetadataTests extends AbstractJsonTests {
@Test
void fromImageWhenImageIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> BuilderMetadata.fromImage(null))
.withMessage("Image must not be null");
.withMessage("'image' must not be null");
}
@Test
void fromImageWhenImageConfigIsNullThrowsException() {
Image image = mock(Image.class);
assertThatIllegalArgumentException().isThrownBy(() -> BuilderMetadata.fromImage(image))
.withMessage("ImageConfig must not be null");
.withMessage("'imageConfig' must not be null");
}
@Test

View File

@@ -66,7 +66,7 @@ class BuilderTests {
@Test
void createWhenLogIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new Builder((BuildLog) null))
.withMessage("Log must not be null");
.withMessage("'log' must not be null");
}
@Test
@@ -79,7 +79,7 @@ class BuilderTests {
void buildWhenRequestIsNullThrowsException() {
Builder builder = new Builder();
assertThatIllegalArgumentException().isThrownBy(() -> builder.build(null))
.withMessage("Request must not be null");
.withMessage("'request' must not be null");
}
@Test

View File

@@ -55,14 +55,14 @@ class BuildpackLayersMetadataTests extends AbstractJsonTests {
@Test
void fromImageWhenImageIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackLayersMetadata.fromImage(null))
.withMessage("Image must not be null");
.withMessage("'image' must not be null");
}
@Test
void fromImageWhenImageConfigIsNullThrowsException() {
Image image = mock(Image.class);
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackLayersMetadata.fromImage(image))
.withMessage("ImageConfig must not be null");
.withMessage("'imageConfig' must not be null");
}
@Test

View File

@@ -49,14 +49,14 @@ class BuildpackMetadataTests extends AbstractJsonTests {
@Test
void fromImageWhenImageIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackMetadata.fromImage(null))
.withMessage("Image must not be null");
.withMessage("'image' must not be null");
}
@Test
void fromImageWhenImageConfigIsNullThrowsException() {
Image image = mock(Image.class);
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackMetadata.fromImage(image))
.withMessage("ImageConfig must not be null");
.withMessage("'imageConfig' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -33,7 +33,7 @@ class BuildpackReferenceTests {
@Test
void ofWhenValueIsEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackReference.of(""))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test

View File

@@ -166,7 +166,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
BuildpackReference reference = BuildpackReference.of("docker://buildpack@0.0.1");
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
assertThatIllegalArgumentException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference))
.withMessageContaining("Unable to parse image reference \"buildpack@0.0.1\"");
.withMessageContaining("'value' [buildpack@0.0.1] must be an image reference");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -31,19 +31,19 @@ class LifecycleVersionTests {
@Test
void parseWhenValueIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> LifecycleVersion.parse(null))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test
void parseWhenTooLongThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> LifecycleVersion.parse("v1.2.3.4"))
.withMessage("Malformed version number '1.2.3.4'");
.withMessage("'value' [v1.2.3.4] must be a valid version number");
}
@Test
void parseWhenNonNumericThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> LifecycleVersion.parse("v1.2.3a"))
.withMessage("Malformed version number '1.2.3a'");
.withMessage("'value' [v1.2.3a] must be a valid version number");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -38,7 +38,7 @@ class StackIdTests {
@Test
void fromImageWhenImageIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> StackId.fromImage(null))
.withMessage("Image must not be null");
.withMessage("'image' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -194,14 +194,14 @@ class DockerApiTests {
@Test
void pullWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.pull(null, null, this.pullListener))
.withMessage("Reference must not be null");
.withMessage("'reference' must not be null");
}
@Test
void pullWhenListenerIsNullThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.api.pull(ImageReference.of("ubuntu"), null, null))
.withMessage("Listener must not be null");
.withMessage("'listener' must not be null");
}
@Test
@@ -267,14 +267,14 @@ class DockerApiTests {
@Test
void pushWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.push(null, this.pushListener, null))
.withMessage("Reference must not be null");
.withMessage("'reference' must not be null");
}
@Test
void pushWhenListenerIsNullThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.api.push(ImageReference.of("ubuntu"), null, null))
.withMessage("Listener must not be null");
.withMessage("'listener' must not be null");
}
@Test
@@ -302,14 +302,14 @@ class DockerApiTests {
@Test
void loadWhenArchiveIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.load(null, UpdateListener.none()))
.withMessage("Archive must not be null");
.withMessage("'archive' must not be null");
}
@Test
void loadWhenListenerIsNullThrowsException() {
ImageArchive archive = mock(ImageArchive.class);
assertThatIllegalArgumentException().isThrownBy(() -> this.api.load(archive, null))
.withMessage("Listener must not be null");
.withMessage("'listener' must not be null");
}
@Test // gh-23130
@@ -352,7 +352,7 @@ class DockerApiTests {
@Test
void removeWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.remove(null, true))
.withMessage("Reference must not be null");
.withMessage("'reference' must not be null");
}
@Test
@@ -380,7 +380,7 @@ class DockerApiTests {
@Test
void inspectWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.inspect(null))
.withMessage("Reference must not be null");
.withMessage("'reference' must not be null");
}
@Test
@@ -396,7 +396,7 @@ class DockerApiTests {
@SuppressWarnings("removal")
void exportLayersWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.exportLayerFiles(null, (name, archive) -> {
})).withMessage("Reference must not be null");
})).withMessage("'reference' must not be null");
}
@Test
@@ -404,7 +404,7 @@ class DockerApiTests {
void exportLayersWhenExportsIsNullThrowsException() {
ImageReference reference = ImageReference.of("gcr.io/paketo-buildpacks/builder:base");
assertThatIllegalArgumentException().isThrownBy(() -> this.api.exportLayerFiles(reference, null))
.withMessage("Exports must not be null");
.withMessage("'exports' must not be null");
}
@Test
@@ -490,14 +490,14 @@ class DockerApiTests {
void tagWhenReferenceIsNullThrowsException() {
ImageReference tag = ImageReference.of("localhost:5000/ubuntu");
assertThatIllegalArgumentException().isThrownBy(() -> this.api.tag(null, tag))
.withMessage("SourceReference must not be null");
.withMessage("'sourceReference' must not be null");
}
@Test
void tagWhenTargetIsNullThrowsException() {
ImageReference reference = ImageReference.of("localhost:5000/ubuntu");
assertThatIllegalArgumentException().isThrownBy(() -> this.api.tag(reference, null))
.withMessage("TargetReference must not be null");
.withMessage("'targetReference' must not be null");
}
@Test
@@ -541,7 +541,7 @@ class DockerApiTests {
@Test
void createWhenConfigIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.create(null, null))
.withMessage("Config must not be null");
.withMessage("'config' must not be null");
}
@Test
@@ -628,7 +628,7 @@ class DockerApiTests {
@Test
void startWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.start(null))
.withMessage("Reference must not be null");
.withMessage("'reference' must not be null");
}
@Test
@@ -643,14 +643,14 @@ class DockerApiTests {
@Test
void logsWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.logs(null, UpdateListener.none()))
.withMessage("Reference must not be null");
.withMessage("'reference' must not be null");
}
@Test
void logsWhenListenerIsNullThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.api.logs(ContainerReference.of("e90e34656806"), null))
.withMessage("Listener must not be null");
.withMessage("'listener' must not be null");
}
@Test
@@ -668,7 +668,7 @@ class DockerApiTests {
@Test
void waitWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.wait(null))
.withMessage("Reference must not be null");
.withMessage("'reference' must not be null");
}
@Test
@@ -683,7 +683,7 @@ class DockerApiTests {
@Test
void removeWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.remove(null, true))
.withMessage("Reference must not be null");
.withMessage("'reference' must not be null");
}
@Test
@@ -719,7 +719,7 @@ class DockerApiTests {
@Test
void deleteWhenNameIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.delete(null, false))
.withMessage("Name must not be null");
.withMessage("'name' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -38,13 +38,13 @@ class TotalProgressEventTests {
@Test
void createWhenPercentLessThanZeroThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new TotalProgressEvent(-1))
.withMessage("Percent must be in the range 0 to 100");
.withMessage("'percent' must be in the range 0 to 100");
}
@Test
void createWhenEventMoreThanOneHundredThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new TotalProgressEvent(101))
.withMessage("Percent must be in the range 0 to 100");
.withMessage("'percent' must be in the range 0 to 100");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -35,13 +35,13 @@ class DockerConnectionExceptionTests {
@Test
void createWhenHostIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new DockerConnectionException(null, null))
.withMessage("Host must not be null");
.withMessage("'host' must not be null");
}
@Test
void createWhenCauseIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new DockerConnectionException(HOST, null))
.withMessage("Cause must not be null");
.withMessage("'cause' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -57,14 +57,14 @@ class DockerEngineExceptionTests {
void createWhenHostIsNullThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new DockerEngineException(null, null, 404, null, NO_ERRORS, NO_MESSAGE))
.withMessage("Host must not be null");
.withMessage("'host' must not be null");
}
@Test
void createWhenUriIsNullThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new DockerEngineException(HOST, null, 404, null, NO_ERRORS, NO_MESSAGE))
.withMessage("URI must not be null");
.withMessage("'uri' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -34,19 +34,19 @@ class ApiVersionTests {
@Test
void parseWhenVersionIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ApiVersion.parse(null))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test
void parseWhenVersionIsEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ApiVersion.parse(""))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test
void parseWhenVersionDoesNotMatchPatternThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ApiVersion.parse("bad"))
.withMessage("Malformed version number 'bad'");
.withMessage("'value' [bad] must contain a well formed version number");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -41,7 +41,7 @@ class BindingTests {
@Test
void ofWithNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Binding.of(null))
.withMessageContaining("Value must not be null");
.withMessageContaining("'value' must not be null");
}
@Test
@@ -53,13 +53,13 @@ class BindingTests {
@Test
void fromWithNullSourceThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Binding.from((String) null, "container-dest"))
.withMessageContaining("Source must not be null");
.withMessageContaining("'source' must not be null");
}
@Test
void fromWithNullDestinationThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Binding.from("host-src", null))
.withMessageContaining("Destination must not be null");
.withMessageContaining("'destination' must not be null");
}
@Test
@@ -71,7 +71,7 @@ class BindingTests {
@Test
void fromVolumeNameSourceWithNullSourceThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Binding.from((VolumeName) null, "container-dest"))
.withMessageContaining("SourceVolume must not be null");
.withMessageContaining("'sourceVolume' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -39,14 +39,14 @@ class ContainerConfigTests extends AbstractJsonTests {
@Test
void ofWhenImageReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ContainerConfig.of(null, (update) -> {
})).withMessage("ImageReference must not be null");
})).withMessage("'imageReference' must not be null");
}
@Test
void ofWhenUpdateIsNullThrowsException() {
ImageReference imageReference = ImageReference.of("ubuntu:bionic");
assertThatIllegalArgumentException().isThrownBy(() -> ContainerConfig.of(imageReference, null))
.withMessage("Update must not be null");
.withMessage("'update' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -34,21 +34,21 @@ class ContainerContentTests {
@Test
void ofWhenArchiveIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ContainerContent.of(null))
.withMessage("Archive must not be null");
.withMessage("'archive' must not be null");
}
@Test
void ofWhenDestinationPathIsNullThrowsException() {
TarArchive archive = mock(TarArchive.class);
assertThatIllegalArgumentException().isThrownBy(() -> ContainerContent.of(archive, null))
.withMessage("DestinationPath must not be empty");
.withMessage("'destinationPath' must not be empty");
}
@Test
void ofWhenDestinationPathIsEmptyThrowsException() {
TarArchive archive = mock(TarArchive.class);
assertThatIllegalArgumentException().isThrownBy(() -> ContainerContent.of(archive, ""))
.withMessage("DestinationPath must not be empty");
.withMessage("'destinationPath' must not be empty");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -38,13 +38,13 @@ class ContainerReferenceTests {
@Test
void ofWhenNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ContainerReference.of(null))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test
void ofWhenEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ContainerReference.of(""))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -118,25 +118,26 @@ class ImageNameTests {
@Test
void ofWhenNameIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of(null))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test
void ofWhenNameIsEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of("")).withMessage("Value must not be empty");
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of(""))
.withMessage("'value' must not be empty");
}
@Test
void ofWhenContainsUppercaseThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of("Test"))
.withMessageContaining("Unable to parse name")
.withMessageContaining("must be a parsable name")
.withMessageContaining("Test");
}
@Test
void ofWhenNameIncludesTagThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of("ubuntu:latest"))
.withMessageContaining("Unable to parse name")
.withMessageContaining("must be a parsable name")
.withMessageContaining(":latest");
}
@@ -144,7 +145,7 @@ class ImageNameTests {
void ofWhenNameIncludeDigestThrowsException() {
assertThatIllegalArgumentException().isThrownBy(
() -> ImageName.of("ubuntu@sha256:47bfdb88c3ae13e488167607973b7688f69d9e8c142c2045af343ec199649c09"))
.withMessageContaining("Unable to parse name")
.withMessageContaining("must be a parsable name")
.withMessageContaining("@sha256:47b");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -48,13 +48,13 @@ class ImagePlatformTests extends AbstractJsonTests {
@Test
void ofWithEmptyValueFails() {
assertThatIllegalArgumentException().isThrownBy(() -> ImagePlatform.of(""))
.withMessageContaining("Value must not be empty");
.withMessageContaining("'value' must not be empty");
}
@Test
void ofWithTooManySegmentsFails() {
assertThatIllegalArgumentException().isThrownBy(() -> ImagePlatform.of("linux/amd64/v1/extra"))
.withMessageContaining("value 'linux/amd64/v1/extra'");
.withMessageContaining("'value' [linux/amd64/v1/extra] must be in the form");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -189,7 +189,7 @@ class ImageReferenceTests {
assertThatIllegalArgumentException()
.isThrownBy(() -> ImageReference
.of("registry.example.com/example/example-app:1.6.0-dev.2.uncommitted+wip.foo.c75795d"))
.withMessageContaining("Unable to parse image reference");
.withMessageContaining("must be an image reference");
}
@Test
@@ -197,7 +197,7 @@ class ImageReferenceTests {
assertThatIllegalArgumentException()
.isThrownBy(() -> ImageReference
.of("europe-west1-docker.pkg.dev/aaaaaa-bbbbb-123456/docker-registry/bootBuildImage:0.0.1"))
.withMessageContaining("Unable to parse image reference");
.withMessageContaining("must be an image reference");
}
@Test
@@ -205,7 +205,7 @@ class ImageReferenceTests {
void ofWhenIsVeryLongAndHasIllegalCharacter() {
assertThatIllegalArgumentException().isThrownBy(() -> ImageReference
.of("docker.io/library/this-image-has-a-long-name-with-an-invalid-tag-which-is-at-danger-of-catastrophic-backtracking:1.0.0+1234"))
.withMessageContaining("Unable to parse image reference");
.withMessageContaining("must be an image reference");
}
@Test
@@ -248,7 +248,7 @@ class ImageReferenceTests {
@Test
void randomWherePrefixIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> ImageReference.random(null))
.withMessage("Prefix must not be null");
.withMessage("'prefix' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -52,12 +52,12 @@ class LayerIdTests {
@Test
void ofWhenValueIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> LayerId.of((String) null))
.withMessage("Value must not be empty");
.withMessage("'value' must not be empty");
}
@Test
void ofWhenValueIsEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> LayerId.of(" ")).withMessage("Value must not be empty");
assertThatIllegalArgumentException().isThrownBy(() -> LayerId.of(" ")).withMessage("'value' must not be empty");
}
@Test
@@ -80,13 +80,13 @@ class LayerIdTests {
@Test
void ofSha256DigestWhenNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> LayerId.ofSha256Digest((byte[]) null))
.withMessage("Digest must not be null");
.withMessage("'digest' must not be null");
}
@Test
void ofSha256DigestWhenWrongLengthThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> LayerId.ofSha256Digest(new byte[31]))
.withMessage("Digest must be exactly 32 bytes");
.withMessage("'digest' must be exactly 32 bytes");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -40,13 +40,13 @@ class LayerTests {
@Test
void ofWhenLayoutIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Layer.of((IOConsumer<Layout>) null))
.withMessage("Layout must not be null");
.withMessage("'layout' must not be null");
}
@Test
void fromTarArchiveWhenTarArchiveIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Layer.fromTarArchive(null))
.withMessage("TarArchive must not be null");
.withMessage("'tarArchive' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -31,7 +31,7 @@ class RandomStringTests {
@Test
void generateWhenPrefixIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> RandomString.generate(null, 10))
.withMessage("Prefix must not be null");
.withMessage("'prefix' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -31,7 +31,7 @@ class VolumeNameTests {
@Test
void randomWhenPrefixIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.random(null))
.withMessage("Prefix must not be null");
.withMessage("'prefix' must not be null");
}
@Test
@@ -57,25 +57,25 @@ class VolumeNameTests {
@Test
void basedOnWhenSourceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn(null, "prefix", "suffix", 6))
.withMessage("Source must not be null");
.withMessage("'source' must not be null");
}
@Test
void basedOnWhenNameExtractorIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn("test", null, "prefix", "suffix", 6))
.withMessage("NameExtractor must not be null");
.withMessage("'nameExtractor' must not be null");
}
@Test
void basedOnWhenPrefixIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn("test", null, "suffix", 6))
.withMessage("Prefix must not be null");
.withMessage("'prefix' must not be null");
}
@Test
void basedOnWhenSuffixIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn("test", "prefix", null, 6))
.withMessage("Suffix must not be null");
.withMessage("'suffix' must not be null");
}
@Test
@@ -87,13 +87,13 @@ class VolumeNameTests {
@Test
void basedOnWhenSizeIsTooBigThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn("name", "prefix", "suffix", 33))
.withMessage("DigestLength must be less than or equal to 32");
.withMessage("'digestLength' must be less than or equal to 32");
}
@Test
void ofWhenValueIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.of(null))
.withMessage("Value must not be null");
.withMessage("'value' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -35,9 +35,9 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class ContentTests {
@Test
void ofWhenStreamIsNullThrowsException() {
void ofWhenSupplierIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Content.of(1, (IOSupplier<InputStream>) null))
.withMessage("Supplier must not be null");
.withMessage("'supplier' must not be null");
}
@Test
@@ -51,7 +51,7 @@ class ContentTests {
@Test
void ofWhenStringIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Content.of((String) null))
.withMessage("String must not be null");
.withMessage("'string' must not be null");
}
@Test
@@ -63,7 +63,7 @@ class ContentTests {
@Test
void ofWhenBytesIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> Content.of((byte[]) null))
.withMessage("Bytes must not be null");
.withMessage("'bytes' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -39,19 +39,19 @@ class InspectedContentTests {
@Test
void ofWhenInputStreamThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((InputStream) null))
.withMessage("InputStream must not be null");
.withMessage("'inputStream' must not be null");
}
@Test
void ofWhenContentIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((Content) null))
.withMessage("Content must not be null");
.withMessage("'content' must not be null");
}
@Test
void ofWhenConsumerIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((IOConsumer<OutputStream>) null))
.withMessage("Writer must not be null");
.withMessage("'writer' must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -46,7 +46,7 @@ class ZipFileTarArchiveTests {
@Test
void createWhenZipIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ZipFileTarArchive(null, Owner.ROOT))
.withMessage("Zip must not be null");
.withMessage("'zip' must not be null");
}
@Test
@@ -54,7 +54,7 @@ class ZipFileTarArchiveTests {
File file = new File(this.tempDir, "test.zip");
writeTestZip(file);
assertThatIllegalArgumentException().isThrownBy(() -> new ZipFileTarArchive(file, null))
.withMessage("Owner must not be null");
.withMessage("'owner' must not be null");
}
@Test