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:
@@ -129,20 +129,20 @@ class DockerComposeFileTests {
|
||||
@Test
|
||||
void ofWhenFileIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> DockerComposeFile.of((File) null))
|
||||
.withMessage("File must not be null");
|
||||
.withMessage("'file' must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenFileDoesNotExistThrowsException() {
|
||||
File file = new File(this.temp, "missing");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> DockerComposeFile.of(file))
|
||||
.withMessageEndingWith("does not exist");
|
||||
.withMessageEndingWith("must exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenFileIsNotFileThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> DockerComposeFile.of(this.temp))
|
||||
.withMessageEndingWith("is not a file");
|
||||
.withMessageEndingWith("must be a normal file");
|
||||
}
|
||||
|
||||
private DockerComposeFile createComposeFile(String name) throws IOException {
|
||||
|
||||
@@ -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 contain an image reference")
|
||||
.withMessageContaining("Test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenNameIncludesTagThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of("ubuntu:latest"))
|
||||
.withMessageContaining("Unable to parse name")
|
||||
.withMessageContaining("must contain an image reference")
|
||||
.withMessageContaining(":latest");
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ class ImageNameTests {
|
||||
void ofWhenNameIncludeDigestThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> ImageName.of("ubuntu@sha256:47bfdb88c3ae13e488167607973b7688f69d9e8c142c2045af343ec199649c09"))
|
||||
.withMessageContaining("Unable to parse name")
|
||||
.withMessageContaining("must contain an image reference")
|
||||
.withMessageContaining("@sha256:47b");
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -165,7 +165,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 contain an image reference");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,7 +173,7 @@ class ImageReferenceTests {
|
||||
void ofWhenImageNameIsVeryLongAndHasIllegalCharacterThrowsException() {
|
||||
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 contain an image reference");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -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.
|
||||
@@ -43,7 +43,7 @@ class JdbcUrlBuilderTests {
|
||||
@Test
|
||||
void createWhenDriverProtocolIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new JdbcUrlBuilder(null, 123))
|
||||
.withMessage("DriverProtocol must not be null");
|
||||
.withMessage("'driverProtocol' must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,7 +84,7 @@ class JdbcUrlBuilderTests {
|
||||
@Test
|
||||
void buildWhenServiceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.builder.build(null, "mydb"))
|
||||
.withMessage("Service must not be null");
|
||||
.withMessage("'service' must not be null");
|
||||
}
|
||||
|
||||
private RunningService mockService(int mappedPort) {
|
||||
|
||||
@@ -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.
|
||||
@@ -46,7 +46,7 @@ class ConnectionFactoryOptionsBuilderTests {
|
||||
@Test
|
||||
void createWhenDriverProtocolIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new JdbcUrlBuilder(null, 123))
|
||||
.withMessage("DriverProtocol must not be null");
|
||||
.withMessage("'driverProtocol' must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,14 +81,14 @@ class ConnectionFactoryOptionsBuilderTests {
|
||||
@Test
|
||||
void buildWhenServiceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.builder.build(null, "mydb", "user", "pass"))
|
||||
.withMessage("Service must not be null");
|
||||
.withMessage("'service' must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWhenDatabaseIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.builder.build(mockService(456), null, "user", "pass"))
|
||||
.withMessage("Database must not be null");
|
||||
.withMessage("'database' must not be null");
|
||||
}
|
||||
|
||||
private RunningService mockService(int mappedPort) {
|
||||
|
||||
Reference in New Issue
Block a user