diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b76b895703..4bd0cdddf4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,7 +4,11 @@ updates: directory: "/" schedule: interval: "daily" + labels: + - "dependabot: Maven" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" + labels: + - "dependabot: GitHub Actions" diff --git a/.github/workflows/binary-compatibility.yml b/.github/workflows/binary-compatibility.yml index f8d159afbc..80d0e07b50 100644 --- a/.github/workflows/binary-compatibility.yml +++ b/.github/workflows/binary-compatibility.yml @@ -3,10 +3,8 @@ name: Binary Compatibility on: [push, pull_request] jobs: - verify-with-base: - - name: Verify with `${{ github.base_ref }}` + name: Verify with base ref runs-on: ubuntu-latest if: github.base_ref != null @@ -24,13 +22,20 @@ jobs: ref: ${{ github.base_ref }} path: ${{ github.run_id }}.${{ github.base_ref }} - name: Build `${{ github.base_ref }}` - run: ./mvnw -V --no-transfer-progress -e -f ${{ github.run_id }}.${{ github.base_ref }}/pom.xml package -DskipTests + run: > + ./mvnw -B -V --no-transfer-progress -e + -f ${{ github.run_id }}.${{ github.base_ref }}/pom.xml package + -DskipTests + -Djansi.passthrough=true + -Dstyle.color=always - name: Compare `${{ github.head_ref }}` with `${{ github.base_ref }}` run: > - ./mvnw -V --no-transfer-progress -e -Pjapicmp-branch package japicmp:cmp + ./mvnw -B -V --no-transfer-progress -e -Pjapicmp-branch package japicmp:cmp -DskipTests -Djapicmp.breakBuildOnBinaryIncompatibleModifications=true -Djapicmp.oldVersion.basedir=${{ github.run_id }}.${{ github.base_ref }} + -Djansi.passthrough=true + -Dstyle.color=always - name: Add label if: failure() @@ -88,9 +93,11 @@ jobs: - name: Compare with the latest release run: > - ./mvnw -V --no-transfer-progress -e package japicmp:cmp + ./mvnw -B -V --no-transfer-progress -e package japicmp:cmp -DskipTests -Djapicmp.breakBuildOnBinaryIncompatibleModifications=true + -Djansi.passthrough=true + -Dstyle.color=always - name: Add label if: failure() diff --git a/.github/workflows/cross-version.yml b/.github/workflows/cross-version.yml index 3efb56a913..c81ca335cf 100644 --- a/.github/workflows/cross-version.yml +++ b/.github/workflows/cross-version.yml @@ -20,4 +20,7 @@ jobs: release: ${{ matrix.java }} version: latest - name: Test - run: ./mvnw -V --no-transfer-progress -e verify javadoc:javadoc + run: > + ./mvnw -B -V --no-transfer-progress -e verify javadoc:javadoc '-P!coverage' + -Djansi.passthrough=true + -Dstyle.color=always diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7315be2bac..bfc615212f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,10 +6,20 @@ jobs: test_os: name: OS ${{ matrix.os }} + permissions: + # Needed for test reporting + checks: write + pull-requests: write strategy: fail-fast: false matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] + include: + - os: ubuntu-latest + comment-test-results: true + - os: macOS-latest + comment-test-results: false + - os: windows-latest + comment-test-results: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -20,12 +30,27 @@ jobs: java-version: 17 # cache: 'maven' - name: Test - run: ./mvnw -V --no-transfer-progress -e verify javadoc:javadoc + # Note: arguments with a period or bang in them have to be single quoted to prevent + # confusing the PowerShell instance on Windows runners. + run: > + ./mvnw -B -V --no-transfer-progress -e verify javadoc:javadoc '-P!coverage' + '-Djansi.passthrough=true' + '-Dstyle.color=always' + + # Add test results to the PR. + - name: Publish unit test results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: ${{ matrix.comment-test-results }} + continue-on-error: true + with: + check_name: "JUnit test results" + files: "target/surefire-reports/TEST-*.xml" sonar: name: Sonar code analysis runs-on: ubuntu-latest if: github.repository == 'assertj/assertj-core' && github.event_name == 'push' + steps: - uses: actions/checkout@v3 with: @@ -38,10 +63,12 @@ jobs: # cache: 'maven' - name: Test with Sonar run: > - ./mvnw -V --no-transfer-progress -e -Pcoverage verify javadoc:javadoc sonar:sonar + ./mvnw -B -V --no-transfer-progress -e -Pcoverage verify javadoc:javadoc sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=assertj -Dsonar.projectKey=joel-costigliola_assertj-core + -Djansi.passthrough=true + -Dstyle.color=always env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pitest-receive-pr.yml b/.github/workflows/pitest-receive-pr.yml index 29fd53a968..1214978435 100644 --- a/.github/workflows/pitest-receive-pr.yml +++ b/.github/workflows/pitest-receive-pr.yml @@ -38,9 +38,15 @@ jobs: # pitest has been bound to a profile called pitest for normal running # we add config to analyse only changes made within a PR and treat surviving mutants as check errors # failWhenNoMutations is unset in the pom, as otherwise PRs that do not affect java code would fail - run: mvn -e -B -Ppitest -Dfeatures="+GIT(from[HEAD~1]), +gitci" test + run: > + mvn -e -B -Ppitest -Dfeatures="+GIT(from[HEAD~1]), +gitci" test + -Djansi.passthrough=true + -Dstyle.color=always - name: aggregate files - run: mvn -e -B -Ppitest pitest-git:aggregate + run: > + mvn -e -B -Ppitest pitest-git:aggregate + -Djansi.passthrough=true + -Dstyle.color=always - name: upload results uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/pitest-updated-pr.yml b/.github/workflows/pitest-updated-pr.yml index 00b25a1db9..ee39e5f8c3 100644 --- a/.github/workflows/pitest-updated-pr.yml +++ b/.github/workflows/pitest-updated-pr.yml @@ -42,4 +42,7 @@ jobs: # The updatePR maven goal is used here with an explicit version. This allows us to upload without checking out # the code, but does mean the version here must be maintained. An alternative would be to checkout the code and use # the github goal. This will work as long as the artifact is extracted to the maven target directory - run: mvn -DrepoToken=${{ secrets.GITHUB_TOKEN }} com.groupcdg:pitest-github-maven-plugin:0.2.0:updatePR + run: > + mvn -B -DrepoToken=${{ secrets.GITHUB_TOKEN }} com.groupcdg:pitest-github-maven-plugin:0.2.0:updatePR + -Djansi.passthrough=true + -Dstyle.color=always diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1565a43b52..3e90afd4b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,9 @@ jobs: run: | git config user.name '${{ github.actor }}' git config user.email '${{ github.actor }}@users.noreply.github.com' - ./mvnw -B release:prepare release:perform -Dpassword=${{ secrets.GITHUB_TOKEN }} + ./mvnw -B release:prepare release:perform -Dpassword=${{ secrets.GITHUB_TOKEN }} \ + -Djansi.passthrough=true \ + -Dstyle.color=always env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} diff --git a/pom.xml b/pom.xml index 92d719ba6c..a72f4ff19d 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ -html5 --allow-script-in-comments - 1.12.10 + 1.12.11 2.2 1.2.0 @@ -366,12 +366,41 @@ org.apache.maven.plugins maven-surefire-plugin + 3.0.0-M7 false org/assertj/core/osgi/** org/assertj/core/internal/objects/Objects_assertHasOnlyFields_Test* + random + + + + + false + + + + false + false + true + true + + + + false + false + true + true + true + @@ -548,12 +577,12 @@ org.pitest pitest-maven - 1.8.1 + 1.9.0 org.pitest pitest-junit5-plugin - 0.16 + 1.0.0 com.groupcdg @@ -621,6 +650,9 @@ coverage + + true + @@ -636,6 +668,12 @@ + + + prepare-agent + + + jacoco-report prepare-package diff --git a/src/main/java/org/assertj/core/api/AssumptionExceptionFactory.java b/src/main/java/org/assertj/core/api/AssumptionExceptionFactory.java index e4aa761b3e..0d1607a348 100644 --- a/src/main/java/org/assertj/core/api/AssumptionExceptionFactory.java +++ b/src/main/java/org/assertj/core/api/AssumptionExceptionFactory.java @@ -20,7 +20,7 @@ import org.assertj.core.util.VisibleForTesting; /** - * Responsible of building the exception to throw for failing assumptions. + * Responsible for building the exception to throw for failing assumptions. * @since 3.21.0 */ public class AssumptionExceptionFactory { diff --git a/src/main/java/org/assertj/core/configuration/Configuration.java b/src/main/java/org/assertj/core/configuration/Configuration.java index 3be0c6b46d..b3744ca608 100644 --- a/src/main/java/org/assertj/core/configuration/Configuration.java +++ b/src/main/java/org/assertj/core/configuration/Configuration.java @@ -65,6 +65,13 @@ public class Configuration { private PreferredAssumptionException preferredAssumptionException; public Configuration() { + setDefaults(); + } + + /** + * Set all configuration settings to their default values again. + */ + public void setDefaults() { comparingPrivateFields = ALLOW_COMPARING_PRIVATE_FIELDS; extractingPrivateFields = ALLOW_EXTRACTING_PRIVATE_FIELDS; bareNamePropertyExtraction = BARE_NAME_PROPERTY_EXTRACTION_ENABLED; diff --git a/src/main/java/org/assertj/core/internal/Strings.java b/src/main/java/org/assertj/core/internal/Strings.java index 8f451209d3..721b1bd5fd 100644 --- a/src/main/java/org/assertj/core/internal/Strings.java +++ b/src/main/java/org/assertj/core/internal/Strings.java @@ -528,8 +528,7 @@ private boolean stringContains(CharSequence actual, CharSequence sequence) { public void assertContainsIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence sequence) { checkCharSequenceIsNotNull(sequence); assertNotNull(info, actual); - if (!actual.toString().toLowerCase().contains(sequence.toString().toLowerCase())) - throw failures.failure(info, shouldContainIgnoringCase(actual, sequence)); + if (!containsIgnoreCase(actual, sequence)) throw failures.failure(info, shouldContainIgnoringCase(actual, sequence)); } // CS427 Issue link: https://github.com/assertj/assertj-core/issues/2060 @@ -593,8 +592,7 @@ public void assertContainsIgnoringWhitespaces(AssertionInfo info, CharSequence a public void assertDoesNotContainIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence... values) { doCommonCheckForCharSequence(info, actual, values); - String actualLowerCase = actual.toString().toLowerCase(); - Set foundValues = stream(values).filter(value -> actualLowerCase.contains(value.toString().toLowerCase())) + Set foundValues = stream(values).filter(value -> containsIgnoreCase(actual, value)) .collect(toCollection(LinkedHashSet::new)); if (foundValues.isEmpty()) return; if (foundValues.size() == 1 && values.length == 1) { @@ -662,7 +660,7 @@ private boolean areEqualIgnoringCase(CharSequence actual, CharSequence expected) } /** - * Verifies that two {@code CharSequence}s are not equal, normalizing newlines. + * Verifies that two {@code CharSequence}s are equal, normalizing newlines. * * @param info contains information about the assertion. * @param actual the actual {@code CharSequence} (newlines will be normalized). @@ -900,7 +898,7 @@ public void assertStartsWith(AssertionInfo info, CharSequence actual, CharSequen public void assertStartsWithIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence prefix) { failIfPrefixIsNull(prefix); assertNotNull(info, actual); - if (!comparisonStrategy.stringStartsWith(actual.toString().toLowerCase(), prefix.toString().toLowerCase())) + if (!startsWith(actual, prefix, true)) throw failures.failure(info, shouldStartWithIgnoringCase(actual, prefix, comparisonStrategy)); } @@ -935,7 +933,7 @@ public void assertDoesNotStartWith(AssertionInfo info, CharSequence actual, Char public void assertDoesNotStartWithIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence prefix) { failIfPrefixIsNull(prefix); assertNotNull(info, actual); - if (comparisonStrategy.stringStartsWith(actual.toString().toLowerCase(), prefix.toString().toLowerCase())) + if (startsWith(actual, prefix, true)) throw failures.failure(info, shouldNotStartWithIgnoringCase(actual, prefix, comparisonStrategy)); } @@ -974,7 +972,7 @@ public void assertEndsWith(AssertionInfo info, CharSequence actual, CharSequence public void assertEndsWithIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence suffix) { failIfSuffixIsNull(suffix); assertNotNull(info, actual); - if (!comparisonStrategy.stringEndsWith(actual.toString().toLowerCase(), suffix.toString().toLowerCase())) + if (!endsWith(actual, suffix, true)) throw failures.failure(info, shouldEndWithIgnoringCase(actual, suffix, comparisonStrategy)); } @@ -1009,7 +1007,7 @@ public void assertDoesNotEndWith(AssertionInfo info, CharSequence actual, CharSe public void assertDoesNotEndWithIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence suffix) { failIfSuffixIsNull(suffix); assertNotNull(info, actual); - if (comparisonStrategy.stringEndsWith(actual.toString().toLowerCase(), suffix.toString().toLowerCase())) + if (endsWith(actual, suffix, true)) throw failures.failure(info, shouldNotEndWithIgnoringCase(actual, suffix, comparisonStrategy)); } @@ -1358,4 +1356,92 @@ private void doCommonCheckForCharSequence(AssertionInfo info, CharSequence actua checkIsNotEmpty(sequence); checkCharSequenceArrayDoesNotHaveNullElements(sequence); } + + // Source: org.apache.commons.lang3.StringUtils + private static boolean containsIgnoreCase(CharSequence str, CharSequence searchStr) { + if (str == null || searchStr == null) { + return false; + } + final int len = searchStr.length(); + final int max = str.length() - len; + for (int i = 0; i <= max; i++) { + if (regionMatches(str, true, i, searchStr, 0, len)) { + return true; + } + } + return false; + } + + // Source: org.apache.commons.lang3.StringUtils + private static boolean endsWith(CharSequence str, CharSequence suffix, boolean ignoreCase) { + if (str == null || suffix == null) { + return str == suffix; + } + if (suffix.length() > str.length()) { + return false; + } + final int strOffset = str.length() - suffix.length(); + return regionMatches(str, ignoreCase, strOffset, suffix, 0, suffix.length()); + } + + // Source: org.apache.commons.lang3.StringUtils + private static boolean startsWith(CharSequence str, CharSequence prefix, boolean ignoreCase) { + if (str == null || prefix == null) { + return str == prefix; + } + // Get length once instead of twice in the unlikely case that it changes. + final int preLen = prefix.length(); + if (prefix.length() > str.length()) { + return false; + } + return regionMatches(str, ignoreCase, 0, prefix, 0, preLen); + } + + // Source: org.apache.commons.lang3.CharSequenceUtils + private static boolean regionMatches(CharSequence cs, boolean ignoreCase, int thisStart, + CharSequence substring, int start, int length) { + if (cs instanceof String && substring instanceof String) { + return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length); + } + int index1 = thisStart; + int index2 = start; + int tmpLen = length; + + // Extract these first so we detect NPEs the same as the java.lang.String version + final int srcLen = cs.length() - thisStart; + final int otherLen = substring.length() - start; + + // Check for invalid parameters + if (thisStart < 0 || start < 0 || length < 0) { + return false; + } + + // Check that the regions are long enough + if (srcLen < length || otherLen < length) { + return false; + } + + while (tmpLen-- > 0) { + final char c1 = cs.charAt(index1++); + final char c2 = substring.charAt(index2++); + + if (c1 == c2) { + continue; + } + + if (!ignoreCase) { + return false; + } + + // The real same check as in String.regionMatches(): + final char u1 = Character.toUpperCase(c1); + final char u2 = Character.toUpperCase(c2); + if (u1 != u2 && Character.toLowerCase(u1) != Character.toLowerCase(u2)) { + return false; + } + } + + return true; + } + } diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Stream_startsWith_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Stream_startsWith_Test.java index cbaf3e9a0a..c603f842c0 100644 --- a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Stream_startsWith_Test.java +++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Stream_startsWith_Test.java @@ -123,7 +123,7 @@ void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comp assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> { Stream names = Stream.of("Luke", "Leia"); String[] sequence = { "Han", "C-3PO" }; - assertThat(names).usingElementComparator(CaseInsensitiveStringComparator.instance).startsWith(sequence); + assertThat(names).usingElementComparator(CaseInsensitiveStringComparator.INSTANCE).startsWith(sequence); }); } @@ -132,7 +132,7 @@ void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> { Stream names = Stream.of("Luke", "Leia"); String[] sequence = { "Luke", "Obi-Wan", "Han" }; - assertThat(names).usingElementComparator(CaseInsensitiveStringComparator.instance).startsWith(sequence); + assertThat(names).usingElementComparator(CaseInsensitiveStringComparator.INSTANCE).startsWith(sequence); }); } @@ -140,14 +140,14 @@ void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { Stream names = Stream.of("Luke", "Leia"); String[] sequence = { "LUKE" }; - assertThat(names).usingElementComparator(CaseInsensitiveStringComparator.instance).startsWith(sequence); + assertThat(names).usingElementComparator(CaseInsensitiveStringComparator.INSTANCE).startsWith(sequence); } @Test void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { Stream names = Stream.of("Luke", "Leia"); String[] sequence = { "LUKE", "lEIA" }; - assertThat(names).usingElementComparator(CaseInsensitiveStringComparator.instance).startsWith(sequence); + assertThat(names).usingElementComparator(CaseInsensitiveStringComparator.INSTANCE).startsWith(sequence); } @Test diff --git a/src/test/java/org/assertj/core/api/EntryPointAssertions_useDefaultRepresentation_Test.java b/src/test/java/org/assertj/core/api/EntryPointAssertions_useDefaultRepresentation_Test.java index 93f1705a5f..a8b6d87122 100644 --- a/src/test/java/org/assertj/core/api/EntryPointAssertions_useDefaultRepresentation_Test.java +++ b/src/test/java/org/assertj/core/api/EntryPointAssertions_useDefaultRepresentation_Test.java @@ -21,12 +21,14 @@ import org.apache.commons.lang3.tuple.Pair; import org.assertj.core.presentation.Representation; +import org.assertj.core.test.MutatesGlobalConfiguration; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @DisplayName("EntryPoint assertions useDefaultRepresentation method") +@MutatesGlobalConfiguration class EntryPointAssertions_useDefaultRepresentation_Test extends EntryPointAssertionsBaseTest { private static final Representation DEFAULT_CUSTOM_REPRESENTATION = AbstractAssert.customRepresentation; diff --git a/src/test/java/org/assertj/core/api/EntryPoint_Assumptions_setPreferredAssumptionException_Test.java b/src/test/java/org/assertj/core/api/EntryPoint_Assumptions_setPreferredAssumptionException_Test.java index 467dac8b74..f7c0633166 100644 --- a/src/test/java/org/assertj/core/api/EntryPoint_Assumptions_setPreferredAssumptionException_Test.java +++ b/src/test/java/org/assertj/core/api/EntryPoint_Assumptions_setPreferredAssumptionException_Test.java @@ -28,12 +28,14 @@ import java.util.stream.Stream; import org.assertj.core.configuration.PreferredAssumptionException; +import org.assertj.core.test.MutatesGlobalConfiguration; import org.junit.AssumptionViolatedException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.opentest4j.TestAbortedException; +@MutatesGlobalConfiguration class EntryPoint_Assumptions_setPreferredAssumptionException_Test { protected static final WithAssumptions withAssumptions = mock(WithAssumptions.class, CALLS_REAL_METHODS); diff --git a/src/test/java/org/assertj/core/api/SoftAssertionsTest.java b/src/test/java/org/assertj/core/api/SoftAssertionsTest.java index 658a5547c1..3f44316899 100644 --- a/src/test/java/org/assertj/core/api/SoftAssertionsTest.java +++ b/src/test/java/org/assertj/core/api/SoftAssertionsTest.java @@ -2265,17 +2265,17 @@ void should_keep_registered_comparators_after_changing_the_iterable_under_test() // WHEN softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(string -> string.startsWith("Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(new Condition<>(string -> string.startsWith("Ma"), "starts with Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOnAssertions(string -> assertThat(string).startsWith("Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) @@ -2302,17 +2302,17 @@ void should_keep_registered_comparators_after_changing_the_list_under_test() { // WHEN softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(string -> string.startsWith("Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(new Condition<>(string -> string.startsWith("Ma"), "starts with Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOnAssertions(string -> assertThat(string).startsWith("Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) @@ -2339,17 +2339,17 @@ void should_keep_registered_comparators_after_changing_the_object_array_under_te // WHEN softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(string -> string.startsWith("Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(new Condition<>(string -> string.startsWith("Ma"), "starts with Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) .extracting(firstNameFunction) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOnAssertions(string -> assertThat(string).startsWith("Ma")) .containsExactly("MANU", "MAGIC"); softly.assertThat(names) diff --git a/src/test/java/org/assertj/core/api/assumptions/Assumptions_assumeThat_Test.java b/src/test/java/org/assertj/core/api/assumptions/Assumptions_assumeThat_Test.java index 0c2aa0270b..817000f530 100644 --- a/src/test/java/org/assertj/core/api/assumptions/Assumptions_assumeThat_Test.java +++ b/src/test/java/org/assertj/core/api/assumptions/Assumptions_assumeThat_Test.java @@ -40,7 +40,7 @@ void should_run_test_when_all_assumptions_are_met() { assumeThat(asList("John", "Doe", "Jane", "Doe")).as("test description") .withFailMessage("error message") .withRepresentation(UNICODE_REPRESENTATION) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(string -> string.length() == 4) .containsExactly("JOHN", "JANE"); }).doesNotThrowAnyException(); diff --git a/src/test/java/org/assertj/core/api/assumptions/BDDAssumptionsTest.java b/src/test/java/org/assertj/core/api/assumptions/BDDAssumptionsTest.java index 083bfc1e3a..554ca96fcc 100644 --- a/src/test/java/org/assertj/core/api/assumptions/BDDAssumptionsTest.java +++ b/src/test/java/org/assertj/core/api/assumptions/BDDAssumptionsTest.java @@ -1388,7 +1388,7 @@ void should_ignore_test_when_assumption_fails() { class BDDAssumptions_given_Duration_Test { @Test void should_run_test_when_assumption_passes() { - thenCode(() -> given(Duration.ofHours(1)).isNotNull().isPositive()); + thenCode(() -> given(Duration.ofHours(1)).isNotNull().isPositive()).doesNotThrowAnyException(); } @Test diff --git a/src/test/java/org/assertj/core/api/chararray/CharArrayAssert_containsExactly_Test.java b/src/test/java/org/assertj/core/api/chararray/CharArrayAssert_containsExactly_Test.java index 8731c37e09..b0a5d68d53 100644 --- a/src/test/java/org/assertj/core/api/chararray/CharArrayAssert_containsExactly_Test.java +++ b/src/test/java/org/assertj/core/api/chararray/CharArrayAssert_containsExactly_Test.java @@ -18,12 +18,10 @@ import org.assertj.core.api.CharArrayAssert; import org.assertj.core.api.CharArrayAssertBaseTest; -import org.assertj.core.util.CaseInsensitiveCharacterComparator; +import org.assertj.core.test.CaseInsensitiveCharacterComparator; import org.junit.jupiter.api.Test; /** - * Tests for {@link org.assertj.core.api.CharArrayAssert#containsExactly(char...)}. - * * @author Jean-Christophe Gay */ class CharArrayAssert_containsExactly_Test extends CharArrayAssertBaseTest { @@ -41,7 +39,7 @@ protected void verify_internal_effects() { @Test void should_honor_the_given_element_comparator() { char[] actual = arrayOf('a', 'b'); - assertThat(actual).usingElementComparator(CaseInsensitiveCharacterComparator.instance) + assertThat(actual).usingElementComparator(CaseInsensitiveCharacterComparator.INSTANCE) .containsExactly('a', 'B'); } } diff --git a/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_usingCustomComparator_Test.java b/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_usingCustomComparator_Test.java index b4340c45d9..ff0844031a 100644 --- a/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_usingCustomComparator_Test.java +++ b/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_usingCustomComparator_Test.java @@ -18,7 +18,7 @@ import org.assertj.core.api.CharSequenceAssert; import org.assertj.core.api.CharSequenceAssertBaseTest; -import org.assertj.core.util.CaseInsensitiveCharSequenceComparator; +import org.assertj.core.test.CaseInsensitiveCharSequenceComparator; /** * Tests for {@link CharSequenceAssert#usingComparator(Comparator)}. @@ -30,12 +30,12 @@ class CharSequenceAssert_usingCustomComparator_Test extends CharSequenceAssertBa @Override protected CharSequenceAssert invoke_api_method() { - return assertions.usingComparator(CaseInsensitiveCharSequenceComparator.instance); + return assertions.usingComparator(CaseInsensitiveCharSequenceComparator.INSTANCE); } @Override protected void verify_internal_effects() { - assertThat(CaseInsensitiveCharSequenceComparator.instance).isSameAs(getObjects(assertions).getComparator()); - assertThat(CaseInsensitiveCharSequenceComparator.instance).isSameAs(getStrings(assertions).getComparator()); + assertThat(CaseInsensitiveCharSequenceComparator.INSTANCE).isSameAs(getObjects(assertions).getComparator()); + assertThat(CaseInsensitiveCharSequenceComparator.INSTANCE).isSameAs(getStrings(assertions).getComparator()); } } diff --git a/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_usingDefaultComparator_Test.java b/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_usingDefaultComparator_Test.java index fe60e7761b..ffddd8aea7 100644 --- a/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_usingDefaultComparator_Test.java +++ b/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_usingDefaultComparator_Test.java @@ -18,7 +18,7 @@ import org.assertj.core.api.CharSequenceAssertBaseTest; import org.assertj.core.internal.Objects; import org.assertj.core.internal.Strings; -import org.assertj.core.util.CaseInsensitiveCharSequenceComparator; +import org.assertj.core.test.CaseInsensitiveCharSequenceComparator; /** * Tests for {@link CharSequenceAssert#usingDefaultComparator()}. @@ -29,7 +29,7 @@ class CharSequenceAssert_usingDefaultComparator_Test extends CharSequenceAssertB @Override protected CharSequenceAssert invoke_api_method() { - return assertions.usingComparator(CaseInsensitiveCharSequenceComparator.instance) + return assertions.usingComparator(CaseInsensitiveCharSequenceComparator.INSTANCE) .usingDefaultComparator(); } diff --git a/src/test/java/org/assertj/core/api/iterable/IterableAssert_extractingResultOf_Test.java b/src/test/java/org/assertj/core/api/iterable/IterableAssert_extractingResultOf_Test.java index 18ca9bc2b3..3e66081d82 100644 --- a/src/test/java/org/assertj/core/api/iterable/IterableAssert_extractingResultOf_Test.java +++ b/src/test/java/org/assertj/core/api/iterable/IterableAssert_extractingResultOf_Test.java @@ -104,7 +104,7 @@ void extractingResultOf_should_keep_assertion_state() { "foo") .usingComparatorForElementFieldsWithType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class) - .usingComparatorForType(CaseInsensitiveStringComparator.instance, + .usingComparatorForType(CaseInsensitiveStringComparator.INSTANCE, String.class) .extractingResultOf("toString") .containsOnly("YODA", "darth vader"); @@ -112,7 +112,7 @@ void extractingResultOf_should_keep_assertion_state() { assertThat(assertion.descriptionText()).isEqualTo("test description"); assertThat(assertion.info.representation()).isEqualTo(UNICODE_REPRESENTATION); assertThat(assertion.info.overridingErrorMessage()).isEqualTo("error message"); - assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.instance); + assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.INSTANCE); assertThat(comparatorForElementFieldsWithTypeOf(assertion).getComparatorForType(Timestamp.class)).isSameAs(ALWAYS_EQUALS_TIMESTAMP); assertThat(comparatorForElementFieldsWithNamesOf(assertion).get("foo")).isSameAs(ALWAYS_EQUALS_STRING); } @@ -128,7 +128,7 @@ void strongly_typed_extractingResultOf_should_keep_assertion_state() { "foo") .usingComparatorForElementFieldsWithType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class) - .usingComparatorForType(CaseInsensitiveStringComparator.instance, + .usingComparatorForType(CaseInsensitiveStringComparator.INSTANCE, String.class) .extractingResultOf("toString", String.class) .containsOnly("YODA", "darth vader"); @@ -136,7 +136,7 @@ void strongly_typed_extractingResultOf_should_keep_assertion_state() { assertThat(assertion.descriptionText()).isEqualTo("test description"); assertThat(assertion.info.representation()).isEqualTo(UNICODE_REPRESENTATION); assertThat(assertion.info.overridingErrorMessage()).isEqualTo("error message"); - assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.instance); + assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.INSTANCE); assertThat(comparatorForElementFieldsWithTypeOf(assertion).getComparatorForType(Timestamp.class)).isSameAs(ALWAYS_EQUALS_TIMESTAMP); assertThat(comparatorForElementFieldsWithNamesOf(assertion).get("foo")).isSameAs(ALWAYS_EQUALS_STRING); } diff --git a/src/test/java/org/assertj/core/api/iterable/IterableAssert_extractingResultOf_with_SortedSet_Test.java b/src/test/java/org/assertj/core/api/iterable/IterableAssert_extractingResultOf_with_SortedSet_Test.java index ccd5ecf38d..45b360fd41 100644 --- a/src/test/java/org/assertj/core/api/iterable/IterableAssert_extractingResultOf_with_SortedSet_Test.java +++ b/src/test/java/org/assertj/core/api/iterable/IterableAssert_extractingResultOf_with_SortedSet_Test.java @@ -107,14 +107,14 @@ void extractingResultOf_should_keep_assertion_state() { .usingComparatorForElementFieldsWithType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class) .extractingResultOf("toString") - .usingComparatorForType(CaseInsensitiveStringComparator.instance, + .usingComparatorForType(CaseInsensitiveStringComparator.INSTANCE, String.class) .containsOnly("YODA", "darth vader"); // THEN assertThat(assertion.descriptionText()).isEqualTo("test description"); assertThat(assertion.info.representation()).isEqualTo(UNICODE_REPRESENTATION); assertThat(assertion.info.overridingErrorMessage()).isEqualTo("error message"); - assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.instance); + assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.INSTANCE); assertThat(comparatorForElementFieldsWithTypeOf(assertion).getComparatorForType(Timestamp.class)).isSameAs(ALWAYS_EQUALS_TIMESTAMP); assertThat(comparatorForElementFieldsWithNamesOf(assertion).get("foo")).isSameAs(ALWAYS_EQUALS_STRING); } @@ -131,14 +131,14 @@ void strongly_typed_extractingResultOf_should_keep_assertion_state() { .usingComparatorForElementFieldsWithType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class) .extractingResultOf("toString", String.class) - .usingComparatorForType(CaseInsensitiveStringComparator.instance, + .usingComparatorForType(CaseInsensitiveStringComparator.INSTANCE, String.class) .containsOnly("YODA", "darth vader"); // THEN assertThat(assertion.descriptionText()).isEqualTo("test description"); assertThat(assertion.info.representation()).isEqualTo(UNICODE_REPRESENTATION); assertThat(assertion.info.overridingErrorMessage()).isEqualTo("error message"); - assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.instance); + assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.INSTANCE); assertThat(comparatorForElementFieldsWithTypeOf(assertion).getComparatorForType(Timestamp.class)).isSameAs(ALWAYS_EQUALS_TIMESTAMP); assertThat(comparatorForElementFieldsWithNamesOf(assertion).get("foo")).isSameAs(ALWAYS_EQUALS_STRING); } diff --git a/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOnAssertions_ThrowingConsumer_Test.java b/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOnAssertions_ThrowingConsumer_Test.java index 8fcd4bc8b2..1c7d5c8ae0 100644 --- a/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOnAssertions_ThrowingConsumer_Test.java +++ b/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOnAssertions_ThrowingConsumer_Test.java @@ -125,7 +125,7 @@ void should_keep_assertion_state() { IterableAssert assertion = assertThat(names).as("test description") .withFailMessage("error message") .withRepresentation(UNICODE_REPRESENTATION) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOnAssertions(fourCharsWord) .containsExactly("JOHN", "JANE"); // THEN diff --git a/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOnAssertions_consumer_Test.java b/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOnAssertions_consumer_Test.java index c20d97c8f5..d78d340acc 100644 --- a/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOnAssertions_consumer_Test.java +++ b/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOnAssertions_consumer_Test.java @@ -97,7 +97,7 @@ void should_keep_assertion_state() { IterableAssert assertion = assertThat(names).as("test description") .withFailMessage("error message") .withRepresentation(UNICODE_REPRESENTATION) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOnAssertions(string -> assertThat(string.length()).isEqualTo(4)) .containsExactly("JOHN", "JANE"); // THEN diff --git a/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOn_condition_Test.java b/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOn_condition_Test.java index 5bbbaa47e6..4c8773d335 100644 --- a/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOn_condition_Test.java +++ b/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOn_condition_Test.java @@ -127,7 +127,7 @@ void should_keep_assertion_state() { IterableAssert assertion = assertThat(names).as("test description") .withFailMessage("error message") .withRepresentation(UNICODE_REPRESENTATION) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(new Condition<>(string -> string.length() == 4, "4 letters")) .containsExactly("JOHN", "JANE"); // THEN diff --git a/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOn_predicate_Test.java b/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOn_predicate_Test.java index 9eab244f48..218f2f685b 100644 --- a/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOn_predicate_Test.java +++ b/src/test/java/org/assertj/core/api/iterable/IterableAssert_filteredOn_predicate_Test.java @@ -95,7 +95,7 @@ void should_keep_assertion_state() { IterableAssert assertion = assertThat(names).as("test description") .withFailMessage("error message") .withRepresentation(UNICODE_REPRESENTATION) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOn(string -> string.length() == 4) .containsExactly("JOHN", "JANE"); // THEN diff --git a/src/test/java/org/assertj/core/api/iterable/IterableAssert_flatExtracting_with_multiple_extractors_Test.java b/src/test/java/org/assertj/core/api/iterable/IterableAssert_flatExtracting_with_multiple_extractors_Test.java index 3a01ec310c..9a5f803979 100644 --- a/src/test/java/org/assertj/core/api/iterable/IterableAssert_flatExtracting_with_multiple_extractors_Test.java +++ b/src/test/java/org/assertj/core/api/iterable/IterableAssert_flatExtracting_with_multiple_extractors_Test.java @@ -138,7 +138,7 @@ void flatExtracting_with_multiple_extractors_should_keep_assertion_state() { .withRepresentation(UNICODE_REPRESENTATION) .usingComparatorForElementFieldsWithNames(ALWAYS_EQUALS_STRING, "foo") .usingComparatorForElementFieldsWithType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class) - .usingComparatorForType(CaseInsensitiveStringComparator.instance, String.class) + .usingComparatorForType(CaseInsensitiveStringComparator.INSTANCE, String.class) .flatExtracting(age, name) .contains(33, "frodo", 38, "SAM"); // @format:on @@ -147,7 +147,7 @@ void flatExtracting_with_multiple_extractors_should_keep_assertion_state() { then(assertion.info.representation()).isEqualTo(UNICODE_REPRESENTATION); then(assertion.info.overridingErrorMessage()).isEqualTo("error message"); then(comparatorsByTypeOf(assertion).getComparatorForType(String.class)) - .isSameAs(CaseInsensitiveStringComparator.instance); + .isSameAs(CaseInsensitiveStringComparator.INSTANCE); then(comparatorForElementFieldsWithTypeOf(assertion).getComparatorForType(Timestamp.class)) .isSameAs(ALWAYS_EQUALS_TIMESTAMP); then(comparatorForElementFieldsWithNamesOf(assertion).get("foo")).isSameAs(ALWAYS_EQUALS_STRING); @@ -165,7 +165,7 @@ void flatExtracting_with_multiple_ThrowingExtractors_should_keep_assertion_state .withRepresentation(UNICODE_REPRESENTATION) .usingComparatorForElementFieldsWithNames(ALWAYS_EQUALS_STRING, "foo") .usingComparatorForElementFieldsWithType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class) - .usingComparatorForType(CaseInsensitiveStringComparator.instance, String.class) + .usingComparatorForType(CaseInsensitiveStringComparator.INSTANCE, String.class) .flatExtracting(ageThrowingExtractor, nameThrowingExtractor) .contains(33, "frodo", 38, "SAM"); // @format:on @@ -174,7 +174,7 @@ void flatExtracting_with_multiple_ThrowingExtractors_should_keep_assertion_state then(assertion.info.representation()).isEqualTo(UNICODE_REPRESENTATION); then(assertion.info.overridingErrorMessage()).isEqualTo("error message"); then(comparatorsByTypeOf(assertion).getComparatorForType(String.class)) - .isSameAs(CaseInsensitiveStringComparator.instance); + .isSameAs(CaseInsensitiveStringComparator.INSTANCE); then(comparatorForElementFieldsWithTypeOf(assertion).getComparatorForType(Timestamp.class)) .isSameAs(ALWAYS_EQUALS_TIMESTAMP); then(comparatorForElementFieldsWithNamesOf(assertion).get("foo")).isSameAs(ALWAYS_EQUALS_STRING); diff --git a/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_extractingResultOf_Test.java b/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_extractingResultOf_Test.java index 8251634c64..b314249dee 100644 --- a/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_extractingResultOf_Test.java +++ b/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_extractingResultOf_Test.java @@ -104,7 +104,7 @@ void extractingResultOf_should_keep_assertion_state() { "foo") .usingComparatorForElementFieldsWithType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class) - .usingComparatorForType(CaseInsensitiveStringComparator.instance, + .usingComparatorForType(CaseInsensitiveStringComparator.INSTANCE, String.class) .extractingResultOf("toString") .containsOnly("YODA", "darth vader"); @@ -112,7 +112,7 @@ void extractingResultOf_should_keep_assertion_state() { assertThat(assertion.descriptionText()).isEqualTo("test description"); assertThat(assertion.info.representation()).isEqualTo(UNICODE_REPRESENTATION); assertThat(assertion.info.overridingErrorMessage()).isEqualTo("error message"); - assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.instance); + assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.INSTANCE); assertThat(comparatorForElementFieldsWithTypeOf(assertion).getComparatorForType(Timestamp.class)).isSameAs(ALWAYS_EQUALS_TIMESTAMP); assertThat(comparatorForElementFieldsWithNamesOf(assertion).get("foo")).isSameAs(ALWAYS_EQUALS_STRING); } @@ -128,7 +128,7 @@ void strongly_typed_extractingResultOf_should_keep_assertion_state() { "foo") .usingComparatorForElementFieldsWithType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class) - .usingComparatorForType(CaseInsensitiveStringComparator.instance, + .usingComparatorForType(CaseInsensitiveStringComparator.INSTANCE, String.class) .extractingResultOf("toString", String.class) .containsOnly("YODA", "darth vader"); @@ -136,7 +136,7 @@ void strongly_typed_extractingResultOf_should_keep_assertion_state() { assertThat(assertion.descriptionText()).isEqualTo("test description"); assertThat(assertion.info.representation()).isEqualTo(UNICODE_REPRESENTATION); assertThat(assertion.info.overridingErrorMessage()).isEqualTo("error message"); - assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.instance); + assertThat(comparatorsByTypeOf(assertion).getComparatorForType(String.class)).isSameAs(CaseInsensitiveStringComparator.INSTANCE); assertThat(comparatorForElementFieldsWithTypeOf(assertion).getComparatorForType(Timestamp.class)).isSameAs(ALWAYS_EQUALS_TIMESTAMP); assertThat(comparatorForElementFieldsWithNamesOf(assertion).get("foo")).isSameAs(ALWAYS_EQUALS_STRING); } diff --git a/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_filteredOnAssertions_Test.java b/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_filteredOnAssertions_Test.java index ca5e418d60..4d459a9f8b 100644 --- a/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_filteredOnAssertions_Test.java +++ b/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_filteredOnAssertions_Test.java @@ -97,7 +97,7 @@ void should_keep_assertion_state() { IterableAssert assertion = assertThat(names).as("test description") .withFailMessage("error message") .withRepresentation(UNICODE_REPRESENTATION) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOnAssertions(string -> assertThat(string.length()).isEqualTo(4)) .containsExactly("JOHN", "JANE"); // THEN diff --git a/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_filteredOnAssertions_ThrowingConsumer_Test.java b/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_filteredOnAssertions_ThrowingConsumer_Test.java index a355118ec3..47d0e7883a 100644 --- a/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_filteredOnAssertions_ThrowingConsumer_Test.java +++ b/src/test/java/org/assertj/core/api/objectarray/ObjectArrayAssert_filteredOnAssertions_ThrowingConsumer_Test.java @@ -76,7 +76,7 @@ void should_keep_assertion_state() { ObjectArrayAssert assertion = assertThat(names).as("test description") .withFailMessage("error message") .withRepresentation(UNICODE_REPRESENTATION) - .usingElementComparator(CaseInsensitiveStringComparator.instance) + .usingElementComparator(CaseInsensitiveStringComparator.INSTANCE) .filteredOnAssertions(fourCharsWord) .containsExactly("JOHN", "JANE"); // THEN diff --git a/src/test/java/org/assertj/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_withFieldComparators_Test.java b/src/test/java/org/assertj/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_withFieldComparators_Test.java index fde88f3ac0..d6a59b311b 100644 --- a/src/test/java/org/assertj/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_withFieldComparators_Test.java +++ b/src/test/java/org/assertj/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_withFieldComparators_Test.java @@ -96,7 +96,7 @@ private static Stream recursivelyEqualObjectsWhenUsingFieldComparator person6.neighbour = new Person("Jim"); person6.neighbour.home.address.number = 456; - return Stream.of(arguments(person1, person2, CaseInsensitiveStringComparator.instance, array("name"), + return Stream.of(arguments(person1, person2, CaseInsensitiveStringComparator.INSTANCE, array("name"), "same data except int fields and case for strings"), arguments(person3, person4, alwaysEqual(), array("name", "home.address.number"), "same data except for int fields"), diff --git a/src/test/java/org/assertj/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_withTypeComparators_Test.java b/src/test/java/org/assertj/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_withTypeComparators_Test.java index 18b918432a..cd51de472f 100644 --- a/src/test/java/org/assertj/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_withTypeComparators_Test.java +++ b/src/test/java/org/assertj/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_withTypeComparators_Test.java @@ -105,7 +105,7 @@ private static Stream recursivelyEqualObjectsWhenUsingTypeComparators person6.neighbour = new Person("Jim"); person6.neighbour.home.address.number = 456; - MapEntry, Comparator> stringComparator = entry(String.class, CaseInsensitiveStringComparator.instance); + MapEntry, Comparator> stringComparator = entry(String.class, CaseInsensitiveStringComparator.INSTANCE); MapEntry, Comparator> intComparator = entry(Integer.class, new AlwaysEqualComparator()); MapEntry, Comparator> personComparator = entry(Person.class, new AlwaysEqualComparator()); return Stream.of(arguments(person1, person2, mapOf(stringComparator, intComparator), diff --git a/src/test/java/org/assertj/core/api/string_/StringAssert_usingCustomComparator_Test.java b/src/test/java/org/assertj/core/api/string_/StringAssert_usingCustomComparator_Test.java index f35490840b..91b721e220 100644 --- a/src/test/java/org/assertj/core/api/string_/StringAssert_usingCustomComparator_Test.java +++ b/src/test/java/org/assertj/core/api/string_/StringAssert_usingCustomComparator_Test.java @@ -16,11 +16,11 @@ import org.assertj.core.api.StringAssert; import org.assertj.core.api.StringAssertBaseTest; -import org.assertj.core.util.CaseInsensitiveCharSequenceComparator; +import org.assertj.core.test.CaseInsensitiveCharSequenceComparator; class StringAssert_usingCustomComparator_Test extends StringAssertBaseTest { - private CaseInsensitiveCharSequenceComparator comparator = CaseInsensitiveCharSequenceComparator.instance; + private CaseInsensitiveCharSequenceComparator comparator = CaseInsensitiveCharSequenceComparator.INSTANCE; @Override protected StringAssert invoke_api_method() { diff --git a/src/test/java/org/assertj/core/api/string_/StringAssert_usingDefaultComparator_Test.java b/src/test/java/org/assertj/core/api/string_/StringAssert_usingDefaultComparator_Test.java index be49f38166..a2e0cdab73 100644 --- a/src/test/java/org/assertj/core/api/string_/StringAssert_usingDefaultComparator_Test.java +++ b/src/test/java/org/assertj/core/api/string_/StringAssert_usingDefaultComparator_Test.java @@ -19,14 +19,14 @@ import org.assertj.core.internal.Comparables; import org.assertj.core.internal.Objects; import org.assertj.core.internal.Strings; -import org.assertj.core.util.CaseInsensitiveCharSequenceComparator; +import org.assertj.core.test.CaseInsensitiveCharSequenceComparator; import org.junit.jupiter.api.BeforeEach; class StringAssert_usingDefaultComparator_Test extends StringAssertBaseTest { @BeforeEach void before() { - assertions.usingComparator(CaseInsensitiveCharSequenceComparator.instance); + assertions.usingComparator(CaseInsensitiveCharSequenceComparator.INSTANCE); } @Override diff --git a/src/test/java/org/assertj/core/configuration/Configuration_apply_Test.java b/src/test/java/org/assertj/core/configuration/Configuration_apply_Test.java index 9e1444a65c..fe0fded3c3 100644 --- a/src/test/java/org/assertj/core/configuration/Configuration_apply_Test.java +++ b/src/test/java/org/assertj/core/configuration/Configuration_apply_Test.java @@ -21,11 +21,13 @@ import org.assertj.core.api.AssumptionExceptionFactory; import org.assertj.core.internal.Failures; import org.assertj.core.presentation.StandardRepresentation; +import org.assertj.core.test.MutatesGlobalConfiguration; import org.assertj.core.util.introspection.FieldSupport; import org.assertj.core.util.introspection.Introspection; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +@MutatesGlobalConfiguration class Configuration_apply_Test { @Test diff --git a/src/test/java/org/assertj/core/configuration/Configuration_describe_Test.java b/src/test/java/org/assertj/core/configuration/Configuration_describe_Test.java index ce1c8bf436..d236cd51d8 100644 --- a/src/test/java/org/assertj/core/configuration/Configuration_describe_Test.java +++ b/src/test/java/org/assertj/core/configuration/Configuration_describe_Test.java @@ -18,9 +18,11 @@ import java.util.function.Consumer; import org.assertj.core.description.Description; +import org.assertj.core.test.MutatesGlobalConfiguration; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +@MutatesGlobalConfiguration class Configuration_describe_Test { @Test diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqual_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqual_Test.java index b14902fd60..f391fd1568 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqual_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqual_Test.java @@ -37,7 +37,7 @@ void should_display_comparison_strategy_in_error_message() { String actual = "Luke"; String expected = "Yoda"; ThrowingCallable code = () -> then(actual).as("Jedi") - .usingComparator(CaseInsensitiveStringComparator.instance) + .usingComparator(CaseInsensitiveStringComparator.INSTANCE) .isEqualTo(expected); // WHEN AssertionFailedError error = catchThrowableOfType(code, AssertionFailedError.class); diff --git a/src/test/java/org/assertj/core/error/ShouldBeIn_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeIn_create_Test.java index 9951f7277e..88e090b4b5 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeIn_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeIn_create_Test.java @@ -50,7 +50,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldBeIn("Yoda", array("Luke", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldBeSubsetOf_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeSubsetOf_create_Test.java index c4f03d4238..4fb4929eb2 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeSubsetOf_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeSubsetOf_create_Test.java @@ -48,7 +48,7 @@ void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldBeSubsetOf(list("Yoda", "Luke"), list("Han", "Luke"), list("Yoda"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldBeSubstringOf_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeSubstringOf_create_Test.java index caf0502dbf..8af58be710 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeSubstringOf_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeSubstringOf_create_Test.java @@ -43,7 +43,7 @@ void should_create_error_message() { void should_create_error_message_with_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldBeSubstring("bcd", "abcdef", - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainAnyOf_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainAnyOf_create_Test.java index fa33bfbcb5..65a8f0908f 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainAnyOf_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainAnyOf_create_Test.java @@ -44,7 +44,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldContainAnyOf(list("Yoda", "Han", "Han"), list("Vador", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), CONFIGURATION_PROVIDER.representation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainAtIndex_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainAtIndex_create_Test.java index 907ed7b70d..f7340bfd58 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainAtIndex_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainAtIndex_create_Test.java @@ -46,7 +46,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldContainAtIndex(list("Yoda", "Luke"), "Leia", atIndex(1), "Luke", - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainCharSequenceOnlyOnce_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainCharSequenceOnlyOnce_create_Test.java index 257e4a494d..e97906f177 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainCharSequenceOnlyOnce_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainCharSequenceOnlyOnce_create_Test.java @@ -55,7 +55,7 @@ void should_create_error_message_when_string_to_search_does_not_appear() { void should_create_error_message_when_string_to_search_does_not_appear_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldContainOnlyOnce("aaamoDifmoifaabbbmotfaaa", "MOtif", 0, - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN @@ -66,7 +66,7 @@ void should_create_error_message_when_string_to_search_does_not_appear_with_cust void should_create_error_message_when_string_to_search_appears_several_times_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldContainOnlyOnce("aaamotIFmoTifaabbbmotifaaa", "MOtif", 3, - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainCharSequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainCharSequence_create_Test.java index 4a215c50b0..eb99c21360 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainCharSequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainCharSequence_create_Test.java @@ -56,7 +56,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldContain("Yoda", "Luke", - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN @@ -85,7 +85,7 @@ void should_create_error_message_when_ignoring_whitespaces() { void should_create_error_message_with_custom_comparison_strategy_when_ignoring_whitespaces() { // GIVEN ErrorMessageFactory factory = shouldContainIgnoringWhitespaces("Yoda", "Luke", - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN @@ -150,7 +150,7 @@ void should_create_error_message_with_several_CharSequence_values_when_ignoring_ void should_create_error_message_with_custom_comparison_strategy_when_ignoring_new_lines() { // GIVEN final ErrorMessageFactory factory = containsIgnoringNewLines("Yoda", array("Yoda", "Luke"), set("Luke"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN final String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainExactlyInAnyOrder_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainExactlyInAnyOrder_create_Test.java index 76bdedc997..9c52e9b599 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainExactlyInAnyOrder_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainExactlyInAnyOrder_create_Test.java @@ -37,7 +37,7 @@ */ class ShouldContainExactlyInAnyOrder_create_Test { - private static final ComparatorBasedComparisonStrategy CASE_INSENSITIVE_COMPARISON_STRATEGY = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); + private static final ComparatorBasedComparisonStrategy CASE_INSENSITIVE_COMPARISON_STRATEGY = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE); @Test void should_create_error_message_with_custom_comparison_strategy() { diff --git a/src/test/java/org/assertj/core/error/ShouldContainExactly_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainExactly_create_Test.java index 7b58bb23c3..2a4ab0eef6 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainExactly_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainExactly_create_Test.java @@ -28,7 +28,7 @@ class ShouldContainExactly_create_Test { - private static final ComparatorBasedComparisonStrategy CASE_INSENSITIVE_COMPARISON_STRATEGY = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); + private static final ComparatorBasedComparisonStrategy CASE_INSENSITIVE_COMPARISON_STRATEGY = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE); @Test void should_display_missing_and_unexpected_elements() { diff --git a/src/test/java/org/assertj/core/error/ShouldContainOnly_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainOnly_create_Test.java index 0fc92bcc66..e85b16c540 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainOnly_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainOnly_create_Test.java @@ -45,7 +45,7 @@ */ class ShouldContainOnly_create_Test { - private static final ComparatorBasedComparisonStrategy CASE_INSENSITIVE_COMPARISON_STRATEGY = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); + private static final ComparatorBasedComparisonStrategy CASE_INSENSITIVE_COMPARISON_STRATEGY = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE); @Test void should_create_error_message() { diff --git a/src/test/java/org/assertj/core/error/ShouldContainSequenceOfCharSequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainSequenceOfCharSequence_create_Test.java index 348ccb8ad3..6235ee7fb8 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainSequenceOfCharSequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainSequenceOfCharSequence_create_Test.java @@ -49,7 +49,7 @@ void should_create_error_message_with_custom_comparison_strategy() { String[] sequenceValues = { "{", "author", "title", "}" }; String actual = "{ 'title':'A Game of Thrones', 'author':'George Martin'}"; ErrorMessageFactory factory = shouldContainSequence(actual, sequenceValues, - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainSequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainSequence_create_Test.java index 2339359af6..41a3a9b699 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainSequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainSequence_create_Test.java @@ -49,7 +49,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldContainSequence(list("Yoda", "Luke"), list("Han", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainSubsequenceOfCharSequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainSubsequenceOfCharSequence_create_Test.java index c608c9f906..13ea50b0b9 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainSubsequenceOfCharSequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainSubsequenceOfCharSequence_create_Test.java @@ -51,7 +51,7 @@ void should_create_error_message_with_custom_comparison_strategy() { String[] sequenceValues = { "{", "author", "title", "}" }; String actual = "{ 'title':'A Game of Thrones', 'author':'George Martin'}"; ErrorMessageFactory factory = shouldContainSubsequence(actual, sequenceValues, 1, - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainSubsequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainSubsequence_create_Test.java index a127884b1a..bd1b3bf1fb 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainSubsequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainSubsequence_create_Test.java @@ -69,7 +69,7 @@ void should_create_error_message_with_first_subsequence_element_not_found_and_it void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldContainSubsequence(list("Yoda", "Luke"), array("Yoda", "Leia"), 1, - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContain_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContain_create_Test.java index 9bfc7c8457..10d94ca05d 100644 --- a/src/test/java/org/assertj/core/error/ShouldContain_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContain_create_Test.java @@ -63,7 +63,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldContain(list("Yoda"), list("Luke", "Yoda"), newLinkedHashSet("Luke"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test")); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldContainsOnlyOnce_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainsOnlyOnce_create_Test.java index 3f4b3a19b5..b65c7390d1 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainsOnlyOnce_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainsOnlyOnce_create_Test.java @@ -60,7 +60,7 @@ void should_create_error_message_with_custom_comparison_strategy() { // GIVEN factory = shouldContainsOnlyOnce(list("Yoda", "Han"), list("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldEndWith_create_Test.java b/src/test/java/org/assertj/core/error/ShouldEndWith_create_Test.java index 2642a90860..9df3449622 100644 --- a/src/test/java/org/assertj/core/error/ShouldEndWith_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldEndWith_create_Test.java @@ -49,7 +49,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldEndWith(list("Yoda", "Luke"), list("Han", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeEqual_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeEqual_create_Test.java index a413430171..c7a6fdfbb4 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeEqual_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeEqual_create_Test.java @@ -44,7 +44,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldNotBeEqual("Yoda", "Luke", - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TestDescription("Jedi"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeIn_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeIn_create_Test.java index 54cc530cd2..6dd3b427bc 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeIn_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeIn_create_Test.java @@ -51,7 +51,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldNotBeIn("Luke", array("Luke", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotContainAtIndex_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContainAtIndex_create_Test.java index 7b8243a56f..23598ca986 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContainAtIndex_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContainAtIndex_create_Test.java @@ -52,7 +52,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN factory = shouldNotContainAtIndex(list("Yoda", "Luke"), "Luke", atIndex(1), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotContainCharSequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContainCharSequence_create_Test.java index 357e90a6f8..dfcb469020 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContainCharSequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContainCharSequence_create_Test.java @@ -56,7 +56,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldNotContain("Yoda", "od", - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotContainSequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContainSequence_create_Test.java index e7038c42d6..3d85363dc4 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContainSequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContainSequence_create_Test.java @@ -44,7 +44,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldNotContainSequence(list("yoDA", "LUke"), list("Yoda", "Luke"), 1, - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotContainSubsequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContainSubsequence_create_Test.java index 915e10849e..07950404ce 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContainSubsequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContainSubsequence_create_Test.java @@ -39,7 +39,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldNotContainSubsequence(list("Yoda", "LUke", "LeiA"), list("Luke", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance), 1); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE), 1); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotContain_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContain_create_Test.java index 23629c8ba8..6f8fd566a8 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContain_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContain_create_Test.java @@ -66,7 +66,7 @@ void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldNotContain(list("Yoda"), list("Luke", "Yoda"), newLinkedHashSet("Yoda"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotEndWithIgnoringCase_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotEndWithIgnoringCase_create_Test.java index 57ac07810b..2c9ae7d406 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotEndWithIgnoringCase_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotEndWithIgnoringCase_create_Test.java @@ -44,7 +44,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldNotEndWithIgnoringCase("Gandalf the grey", "GREY", - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotEndWith_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotEndWith_create_Test.java index 79912062aa..2a71ee6f52 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotEndWith_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotEndWith_create_Test.java @@ -50,7 +50,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN ErrorMessageFactory factory = shouldNotEndWith(list("Yoda", "Luke"), list("Han", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotHaveDuplicates_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotHaveDuplicates_create_Test.java index 9387854251..9963d0123c 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotHaveDuplicates_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotHaveDuplicates_create_Test.java @@ -51,7 +51,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN factory = shouldNotHaveDuplicates(list("Yoda", "Yoda", "Luke"), list("Yoda"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldNotStartWith_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotStartWith_create_Test.java index 2396b76b1b..aab93d0ed3 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotStartWith_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotStartWith_create_Test.java @@ -56,7 +56,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN factory = shouldNotStartWith(list("Yoda", "Luke"), list("Han", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); // THEN diff --git a/src/test/java/org/assertj/core/error/ShouldStartWith_create_Test.java b/src/test/java/org/assertj/core/error/ShouldStartWith_create_Test.java index 30bb8fb8b1..05dd127bb4 100644 --- a/src/test/java/org/assertj/core/error/ShouldStartWith_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldStartWith_create_Test.java @@ -55,7 +55,7 @@ void should_create_error_message() { void should_create_error_message_with_custom_comparison_strategy() { // GIVEN factory = shouldStartWith(list("Yoda", "Luke"), list("Han", "Leia"), - new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); + new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE)); // WHEN String message = factory.create(new TextDescription("Test"), STANDARD_REPRESENTATION); // THEN diff --git a/src/test/java/org/assertj/core/extention/SoftlyExtensionInstanceTest.java b/src/test/java/org/assertj/core/extension/SoftlyExtensionInstanceTest.java similarity index 98% rename from src/test/java/org/assertj/core/extention/SoftlyExtensionInstanceTest.java rename to src/test/java/org/assertj/core/extension/SoftlyExtensionInstanceTest.java index ae9731cada..12b754902f 100644 --- a/src/test/java/org/assertj/core/extention/SoftlyExtensionInstanceTest.java +++ b/src/test/java/org/assertj/core/extension/SoftlyExtensionInstanceTest.java @@ -10,7 +10,7 @@ * * Copyright 2012-2022 the original author or authors. */ -package org.assertj.core.extention; +package org.assertj.core.extension; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.util.AssertionsUtil.assertThatAssertionErrorIsThrownBy; diff --git a/src/test/java/org/assertj/core/internal/AbstractTest_ComparatorBasedComparisonStrategy.java b/src/test/java/org/assertj/core/internal/AbstractTest_ComparatorBasedComparisonStrategy.java index 277d7dec88..0488767644 100644 --- a/src/test/java/org/assertj/core/internal/AbstractTest_ComparatorBasedComparisonStrategy.java +++ b/src/test/java/org/assertj/core/internal/AbstractTest_ComparatorBasedComparisonStrategy.java @@ -18,7 +18,7 @@ public class AbstractTest_ComparatorBasedComparisonStrategy { - protected Comparator caseInsensitiveStringComparator = CaseInsensitiveStringComparator.instance; + protected Comparator caseInsensitiveStringComparator = CaseInsensitiveStringComparator.INSTANCE; protected ComparatorBasedComparisonStrategy caseInsensitiveComparisonStrategy = new ComparatorBasedComparisonStrategy( caseInsensitiveStringComparator); protected ComparatorBasedComparisonStrategy describedComparisonStrategy = new ComparatorBasedComparisonStrategy( diff --git a/src/test/java/org/assertj/core/internal/CharArraysBaseTest.java b/src/test/java/org/assertj/core/internal/CharArraysBaseTest.java index 57b0751664..5f1c7efc22 100644 --- a/src/test/java/org/assertj/core/internal/CharArraysBaseTest.java +++ b/src/test/java/org/assertj/core/internal/CharArraysBaseTest.java @@ -17,7 +17,7 @@ import java.util.Comparator; -import org.assertj.core.util.CaseInsensitiveCharacterComparator; +import org.assertj.core.test.CaseInsensitiveCharacterComparator; import org.junit.jupiter.api.BeforeEach; @@ -66,4 +66,4 @@ protected void setArrays(Arrays internalArrays) { arrays.setArrays(internalArrays); } -} \ No newline at end of file +} diff --git a/src/test/java/org/assertj/core/internal/CharactersBaseTest.java b/src/test/java/org/assertj/core/internal/CharactersBaseTest.java index 60d5154376..411e33eaff 100644 --- a/src/test/java/org/assertj/core/internal/CharactersBaseTest.java +++ b/src/test/java/org/assertj/core/internal/CharactersBaseTest.java @@ -14,7 +14,7 @@ import static org.mockito.Mockito.spy; -import org.assertj.core.util.CaseInsensitiveCharacterComparator; +import org.assertj.core.test.CaseInsensitiveCharacterComparator; import org.junit.jupiter.api.BeforeEach; /** @@ -38,9 +38,9 @@ public void setUp() { failures = spy(new Failures()); characters = new Characters(); characters.failures = failures; - caseInsensitiveComparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveCharacterComparator.instance); + caseInsensitiveComparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveCharacterComparator.INSTANCE); charactersWithCaseInsensitiveComparisonStrategy = new Characters(caseInsensitiveComparisonStrategy); charactersWithCaseInsensitiveComparisonStrategy.failures = failures; } -} \ No newline at end of file +} diff --git a/src/test/java/org/assertj/core/internal/IterableDiff_Test.java b/src/test/java/org/assertj/core/internal/IterableDiff_Test.java index 1ceea1589f..1c041d8c87 100644 --- a/src/test/java/org/assertj/core/internal/IterableDiff_Test.java +++ b/src/test/java/org/assertj/core/internal/IterableDiff_Test.java @@ -101,7 +101,7 @@ void should_report_difference_between_two_different_iterables_with_duplicate_ele @Test void should_not_report_any_differences_between_two_case_sensitive_iterables_according_to_custom_comparison_strategy() { // GIVEN - comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); + comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE); actual = newArrayList("a", "b", "C", "D"); expected = newArrayList("A", "B", "C", "D"); // WHEN diff --git a/src/test/java/org/assertj/core/internal/IterablesBaseTest.java b/src/test/java/org/assertj/core/internal/IterablesBaseTest.java index 32d7b21832..a192fefbd6 100644 --- a/src/test/java/org/assertj/core/internal/IterablesBaseTest.java +++ b/src/test/java/org/assertj/core/internal/IterablesBaseTest.java @@ -50,7 +50,7 @@ public void setUp() { failures = spy(new Failures()); iterables = new Iterables(); iterables.failures = failures; - comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); + comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE); iterablesWithCaseInsensitiveComparisonStrategy = new Iterables(comparisonStrategy); iterablesWithCaseInsensitiveComparisonStrategy.failures = failures; info = someInfo(); diff --git a/src/test/java/org/assertj/core/internal/ListsBaseTest.java b/src/test/java/org/assertj/core/internal/ListsBaseTest.java index ff155046ce..c1df6504dd 100644 --- a/src/test/java/org/assertj/core/internal/ListsBaseTest.java +++ b/src/test/java/org/assertj/core/internal/ListsBaseTest.java @@ -39,7 +39,7 @@ public void setUp() { failures = spy(new Failures()); lists = new Lists(); lists.failures = failures; - comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); + comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE); listsWithCaseInsensitiveComparisonStrategy = new Lists(comparisonStrategy); listsWithCaseInsensitiveComparisonStrategy.failures = failures; } diff --git a/src/test/java/org/assertj/core/internal/StringsBaseTest.java b/src/test/java/org/assertj/core/internal/StringsBaseTest.java index 39773c809a..4dd2676ed0 100644 --- a/src/test/java/org/assertj/core/internal/StringsBaseTest.java +++ b/src/test/java/org/assertj/core/internal/StringsBaseTest.java @@ -43,7 +43,7 @@ public void setUp() { failures = spy(new Failures()); strings = new Strings(); strings.failures = failures; - comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); + comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.INSTANCE); stringsWithCaseInsensitiveComparisonStrategy = new Strings(comparisonStrategy); stringsWithCaseInsensitiveComparisonStrategy.failures = failures; } diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertContainsIgnoringCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertContainsIgnoringCase_Test.java index 74124201ec..eeb0716f16 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertContainsIgnoringCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertContainsIgnoringCase_Test.java @@ -12,22 +12,19 @@ */ package org.assertj.core.internal.strings; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatNullPointerException; +import static org.assertj.core.api.Assertions.catchNullPointerException; +import static org.assertj.core.api.BDDAssertions.then; import static org.assertj.core.error.ShouldContainCharSequence.shouldContainIgnoringCase; import static org.assertj.core.internal.ErrorMessages.charSequenceToLookForIsNull; import static org.assertj.core.test.TestData.someInfo; +import static org.assertj.core.util.AssertionsUtil.expectAssertionError; import static org.assertj.core.util.FailureMessages.actualIsNull; -import org.assertj.core.api.AssertionInfo; -import org.assertj.core.internal.Strings; import org.assertj.core.internal.StringsBaseTest; import org.junit.jupiter.api.Test; - +import org.junitpioneer.jupiter.DefaultLocale; /** - * Tests for {@link Strings#assertContainsIgnoringCase(AssertionInfo, CharSequence, CharSequence)}. - * * @author Alex Ruiz * @author Joel Costigliola */ @@ -35,59 +32,88 @@ class Strings_assertContainsIgnoringCase_Test extends StringsBaseTest { @Test void should_fail_if_actual_does_not_contain_sequence() { - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> strings.assertContainsIgnoringCase(someInfo(), "Yoda", "Luke")) - .withMessage(shouldContainIgnoringCase("Yoda", "Luke").create()); + // WHEN + AssertionError assertionError = expectAssertionError(() -> strings.assertContainsIgnoringCase(someInfo(), "Yoda", "Luke")); + // THEN + then(assertionError).hasMessage(shouldContainIgnoringCase("Yoda", "Luke").create()); } @Test void should_throw_error_if_sequence_is_null() { - assertThatNullPointerException().isThrownBy(() -> strings.assertContainsIgnoringCase(someInfo(), "Yoda", null)) - .withMessage(charSequenceToLookForIsNull()); + // WHEN + NullPointerException exception = catchNullPointerException(() -> strings.assertContainsIgnoringCase(someInfo(), "Yoda", + null)); + // THEN + then(exception).hasMessage(charSequenceToLookForIsNull()); } @Test void should_fail_if_actual_is_null() { - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> strings.assertContainsIgnoringCase(someInfo(), null, "Yoda")) - .withMessage(actualIsNull()); + // WHEN + AssertionError assertionError = expectAssertionError(() -> strings.assertContainsIgnoringCase(someInfo(), null, "Yoda")); + // THEN + then(assertionError).hasMessage(actualIsNull()); } @Test void should_pass_if_actual_contains_sequence() { + // WHEN/THEN strings.assertContainsIgnoringCase(someInfo(), "Yoda", "Yo"); } @Test void should_pass_if_actual_contains_sequence_in_different_case() { + // WHEN/THEN strings.assertContainsIgnoringCase(someInfo(), "Yoda", "yo"); } @Test void should_fail_if_actual_does_not_contain_sequence_whatever_custom_comparison_strategy_is() { - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), "Yoda", "Luke")) - .withMessage(shouldContainIgnoringCase("Yoda", "Luke").create()); + // WHEN + AssertionError assertionError = expectAssertionError(() -> stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), + "Yoda", + "Luke")); + // THEN + then(assertionError).hasMessage(shouldContainIgnoringCase("Yoda", "Luke").create()); } @Test void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { - assertThatNullPointerException().isThrownBy(() -> stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), - "Yoda", - null)) - .withMessage(charSequenceToLookForIsNull()); + // WHEN + NullPointerException exception = catchNullPointerException(() -> stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), + "Yoda", + null)); + // THEN + then(exception).hasMessage(charSequenceToLookForIsNull()); } @Test void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), null, "Yoda")) - .withMessage(actualIsNull()); + // WHEN + AssertionError assertionError = expectAssertionError(() -> stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), + null, + "Yoda")); + // THEN + then(assertionError).hasMessage(actualIsNull()); } @Test void should_pass_if_actual_contains_sequence_whatever_custom_comparison_strategy_is() { + // WHEN/THEN stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), "Yoda", "Yo"); } @Test void should_pass_if_actual_contains_sequence_in_different_case_whatever_custom_comparison_strategy_is() { + // WHEN/THEN stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), "Yoda", "yo"); } + + @Test + @DefaultLocale("tr-TR") + void should_pass_with_Turkish_default_locale() { + // WHEN/THEN + strings.assertContainsIgnoringCase(someInfo(), "Leia", "IA"); + } + } diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotContainIgnoringCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotContainIgnoringCase_Test.java index 37793f0c66..f1361ca2fd 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotContainIgnoringCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotContainIgnoringCase_Test.java @@ -12,39 +12,37 @@ */ package org.assertj.core.internal.strings; -import static org.assertj.core.api.Assertions.catchThrowable; +import static org.assertj.core.api.Assertions.catchNullPointerException; import static org.assertj.core.api.BDDAssertions.then; import static org.assertj.core.api.BDDAssertions.thenIllegalArgumentException; import static org.assertj.core.error.ShouldNotContainCharSequence.shouldNotContainIgnoringCase; import static org.assertj.core.internal.ErrorMessages.arrayOfValuesToLookForIsEmpty; import static org.assertj.core.internal.ErrorMessages.valuesToLookForIsNull; import static org.assertj.core.test.TestData.someInfo; +import static org.assertj.core.util.Arrays.array; import static org.assertj.core.util.AssertionsUtil.expectAssertionError; import static org.assertj.core.util.FailureMessages.actualIsNull; -import static org.mockito.internal.util.collections.Sets.newSet; +import static org.assertj.core.util.Sets.set; -import org.assertj.core.api.AssertionInfo; -import org.assertj.core.internal.Strings; import org.assertj.core.internal.StringsBaseTest; -import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.DefaultLocale; /** - * Tests for {@link Strings#assertDoesNotContainIgnoringCase(AssertionInfo, CharSequence, CharSequence...)}. - * * @author Brummolix */ -@DisplayName("Strings assertDoesNotContainIgnoringCase") class Strings_assertDoesNotContainIgnoringCase_Test extends StringsBaseTest { @Test void should_pass_if_actual_does_not_contain_value_ignoring_case() { - assertDoesNotContainIgnoringCase("Yoda", "no"); + // WHEN/THEN + strings.assertDoesNotContainIgnoringCase(someInfo(), "Yoda", "no"); } @Test void should_pass_if_actual_does_not_contain_values_ignoring_case() { - assertDoesNotContainIgnoringCase("Yoda", "no", "also no"); + // WHEN/THEN + strings.assertDoesNotContainIgnoringCase(someInfo(), "Yoda", "no", "also no"); } @Test @@ -52,7 +50,8 @@ void should_fail_if_actual_contains_value() { // GIVEN String actual = "Yoda"; // WHEN - AssertionError assertionError = expectAssertionError(() -> assertDoesNotContainIgnoringCase(actual, "od")); + AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotContainIgnoringCase(someInfo(), actual, + "od")); // THEN then(assertionError).hasMessage(shouldNotContainIgnoringCase(actual, "od").create()); } @@ -62,7 +61,8 @@ void should_fail_if_actual_contains_value_with_different_case() { // GIVEN String actual = "Yoda"; // WHEN - AssertionError assertionError = expectAssertionError(() -> assertDoesNotContainIgnoringCase(actual, "OD")); + AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotContainIgnoringCase(someInfo(), actual, + "OD")); // THEN then(assertionError).hasMessage(shouldNotContainIgnoringCase(actual, "OD").create()); } @@ -72,10 +72,10 @@ void should_fail_if_actual_contains_one_of_several_values() { // GIVEN String actual = "Yoda"; // WHEN - AssertionError assertionError = expectAssertionError(() -> assertDoesNotContainIgnoringCase(actual, "od", "Yo", "Luke")); + AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotContainIgnoringCase(someInfo(), actual, "od", + "Yo", "Luke")); // THEN - String message = shouldNotContainIgnoringCase(actual, new CharSequence[] { "od", "Yo", "Luke" }, newSet("od", "Yo")).create(); - then(assertionError).hasMessage(message); + then(assertionError).hasMessage(shouldNotContainIgnoringCase(actual, array("od", "Yo", "Luke"), set("od", "Yo")).create()); } @Test @@ -83,10 +83,10 @@ void should_fail_if_actual_contains_one_of_several_values_with_different_case() // GIVEN String actual = "Yoda"; // WHEN - AssertionError assertionError = expectAssertionError(() -> assertDoesNotContainIgnoringCase(actual, "OD", "yo", "Luke")); + AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotContainIgnoringCase(someInfo(), actual, "OD", + "yo", "Luke")); // THEN - String message = shouldNotContainIgnoringCase(actual, new CharSequence[] { "OD", "yo", "Luke" }, newSet("OD", "yo")).create(); - then(assertionError).hasMessage(message); + then(assertionError).hasMessage(shouldNotContainIgnoringCase(actual, array("OD", "yo", "Luke"), set("OD", "yo")).create()); } @Test @@ -94,10 +94,10 @@ void should_fail_if_values_are_null() { // GIVEN CharSequence[] values = null; // WHEN - Throwable npe = catchThrowable(() -> assertDoesNotContainIgnoringCase("Yoda", values)); + NullPointerException exception = catchNullPointerException(() -> strings.assertDoesNotContainIgnoringCase(someInfo(), "Yoda", + values)); // THEN - then(npe).isInstanceOf(NullPointerException.class) - .hasMessage(valuesToLookForIsNull()); + then(exception).hasMessage(valuesToLookForIsNull()); } @Test @@ -105,14 +105,15 @@ void should_fail_if_actual_is_null() { // GIVEN String actual = null; // WHEN - AssertionError assertionError = expectAssertionError(() -> assertDoesNotContainIgnoringCase(actual, "Yoda")); + AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotContainIgnoringCase(someInfo(), actual, + "Yoda")); // THEN then(assertionError).hasMessage(actualIsNull()); } @Test void should_throw_error_if_values_are_empty() { - thenIllegalArgumentException().isThrownBy(() -> assertDoesNotContainIgnoringCase("Yoda")) + thenIllegalArgumentException().isThrownBy(() -> strings.assertDoesNotContainIgnoringCase(someInfo(), "Yoda")) .withMessage(arrayOfValuesToLookForIsEmpty()); } @@ -121,13 +122,19 @@ void should_throw_error_if_values_contains_null() { // GIVEN CharSequence[] values = new CharSequence[] { "1", null }; // WHEN - Throwable npe = catchThrowable(() -> assertDoesNotContainIgnoringCase("Yoda", values)); + NullPointerException exception = catchNullPointerException(() -> strings.assertDoesNotContainIgnoringCase(someInfo(), "Yoda", + values)); // THEN - then(npe).isInstanceOf(NullPointerException.class) - .hasMessage("Expecting CharSequence elements not to be null but found one at index 1"); + then(exception).hasMessage("Expecting CharSequence elements not to be null but found one at index 1"); } - private void assertDoesNotContainIgnoringCase(CharSequence actual, CharSequence... values) { - strings.assertDoesNotContainIgnoringCase(someInfo(), actual, values); + @Test + @DefaultLocale("tr-TR") + void should_fail_with_Turkish_default_locale() { + // WHEN + AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotContainIgnoringCase(INFO, "Leia", "EI")); + // THEN + then(assertionError).hasMessage(shouldNotContainIgnoringCase("Leia", "EI").create()); } + } diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotEndWithIgnoringCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotEndWithIgnoringCase_Test.java index 6c5961e7dd..216742b7ab 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotEndWithIgnoringCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotEndWithIgnoringCase_Test.java @@ -18,7 +18,6 @@ import static org.assertj.core.util.AssertionsUtil.expectAssertionError; import static org.assertj.core.util.FailureMessages.actualIsNull; -import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; import org.assertj.core.internal.ComparisonStrategy; import org.assertj.core.internal.StandardComparisonStrategy; @@ -26,11 +25,9 @@ import org.assertj.core.internal.StringsBaseTest; import org.assertj.core.util.StringHashCodeTestComparator; import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.DefaultLocale; -/** - * Tests for {@link Strings#assertDoesNotEndWithIgnoringCase(AssertionInfo, CharSequence, CharSequence)}. - */ -class Strings_assertDoesNotEndWithIgnoringCaseIgnoringCase_Test extends StringsBaseTest { +class Strings_assertDoesNotEndWithIgnoringCase_Test extends StringsBaseTest { @Test void should_pass_if_actual_does_not_end_with_suffix() { @@ -78,4 +75,14 @@ void should_fail_if_actual_ends_with_suffix_according_to_custom_comparison_strat // THEN then(assertionError).hasMessage(shouldNotEndWithIgnoringCase("Yoda", "A", hashCodeComparisonStrategy).create()); } + + @Test + @DefaultLocale("tr-TR") + void should_fail_with_Turkish_default_locale() { + // WHEN + AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotEndWithIgnoringCase(INFO, "Leia", "IA")); + // THEN + then(assertionError).hasMessage(shouldNotEndWithIgnoringCase("Leia", "IA", StandardComparisonStrategy.instance()).create()); + } + } diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotStartWithIgnoringCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotStartWithIgnoringCase_Test.java index 70d6ac2b72..a18bc90bd6 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotStartWithIgnoringCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertDoesNotStartWithIgnoringCase_Test.java @@ -18,7 +18,6 @@ import static org.assertj.core.util.AssertionsUtil.expectAssertionError; import static org.assertj.core.util.FailureMessages.actualIsNull; -import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; import org.assertj.core.internal.ComparisonStrategy; import org.assertj.core.internal.StandardComparisonStrategy; @@ -26,10 +25,8 @@ import org.assertj.core.internal.StringsBaseTest; import org.assertj.core.util.StringHashCodeTestComparator; import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.DefaultLocale; -/** - * Tests for {@link Strings#assertDoesNotStartWithIgnoringCase(AssertionInfo, CharSequence, CharSequence)}. - */ class Strings_assertDoesNotStartWithIgnoringCase_Test extends StringsBaseTest { @Test @@ -42,7 +39,7 @@ void should_pass_if_actual_does_not_start_with_prefix() { void should_fail_if_actual_starts_with_prefix() { // WHEN AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotStartWithIgnoringCase(INFO, "Yoda", "yo")); - //THEN + // THEN then(assertionError).hasMessage(shouldNotStartWithIgnoringCase("Yoda", "yo", StandardComparisonStrategy.instance()).create()); } @@ -76,6 +73,17 @@ void should_fail_if_actual_starts_with_prefix_according_to_custom_comparison_str // WHEN AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotStartWithIgnoringCase(INFO, "Yoda", "yODA")); // THEN - then(assertionError).hasMessageContainingAll(shouldNotStartWithIgnoringCase("Yoda", "yODA", hashCodeComparisonStrategy).create()); + then(assertionError).hasMessageContainingAll(shouldNotStartWithIgnoringCase("Yoda", "yODA", + hashCodeComparisonStrategy).create()); + } + + @Test + @DefaultLocale("tr-TR") + void should_fail_with_Turkish_default_locale() { + // WHEN + AssertionError assertionError = expectAssertionError(() -> strings.assertDoesNotStartWithIgnoringCase(INFO, "Leia", "LEI")); + // THEN + then(assertionError).hasMessage(shouldNotStartWithIgnoringCase("Leia", "LEI", StandardComparisonStrategy.instance()).create()); } + } diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertEndsWithIgnoringCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertEndsWithIgnoringCase_Test.java index 169cb990bb..58a1b920d9 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertEndsWithIgnoringCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertEndsWithIgnoringCase_Test.java @@ -15,10 +15,10 @@ import static org.assertj.core.api.Assertions.assertThatNullPointerException; import static org.assertj.core.api.BDDAssertions.then; import static org.assertj.core.error.ShouldEndWithIgnoringCase.shouldEndWithIgnoringCase; +import static org.assertj.core.test.TestData.someInfo; import static org.assertj.core.util.AssertionsUtil.expectAssertionError; import static org.assertj.core.util.FailureMessages.actualIsNull; -import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; import org.assertj.core.internal.ComparisonStrategy; import org.assertj.core.internal.StandardComparisonStrategy; @@ -26,10 +26,8 @@ import org.assertj.core.internal.StringsBaseTest; import org.assertj.core.util.StringHashCodeTestComparator; import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.DefaultLocale; -/** - * Tests for {@link Strings#assertEndsWithIgnoringCase(AssertionInfo, CharSequence, CharSequence)}. - */ class Strings_assertEndsWithIgnoringCase_Test extends StringsBaseTest { @Test @@ -84,4 +82,12 @@ void should_fail_if_actual_does_not_end_with_suffix_according_to_custom_comparis // THEN then(assertionError).hasMessage(shouldEndWithIgnoringCase("Yoda", "Luke", hashCodeComparisonStrategy).create()); } + + @Test + @DefaultLocale("tr-TR") + void should_pass_with_Turkish_default_locale() { + // WHEN/THEN + strings.assertEndsWithIgnoringCase(someInfo(), "Leia", "IA"); + } + } diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertEqualsIgnoringCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertEqualsIgnoringCase_Test.java index dd5def5e9d..80f87dc5e6 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertEqualsIgnoringCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertEqualsIgnoringCase_Test.java @@ -17,15 +17,11 @@ import static org.assertj.core.test.CharArrays.arrayOf; import static org.assertj.core.test.TestData.someInfo; -import org.assertj.core.api.AssertionInfo; -import org.assertj.core.internal.Strings; import org.assertj.core.internal.StringsBaseTest; import org.junit.jupiter.api.Test; - +import org.junitpioneer.jupiter.DefaultLocale; /** - * Tests for {@link Strings#assertEqualsIgnoringCase(AssertionInfo, CharSequence, CharSequence)}. - * * @author Alex Ruiz * @author Joel Costigliola */ @@ -103,4 +99,12 @@ void should_pass_if_both_Strings_are_equal_but_not_same_whatever_custom_comparis void should_pass_if_both_Strings_are_equal_ignoring_case_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertEqualsIgnoringCase(someInfo(), "Yoda", "YODA"); } + + @Test + @DefaultLocale("tr-TR") + void should_pass_with_Turkish_default_locale() { + // WHEN/THEN + strings.assertEqualsIgnoringCase(someInfo(), "Leia", "LEIA"); + } + } diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertNotEqualsIgnoringCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertNotEqualsIgnoringCase_Test.java index 8aa6ff735f..4cc65be840 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertNotEqualsIgnoringCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertNotEqualsIgnoringCase_Test.java @@ -15,20 +15,19 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.catchThrowable; +import static org.assertj.core.api.BDDAssertions.then; import static org.assertj.core.error.ShouldNotBeEqualIgnoringCase.shouldNotBeEqualIgnoringCase; import static org.assertj.core.test.CharArrays.arrayOf; import static org.assertj.core.test.TestData.someInfo; +import static org.assertj.core.util.AssertionsUtil.expectAssertionError; import static org.mockito.Mockito.verify; import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.StringsBaseTest; import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.DefaultLocale; /** - * Tests for - * {@link org.assertj.core.internal.Strings#assertNotEqualsIgnoringCase(org.assertj.core.api.AssertionInfo, CharSequence, CharSequence)} - * . - * * @author Alexander Bischof */ class Strings_assertNotEqualsIgnoringCase_Test extends StringsBaseTest { @@ -127,4 +126,14 @@ void should_fail_if_both_Strings_are_equal_ignoring_case_whatever_custom_compari assertThat(error).isInstanceOf(AssertionError.class); verifyFailureThrownWhenStringsAreNotEqual(info, "Yoda", "YODA"); } + + @Test + @DefaultLocale("tr-TR") + void should_fail_with_Turkish_default_locale() { + // WHEN + AssertionError assertionError = expectAssertionError(() -> strings.assertNotEqualsIgnoringCase(INFO, "Leia", "LEIA")); + // THEN + then(assertionError).hasMessage(shouldNotBeEqualIgnoringCase("Leia", "LEIA").create()); + } + } diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertStartsWithIgnoringCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertStartsWithIgnoringCase_Test.java index cbe1fd2fa3..25e4b4d96a 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertStartsWithIgnoringCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertStartsWithIgnoringCase_Test.java @@ -18,7 +18,6 @@ import static org.assertj.core.util.AssertionsUtil.expectAssertionError; import static org.assertj.core.util.FailureMessages.actualIsNull; -import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; import org.assertj.core.internal.ComparisonStrategy; import org.assertj.core.internal.StandardComparisonStrategy; @@ -26,10 +25,8 @@ import org.assertj.core.internal.StringsBaseTest; import org.assertj.core.util.StringHashCodeTestComparator; import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.DefaultLocale; -/** - * Tests for {@link Strings#assertStartsWithIgnoringCase(AssertionInfo, CharSequence, CharSequence)}. - */ class Strings_assertStartsWithIgnoringCase_Test extends StringsBaseTest { @Test @@ -82,4 +79,12 @@ void should_fail_if_actual_does_not_start_with_prefix_according_to_custom_compar // THEN then(assertionError).hasMessage(shouldStartWithIgnoringCase("Yoda", "Luke", hashCodeComparisonStrategy).create()); } + + @Test + @DefaultLocale("tr-TR") + void should_pass_with_Turkish_default_locale() { + // WHEN/THEN + strings.assertStartsWithIgnoringCase(INFO, "Leia", "LEI"); + } + } diff --git a/src/test/java/org/assertj/core/osgi/AssumptionsTest.java b/src/test/java/org/assertj/core/osgi/AssumptionsTest.java index 032fc1b48a..4eefdeea77 100644 --- a/src/test/java/org/assertj/core/osgi/AssumptionsTest.java +++ b/src/test/java/org/assertj/core/osgi/AssumptionsTest.java @@ -20,11 +20,11 @@ import org.assertj.core.api.Assumptions; import org.assertj.core.configuration.PreferredAssumptionException; +import org.assertj.core.test.MutatesGlobalConfiguration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.Isolated; import org.opentest4j.TestAbortedException; -@Isolated // Isolated as the preferred assumption class is mutated globally here. +@MutatesGlobalConfiguration class AssumptionsTest { @Test diff --git a/src/test/java/org/assertj/core/presentation/StandardRepresentation_throwable_format_Test.java b/src/test/java/org/assertj/core/presentation/StandardRepresentation_throwable_format_Test.java index fed27510dd..c508135a67 100644 --- a/src/test/java/org/assertj/core/presentation/StandardRepresentation_throwable_format_Test.java +++ b/src/test/java/org/assertj/core/presentation/StandardRepresentation_throwable_format_Test.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.when; import org.assertj.core.configuration.Configuration; -import org.junit.jupiter.api.AfterEach; +import org.assertj.core.test.MutatesGlobalConfiguration; import org.junit.jupiter.api.Test; /** @@ -28,6 +28,7 @@ * * @author XiaoMingZHM Eveneko */ +@MutatesGlobalConfiguration class StandardRepresentation_throwable_format_Test { private static final Representation REPRESENTATION = new StandardRepresentation(); @@ -46,12 +47,6 @@ static void boom() { } } - @AfterEach - void afterEach() { - // Restore default configuration after each test - DEFAULT_CONFIGURATION.apply(); - } - @Test void should_not_display_stacktrace_if_maxStackTraceElementsDisplayed_is_zero() { // GIVEN diff --git a/src/test/java/org/assertj/core/util/CaseInsensitiveCharSequenceComparator.java b/src/test/java/org/assertj/core/test/CaseInsensitiveCharSequenceComparator.java similarity index 76% rename from src/test/java/org/assertj/core/util/CaseInsensitiveCharSequenceComparator.java rename to src/test/java/org/assertj/core/test/CaseInsensitiveCharSequenceComparator.java index f822bf85de..3ff95b608a 100644 --- a/src/test/java/org/assertj/core/util/CaseInsensitiveCharSequenceComparator.java +++ b/src/test/java/org/assertj/core/test/CaseInsensitiveCharSequenceComparator.java @@ -10,22 +10,20 @@ * * Copyright 2012-2022 the original author or authors. */ -package org.assertj.core.util; +package org.assertj.core.test; import java.util.Comparator; -import org.assertj.core.test.CaseInsensitiveStringComparator; - /** * @author Mikhail Mazursky */ public class CaseInsensitiveCharSequenceComparator implements Comparator { - public final static CaseInsensitiveCharSequenceComparator instance = new CaseInsensitiveCharSequenceComparator(); + public static final CaseInsensitiveCharSequenceComparator INSTANCE = new CaseInsensitiveCharSequenceComparator(); @Override public int compare(CharSequence s1, CharSequence s2) { - - return CaseInsensitiveStringComparator.instance.compare(s1.toString(), s2.toString()); + return CaseInsensitiveStringComparator.INSTANCE.compare(s1.toString(), s2.toString()); } + } diff --git a/src/test/java/org/assertj/core/util/CaseInsensitiveCharacterComparator.java b/src/test/java/org/assertj/core/test/CaseInsensitiveCharacterComparator.java similarity index 75% rename from src/test/java/org/assertj/core/util/CaseInsensitiveCharacterComparator.java rename to src/test/java/org/assertj/core/test/CaseInsensitiveCharacterComparator.java index ad199273bf..f0429e42b6 100644 --- a/src/test/java/org/assertj/core/util/CaseInsensitiveCharacterComparator.java +++ b/src/test/java/org/assertj/core/test/CaseInsensitiveCharacterComparator.java @@ -10,16 +10,19 @@ * * Copyright 2012-2022 the original author or authors. */ -package org.assertj.core.util; +package org.assertj.core.test; + +import static java.lang.Character.toLowerCase; import java.util.Comparator; public class CaseInsensitiveCharacterComparator implements Comparator { - public final static CaseInsensitiveCharacterComparator instance = new CaseInsensitiveCharacterComparator(); + public static final CaseInsensitiveCharacterComparator INSTANCE = new CaseInsensitiveCharacterComparator(); @Override public int compare(Character c1, Character c2) { - return c1.toString().toLowerCase().compareTo(c2.toString().toLowerCase()); + return Character.compare(toLowerCase(c1), toLowerCase(c2)); } -} \ No newline at end of file + +} diff --git a/src/test/java/org/assertj/core/test/CaseInsensitiveCharacterComparatorTest.java b/src/test/java/org/assertj/core/test/CaseInsensitiveCharacterComparatorTest.java new file mode 100644 index 0000000000..29fac2e67a --- /dev/null +++ b/src/test/java/org/assertj/core/test/CaseInsensitiveCharacterComparatorTest.java @@ -0,0 +1,33 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright 2012-2022 the original author or authors. + */ +package org.assertj.core.test; + +import static org.assertj.core.api.BDDAssertions.then; + +import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.DefaultLocale; + +class CaseInsensitiveCharacterComparatorTest { + + private final CaseInsensitiveCharacterComparator underTest = new CaseInsensitiveCharacterComparator(); + + @Test + @DefaultLocale("tr-TR") + void should_work_with_Turkish_default_locale() { + // WHEN + int result = underTest.compare('i', 'I'); + // THEN + then(result).isZero(); + } + +} diff --git a/src/test/java/org/assertj/core/test/CaseInsensitiveStringComparator.java b/src/test/java/org/assertj/core/test/CaseInsensitiveStringComparator.java index 68ec8f7ba4..bb1c59cad8 100644 --- a/src/test/java/org/assertj/core/test/CaseInsensitiveStringComparator.java +++ b/src/test/java/org/assertj/core/test/CaseInsensitiveStringComparator.java @@ -16,7 +16,7 @@ public class CaseInsensitiveStringComparator implements Comparator { - public final static CaseInsensitiveStringComparator instance = new CaseInsensitiveStringComparator(); + public static final CaseInsensitiveStringComparator INSTANCE = new CaseInsensitiveStringComparator(); @Override public int compare(String s1, String s2) { diff --git a/src/test/java/org/assertj/core/test/CaseInsensitiveStringComparatorTest.java b/src/test/java/org/assertj/core/test/CaseInsensitiveStringComparatorTest.java index dec73d2e89..155a4439f5 100644 --- a/src/test/java/org/assertj/core/test/CaseInsensitiveStringComparatorTest.java +++ b/src/test/java/org/assertj/core/test/CaseInsensitiveStringComparatorTest.java @@ -23,7 +23,7 @@ class CaseInsensitiveStringComparatorTest { @Test @DefaultLocale("tr-TR") - void should_work_with_turkish_locale() { + void should_work_with_Turkish_default_locale() { // WHEN int result = underTest.compare("i", "I"); // THEN diff --git a/src/test/java/org/assertj/core/test/MutatesGlobalConfiguration.java b/src/test/java/org/assertj/core/test/MutatesGlobalConfiguration.java new file mode 100644 index 0000000000..4b008ec767 --- /dev/null +++ b/src/test/java/org/assertj/core/test/MutatesGlobalConfiguration.java @@ -0,0 +1,54 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright 2012-2022 the original author or authors. + */ +package org.assertj.core.test; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import org.assertj.core.configuration.ConfigurationProvider; +import org.assertj.core.test.MutatesGlobalConfiguration.AssumptionMutatingExtension; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.parallel.Isolated; + +/** + * An annotation for any test class that mutates the global configuration. + * + *

By using this annotation, any tests that mutate this configuration will have the configuration + * reset to the default values after each test case runs. + * + * @author Ashley Scopes + */ +@ExtendWith(AssumptionMutatingExtension.class) +@Isolated("Mutates global state") +@Target(ElementType.TYPE) +public @interface MutatesGlobalConfiguration { + + final class AssumptionMutatingExtension implements AfterEachCallback, AfterAllCallback { + + @Override + public void afterEach(ExtensionContext context) { + resetAll(); + } + + @Override + public void afterAll(ExtensionContext context) { + resetAll(); + } + + private void resetAll() { + ConfigurationProvider.CONFIGURATION_PROVIDER.configuration().setDefaults(); + } + } +}