diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..6659c4c689 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [joel-costigliola, scordio] diff --git a/.github/workflows/binary-compatibility.yml b/.github/workflows/binary-compatibility.yml index ee7a01bf08..f9dafea80f 100644 --- a/.github/workflows/binary-compatibility.yml +++ b/.github/workflows/binary-compatibility.yml @@ -8,6 +8,9 @@ on: paths: - 'assertj-core/**' +env: + MAVEN_ARGS: -B -V -ntp -e -Djansi.passthrough=true -Dstyle.color=always -DskipTests + jobs: verify-with-base: name: Verify with target branch @@ -15,71 +18,31 @@ jobs: if: github.base_ref != null steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: '21' cache: 'maven' - name: Checkout `${{ github.base_ref }}` into subfolder - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.base_ref }} path: ${{ github.run_id }}.${{ github.base_ref }} - name: Build `${{ github.base_ref }}` - run: > - ./mvnw -B -V --no-transfer-progress -e -f ${{ github.run_id }}.${{ github.base_ref }}/assertj-core/pom.xml package - -DskipTests - -Djansi.passthrough=true - -Dstyle.color=always + run: ./mvnw $MAVEN_ARGS -f ${{ github.run_id }}.${{ github.base_ref }}/assertj-core/pom.xml package - name: Compare `${{ github.head_ref }}` with `${{ github.base_ref }}` run: > - ./mvnw -B -V --no-transfer-progress -e -f assertj-core/pom.xml -Pjapicmp-branch package japicmp:cmp - -DskipTests + ./mvnw $MAVEN_ARGS -f assertj-core/pom.xml -Pjapicmp-branch package japicmp:cmp -Djapicmp.breakBuildOnBinaryIncompatibleModifications=true -Djapicmp.oldVersion.basedir=${{ github.run_id }}.${{ github.base_ref }}/assertj-core - -Djansi.passthrough=true - -Dstyle.color=always - - - name: Add label - if: failure() - uses: actions/github-script@v6 - continue-on-error: true - with: - script: | - github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - labels: ['binary incompatible with: base'] - }) - - - name: Remove label - if: success() - uses: actions/github-script@v6 - continue-on-error: true - with: - script: | - github.rest.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - name: 'binary incompatible with: base' - }) - name: Add result to job summary if: success() || failure() run: | echo '```' >> $GITHUB_STEP_SUMMARY cat assertj-core/target/japicmp/default-cli.diff >> $GITHUB_STEP_SUMMARY - - name: Upload reports - if: success() || failure() - uses: actions/upload-artifact@v3 - with: - name: japicmp - path: assertj-core/target/japicmp - if-no-files-found: error verify-with-release: @@ -87,44 +50,17 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: '21' cache: 'maven' - name: Compare with the latest release run: > - ./mvnw -B -V --no-transfer-progress -e -f assertj-core/pom.xml package japicmp:cmp - -DskipTests + ./mvnw $MAVEN_ARGS -f assertj-core/pom.xml package japicmp:cmp -Djapicmp.breakBuildOnBinaryIncompatibleModifications=true - -Djansi.passthrough=true - -Dstyle.color=always - - - name: Add label - if: github.base_ref != null && failure() - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - labels: ['binary incompatible with: release'] - }) - - name: Remove label - if: github.base_ref != null && success() - uses: actions/github-script@v6 - continue-on-error: true - with: - script: | - github.rest.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - name: 'binary incompatible with: release' - }) - name: Add result to job summary if: success() || failure() @@ -133,7 +69,7 @@ jobs: cat assertj-core/target/japicmp/default-cli.diff >> $GITHUB_STEP_SUMMARY - name: Upload reports if: success() || failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: japicmp path: assertj-core/target/japicmp diff --git a/.github/workflows/cross-version.yml b/.github/workflows/cross-version.yml index 326a2d9610..b554210dfc 100644 --- a/.github/workflows/cross-version.yml +++ b/.github/workflows/cross-version.yml @@ -2,6 +2,9 @@ name: Cross-Version on: [push, pull_request] +env: + MAVEN_ARGS: -B -V -ntp -e -Djansi.passthrough=true -Dstyle.color=always -Djacoco.skip=true + jobs: test_java: @@ -9,10 +12,10 @@ jobs: strategy: fail-fast: false matrix: - java: [19, 20, 21] + java: [22, 23] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Java uses: oracle-actions/setup-java@v1 with: @@ -20,8 +23,4 @@ jobs: release: ${{ matrix.java }} version: latest - name: Test - run: > - ./mvnw -B -V --no-transfer-progress -e verify javadoc:javadoc - -Djacoco.skip=true - -Djansi.passthrough=true - -Dstyle.color=always + run: ./mvnw $MAVEN_ARGS verify diff --git a/.github/workflows/dependency-graph.yml b/.github/workflows/dependency-graph.yml new file mode 100644 index 0000000000..9e3dbde2f8 --- /dev/null +++ b/.github/workflows/dependency-graph.yml @@ -0,0 +1,24 @@ +name: Dependency Graph + +on: + push: + branches: + - main + +jobs: + + dependency_graph: + + name: Update + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '21' + cache: 'maven' + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@v3 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 89a6a7414d..4629c88558 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,72 +2,69 @@ name: CI on: [push, pull_request] +env: + MAVEN_ARGS: -B -V -ntp -e -Djansi.passthrough=true -Dstyle.color=always + jobs: test_os: + name: OS ${{ matrix.os }} - permissions: - # Needed for test reporting - checks: write - pull-requests: write strategy: fail-fast: false matrix: - include: - - os: ubuntu-latest - comment-test-results: true - - os: macOS-latest - comment-test-results: false - - os: windows-latest - comment-test-results: false + os: [ubuntu-latest, macOS-latest, windows-latest] runs-on: ${{ matrix.os }} + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: '21' cache: 'maven' - name: Test - # 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 - '-Djansi.passthrough=true' - '-Dstyle.color=always' + run: ./mvnw $MAVEN_ARGS verify + + javadoc: - - name: Publish unit test results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: ${{ matrix.comment-test-results }} - continue-on-error: true + name: Javadoc + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Java + uses: actions/setup-java@v4 with: - check_name: "JUnit test results" - junit_files: "assertj*/**/target/surefire-reports/TEST-*.xml" + distribution: 'zulu' + java-version: '21' + cache: 'maven' + - name: Generate Javadoc + run: ./mvnw $MAVEN_ARGS -DskipTests package javadoc:javadoc sonar: + name: Sonar code analysis runs-on: ubuntu-latest if: github.repository == 'assertj/assertj' && github.event_name == 'push' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: '21' cache: 'maven' - name: Test with Sonar run: > - ./mvnw -B -V --no-transfer-progress -e verify javadoc:javadoc sonar:sonar + ./mvnw $MAVEN_ARGS verify 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 f71e6348a6..d28791cc01 100644 --- a/.github/workflows/pitest-receive-pr.yml +++ b/.github/workflows/pitest-receive-pr.yml @@ -15,6 +15,9 @@ name: Receive on: pull_request: +env: + MAVEN_ARGS: -B -V -ntp -e -Djansi.passthrough=true -Dstyle.color=always + jobs: store-pitest-feedback: # Only run on forked repos. @@ -23,32 +26,28 @@ jobs: steps: - name: Checkout project - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # important to set a fetch depth of 2. By default the checkout action make no history available fetch-depth: 2 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: '21' cache: 'maven' - name: run pitest # 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 -B -e -Ppitest -Dfeatures="+GIT(from[HEAD~1]), +gitci" test - -Djansi.passthrough=true - -Dstyle.color=always + ./mvnw $MAVEN_ARGS -Ppitest -Dfeatures="+GIT(from[HEAD~1]), +gitci" test - name: aggregate files run: > - mvn -B -e -f assertj-core/pom.xml -Ppitest pitest-git:aggregate - -Djansi.passthrough=true - -Dstyle.color=always + ./mvnw $MAVEN_ARGS -f assertj-core/pom.xml -Ppitest pitest-git:aggregate - name: upload results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pitest path: target/assertj-core/pit-reports-ci/ diff --git a/.github/workflows/pitest-updated-pr.yml b/.github/workflows/pitest-updated-pr.yml index 81361b5266..97dbe41169 100644 --- a/.github/workflows/pitest-updated-pr.yml +++ b/.github/workflows/pitest-updated-pr.yml @@ -19,6 +19,9 @@ on: types: - completed +env: + MAVEN_ARGS: -B -V -ntp -e -Djansi.passthrough=true -Dstyle.color=always + jobs: pitest-update-pr: if: ${{ github.event.workflow_run.conclusion == 'success' }} @@ -27,12 +30,12 @@ jobs: - name: debug uses: hmarr/debug-action@v2 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: '21' - name: Download artifact - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: workflow: ${{ github.event.workflow_run.workflow_id }} name: pitest @@ -43,6 +46,4 @@ jobs: # 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 -B -DrepoToken=${{ secrets.GITHUB_TOKEN }} com.groupcdg:pitest-github-maven-plugin:1.0.3:updatePR - -Djansi.passthrough=true - -Dstyle.color=always + ./mvnw $MAVEN_ARGS -DrepoToken=${{ secrets.GITHUB_TOKEN }} com.groupcdg:pitest-github-maven-plugin:1.1.1:updatePR diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml new file mode 100644 index 0000000000..912478efc2 --- /dev/null +++ b/.github/workflows/qodana.yml @@ -0,0 +1,21 @@ +name: Qodana + +on: [push, pull_request, workflow_dispatch] + +jobs: + qodana: + name: Scan + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + checks: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit + fetch-depth: 0 # a full history is required for pull request analysis + - name: 'Qodana Scan' + uses: JetBrains/qodana-action@v2023.3 + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e90afd4b5..4cd8bbab21 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,9 @@ name: Release on: workflow_dispatch: +env: + MAVEN_ARGS: -B -V -ntp -e -Djansi.passthrough=true -Dstyle.color=always -Djacoco.skip=true + jobs: release: @@ -10,12 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Maven Central - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: '21' server-id: ossrh server-username: OSSRH_USERNAME server-password: OSSRH_TOKEN @@ -25,9 +28,7 @@ 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 }} \ - -Djansi.passthrough=true \ - -Dstyle.color=always + ./mvnw $MAVEN_ARGS release:prepare release:perform -Dpassword=${{ secrets.GITHUB_TOKEN }} env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 0000000000..afdcfab795 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,2 @@ +-Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5 +-Daether.connector.smartChecksums=false diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index 732313c431..84d1e60d8d 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -23,85 +23,50 @@ import java.net.PasswordAuthentication; import java.net.URL; import java.nio.file.Files; -import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; -import java.nio.file.StandardOpenOption; -import java.util.Properties; public final class MavenWrapperDownloader { - private static final String WRAPPER_VERSION = "3.1.1"; + private static final String WRAPPER_VERSION = "3.2.0"; private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) ); - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = - "https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/" + WRAPPER_VERSION - + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use instead of the - * default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - public static void main( String[] args ) { - if ( args.length == 0 ) - { - System.err.println( " - ERROR projectBasedir parameter missing" ); - System.exit( 1 ); - } + log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION ); - log( " - Downloader started" ); - final String dir = args[0].replace( "..", "" ); // Sanitize path - final Path projectBasedir = Paths.get( dir ).toAbsolutePath().normalize(); - if ( !Files.isDirectory( projectBasedir, LinkOption.NOFOLLOW_LINKS ) ) + if ( args.length != 2 ) { - System.err.println( " - ERROR projectBasedir not exists: " + projectBasedir ); + System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" ); System.exit( 1 ); } - log( " - Using base directory: " + projectBasedir ); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - Path mavenWrapperPropertyFile = projectBasedir.resolve( MAVEN_WRAPPER_PROPERTIES_PATH ); - String url = readWrapperUrl( mavenWrapperPropertyFile ); - try { - Path outputFile = projectBasedir.resolve( MAVEN_WRAPPER_JAR_PATH ); - createDirectories( outputFile.getParent() ); - downloadFileFromURL( url, outputFile ); + log( " - Downloader started" ); + final URL wrapperUrl = new URL( args[0] ); + final String jarPath = args[1].replace( "..", "" ); // Sanitize path + final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize(); + downloadFileFromURL( wrapperUrl, wrapperJarPath ); log( "Done" ); - System.exit( 0 ); } catch ( IOException e ) { - System.err.println( "- Error downloading" ); - e.printStackTrace(); + System.err.println( "- Error downloading: " + e.getMessage() ); + if ( VERBOSE ) + { + e.printStackTrace(); + } System.exit( 1 ); } } - private static void downloadFileFromURL( String urlString, Path destination ) throws IOException + private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath ) + throws IOException { - log( " - Downloading to: " + destination ); + log( " - Downloading to: " + wrapperJarPath ); if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null ) { final String username = System.getenv( "MVNW_USERNAME" ); @@ -115,40 +80,11 @@ protected PasswordAuthentication getPasswordAuthentication() } } ); } - URL website = new URL( urlString ); - try ( InputStream inStream = website.openStream() ) { - Files.copy( inStream, destination, StandardCopyOption.REPLACE_EXISTING ); - } - log( " - Downloader complete" ); - } - - private static void createDirectories(Path outputPath) throws IOException - { - if ( !Files.isDirectory( outputPath, LinkOption.NOFOLLOW_LINKS ) ) { - Path createDirectories = Files.createDirectories( outputPath ); - log( " - Directories created: " + createDirectories ); - } - } - - private static String readWrapperUrl( Path mavenWrapperPropertyFile ) - { - String url = DEFAULT_DOWNLOAD_URL; - if ( Files.exists( mavenWrapperPropertyFile, LinkOption.NOFOLLOW_LINKS ) ) + try ( InputStream inStream = wrapperUrl.openStream() ) { - log( " - Reading property file: " + mavenWrapperPropertyFile ); - try ( InputStream in = Files.newInputStream( mavenWrapperPropertyFile, StandardOpenOption.READ ) ) - { - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load( in ); - url = mavenWrapperProperties.getProperty( PROPERTY_NAME_WRAPPER_URL, DEFAULT_DOWNLOAD_URL ); - } - catch ( IOException e ) - { - System.err.println( " - ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" ); - } + Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING ); } - log( " - Downloading from: " + url ); - return url; + log( " - Downloader complete" ); } private static void log( String msg ) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index ca5ab4bab1..346d645fd0 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -6,7 +6,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# 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 @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c861cca09b..b6165dd90b 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,45 +2,132 @@ ## Our Pledge -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. ## Our Standards -Examples of behavior that contributes to creating a positive environment include: +Examples of behavior that contributes to a positive environment for our +community include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community -Examples of unacceptable behavior by participants include: +Examples of unacceptable behavior include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting -## Our Responsibilities +## Enforcement Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. ## Scope -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at joel.costigliola@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +joel.costigliola@gmail.com and stefano.cordio@gmail.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/README.md b/README.md index 36676ae3f9..421998c9c7 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ AssertJ provides a rich and intuitive set of strongly-typed assertions to use fo * [AssertJ's goals](#goals) * [Quick start](https://assertj.github.io/doc/#assertj-core-quick-start) -* [Latest releases](https://assertj.github.io/doc/#assertj-core-release-notes) * [Documentation](https://assertj.github.io/doc/#assertj-core) * [Contributing](#contributing) @@ -29,8 +28,8 @@ Assertion missing? Please [create an issue](https://github.com/assertj/assertj/i AssertJ is composed of several modules: -* A core module (this one) to provide assertions for JDK types (`String`, `Iterable`, `Stream`, `Path`, `File`, `Map`...) - see [AssertJ Core documentation](https://assertj.github.io/doc/#assertj-core-assertions-guide) and [javadoc](https://www.javadoc.io/doc/org.assertj/assertj-core/latest/index.html). -* A **[Guava module](https://github.com/assertj/assertj-guava#readme)** to provide assertions for Guava types (`Multimap`, `Optional`...) - see [AssertJ Guava documentation](https://assertj.github.io/doc/#assertj-guava) and [javadoc](https://www.javadoc.io/doc/org.assertj/assertj-guava/latest/index.html). +* A **core module** to provide assertions for JDK types (`String`, `Iterable`, `Stream`, `Path`, `File`, `Map`...) - see [AssertJ Core documentation](https://assertj.github.io/doc/#assertj-core-assertions-guide) and [javadoc](https://www.javadoc.io/doc/org.assertj/assertj-core/latest/index.html). +* A **Guava module** to provide assertions for Guava types (`Multimap`, `Optional`...) - see [AssertJ Guava documentation](https://assertj.github.io/doc/#assertj-guava) and [javadoc](https://www.javadoc.io/doc/org.assertj/assertj-guava/latest/index.html). * A **[Joda Time module](https://github.com/assertj/assertj-joda-time#readme)** to provide assertions for Joda Time types (`DateTime`, `LocalDateTime`) - see [AssertJ Joda Time documentation](http://joel-costigliola.github.io/assertj/assertj-joda-time.html) and [javadoc](https://www.javadoc.io/doc/org.assertj/assertj-joda-time/latest/index.html). * A **[Neo4J module](https://github.com/assertj/assertj-neo4j#readme)** to provide assertions for Neo4J types (`Path`, `Node`, `Relationship`...) - see [AssertJ Neo4J documentation](http://joel-costigliola.github.io/assertj/assertj-neo4j.html) and [javadoc](https://www.javadoc.io/doc/org.assertj/assertj-neo4j/latest/index.html). * A **[DB module](https://github.com/assertj/assertj-db#readme)** to provide assertions for relational database types (`Table`, `Row`, `Column`...) - see [AssertJ DB documentation](https://assertj.github.io/doc/#assertj-db) and [javadoc](https://www.javadoc.io/doc/org.assertj/assertj-db/latest/index.html). diff --git a/assertj-bom/pom.xml b/assertj-bom/pom.xml index cf8c9af18c..5ce94c37b7 100644 --- a/assertj-bom/pom.xml +++ b/assertj-bom/pom.xml @@ -5,7 +5,7 @@ org.assertj assertj-build - 3.24.2-SNAPSHOT + 3.25.0 assertj-bom @@ -35,8 +35,6 @@ org.codehaus.mojo flatten-maven-plugin - 1.3.0 - false flatten diff --git a/assertj-core/pom.xml b/assertj-core/pom.xml index bced047b21..0e48254ddf 100644 --- a/assertj-core/pom.xml +++ b/assertj-core/pom.xml @@ -5,7 +5,7 @@ org.assertj assertj-parent - 3.24.2-SNAPSHOT + 3.25.0 ../assertj-parent @@ -25,11 +25,13 @@ --add-opens=java.base/sun.nio.fs=ALL-UNNAMED -html5 --allow-script-in-comments + ${project.basedir}/../ + false - 1.12.21 + 1.14.11 2.2 - 1.0.3 + 1.1.4 @@ -52,7 +54,7 @@ org.jboss.logging jboss-logging - 3.5.0.Final + 3.5.3.Final @@ -98,19 +100,19 @@ commons-io commons-io - 2.11.0 + 2.15.1 test com.fasterxml.jackson.core jackson-databind - 2.14.1 + 2.16.1 test com.google.guava guava - 31.1-jre + 33.0.0-jre test @@ -122,7 +124,7 @@ nl.jqno.equalsverifier equalsverifier - 3.12.3 + 3.15.5 test @@ -134,13 +136,13 @@ org.apache.commons commons-lang3 - 3.12.0 + 3.14.0 test org.hibernate.orm hibernate-core - 6.1.6.Final + 6.4.1.Final test @@ -176,6 +178,12 @@ org.junit.vintage junit-vintage-engine test + + + org.hamcrest + hamcrest-core + + org.mockito @@ -190,7 +198,13 @@ org.springframework spring-core - 5.3.24 + 5.3.31 + test + + + javax.servlet + javax.servlet-api + 4.0.1 test @@ -279,7 +293,7 @@ maven-enforcer-plugin - enforce-java-and-dependencies + enforce-dependencies enforce @@ -296,9 +310,6 @@ - - [17,) - @@ -330,7 +341,6 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M7 false @@ -443,20 +453,46 @@ - + ]]> + + org.codehaus.mojo + flatten-maven-plugin + + + flatten + process-resources + + flatten + + + ossrh + + remove + + + + + flatten-clean + clean + + clean + + + + org.pitest pitest-maven - 1.10.4 + 1.15.3 org.pitest pitest-junit5-plugin - 1.1.1 + 1.2.1 com.groupcdg diff --git a/assertj-core/src/main/java/org/assertj/core/api/AbstractAssert.java b/assertj-core/src/main/java/org/assertj/core/api/AbstractAssert.java index 3e6ef560bc..37d3b9fa22 100644 --- a/assertj-core/src/main/java/org/assertj/core/api/AbstractAssert.java +++ b/assertj-core/src/main/java/org/assertj/core/api/AbstractAssert.java @@ -173,7 +173,7 @@ protected AssertionError failure(String errorMessage, Object... arguments) { if (assertionError == null) { // error message was not overridden, build it. String description = MessageFormatter.instance().format(info.description(), info.representation(), ""); - assertionError = new AssertionError(description + String.format(errorMessage, arguments)); + assertionError = new AssertionError(description + format(errorMessage, arguments)); } Failures.instance().removeAssertJRelatedElementsFromStackTraceIfNeeded(assertionError); removeCustomAssertRelatedElementsFromStackTraceIfNeeded(assertionError); @@ -361,6 +361,11 @@ private void printDescriptionText() { /** {@inheritDoc} */ @Override public SELF isEqualTo(Object expected) { + if (actual instanceof AbstractAssert && throwUnsupportedExceptionOnEquals) { + throw new UnsupportedOperationException("Attempted to compare an assertion object to another object using 'isEqualTo'. " + + "This is not supported. Perhaps you meant 'isSameAs' instead?"); + } + objects.assertEqual(info, actual, expected); return myself; } @@ -368,6 +373,11 @@ public SELF isEqualTo(Object expected) { /** {@inheritDoc} */ @Override public SELF isNotEqualTo(Object other) { + if (actual instanceof AbstractAssert && throwUnsupportedExceptionOnEquals) { + throw new UnsupportedOperationException("Attempted to compare an assertion object to another object using 'isNotEqualTo'. " + + "This is not supported. Perhaps you meant 'isNotSameAs' instead?"); + } + objects.assertNotEqual(info, actual, other); return myself; } @@ -524,6 +534,13 @@ public SELF hasToString(String expectedToString) { return myself; } + /** {@inheritDoc} */ + @Override + public SELF hasToString(String expectedStringTemplate, Object... args) { + requireNonNull(expectedStringTemplate, "The expectedStringTemplate must not be null"); + return hasToString(format(expectedStringTemplate, args)); + } + /** {@inheritDoc} */ @Override public SELF doesNotHaveToString(String otherToString) { @@ -531,6 +548,13 @@ public SELF doesNotHaveToString(String otherToString) { return myself; } + /** {@inheritDoc} */ + @Override + public SELF doesNotHaveToString(String expectedStringTemplate, Object... args) { + requireNonNull(expectedStringTemplate, "The expectedStringTemplate must not be null"); + return doesNotHaveToString(format(expectedStringTemplate, args)); + } + /** {@inheritDoc} */ @Override public SELF doesNotHaveSameClassAs(Object other) { @@ -567,12 +591,11 @@ public SELF isNotOfAnyClassIn(Class... types) { } /** {@inheritDoc} */ - @SuppressWarnings("unchecked") + @Deprecated @Override @CheckReturnValue public AbstractListAssert, Object, ObjectAssert> asList() { - objects.assertIsInstanceOf(info, actual, List.class); - return newListAssertInstance((List) actual).as(info.description()); + return asInstanceOf(InstanceOfAssertFactories.LIST); } /** {@inheritDoc} */ @@ -726,7 +749,7 @@ public SELF withRepresentation(Representation representation) { @Deprecated public boolean equals(Object obj) { if (throwUnsupportedExceptionOnEquals) { - throw new UnsupportedOperationException("'equals' is not supported...maybe you intended to call 'isEqualTo'"); + throw new UnsupportedOperationException("'equals' is not supported... maybe you intended to call 'isEqualTo'"); } return super.equals(obj); } @@ -750,7 +773,7 @@ public int hashCode() { * * @param predicate the {@link Predicate} to match * @return {@code this} assertion object. - * @throws AssertionError if the actual does not match the given {@link Predicate}. + * @throws AssertionError if {@code actual} does not match the given {@link Predicate}. * @throws NullPointerException if given {@link Predicate} is null. */ public SELF matches(Predicate predicate) { @@ -775,7 +798,7 @@ public SELF matches(Predicate predicate) { * @param predicate the {@link Predicate} to match * @param predicateDescription a description of the {@link Predicate} used in the error message * @return {@code this} assertion object. - * @throws AssertionError if the actual does not match the given {@link Predicate}. + * @throws AssertionError if {@code actual} does not match the given {@link Predicate}. * @throws NullPointerException if given {@link Predicate} is null. * @throws NullPointerException if given predicateDescription is null. */ @@ -1095,7 +1118,7 @@ protected RecursiveAssertionAssert usingRecursiveAssertion() { * @param propertyOrField the property/field to extract from the initial object under test * @param assertFactory the factory for the creation of the new {@code Assert} * @return the new {@code Assert} instance - * @throws AssertionError if the object under test is {@code null} + * @throws AssertionError if {@code actual} is {@code null} * * @since 3.16.0 * @see AbstractObjectAssert#extracting(String) @@ -1123,7 +1146,7 @@ protected RecursiveAssertionAssert usingRecursiveAssertion() { * @param extractor the extractor function used to extract the value from the object under test * @param assertFactory the factory for the creation of the new {@code Assert} * @return the new {@code Assert} instance - * @throws AssertionError if the object under test is {@code null} + * @throws AssertionError if {@code actual} is {@code null} * * @since 3.16.0 * @see AbstractObjectAssert#extracting(Function) @@ -1155,5 +1178,4 @@ protected RecursiveAssertionAssert usingRecursiveAssertion() { protected boolean areEqual(Object actual, Object other) { return objects.getComparisonStrategy().areEqual(actual, other); } - } diff --git a/assertj-core/src/main/java/org/assertj/core/api/AbstractBooleanArrayAssert.java b/assertj-core/src/main/java/org/assertj/core/api/AbstractBooleanArrayAssert.java index 5ec2bfd74c..380d525f1e 100644 --- a/assertj-core/src/main/java/org/assertj/core/api/AbstractBooleanArrayAssert.java +++ b/assertj-core/src/main/java/org/assertj/core/api/AbstractBooleanArrayAssert.java @@ -205,7 +205,7 @@ public SELF hasSameSizeAs(Iterable other) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ @@ -229,7 +229,7 @@ public SELF contains(boolean... values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. * @since 3.19.0 @@ -256,7 +256,7 @@ public SELF contains(Boolean[] values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some * or none of the given values, or the actual array contains more values than the given ones. @@ -282,7 +282,7 @@ public SELF containsOnly(boolean... values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some * or none of the given values, or the actual array contains more values than the given ones. @@ -308,7 +308,7 @@ public SELF containsOnly(Boolean[] values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some * or none of the given values, or the actual group contains more than once these values. @@ -333,7 +333,7 @@ public SELF containsOnlyOnce(boolean... values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some * or none of the given values, or the actual group contains more than once these values. @@ -359,6 +359,7 @@ public SELF containsOnlyOnce(Boolean[] values) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given sequence. */ public SELF containsSequence(boolean... sequence) { @@ -381,6 +382,7 @@ public SELF containsSequence(boolean... sequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given sequence. */ public SELF containsSequence(Boolean[] sequence) { @@ -404,6 +406,7 @@ public SELF containsSequence(Boolean[] sequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given subsequence. */ public SELF containsSubsequence(boolean... subsequence) { @@ -426,6 +429,7 @@ public SELF containsSubsequence(boolean... subsequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given subsequence. */ public SELF containsSubsequence(Boolean[] subsequence) { @@ -563,7 +567,7 @@ public SELF doesNotHaveDuplicates() { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ @@ -587,7 +591,7 @@ public SELF startsWith(boolean... sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ @@ -612,7 +616,6 @@ public SELF startsWith(Boolean[] sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ @@ -636,7 +639,6 @@ public SELF endsWith(boolean... sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ @@ -698,6 +700,7 @@ public final SELF usingDefaultElementComparator() { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones * or values are the same but the order is not. @@ -721,6 +724,7 @@ public SELF containsExactly(boolean... values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones * or values are the same but the order is not. @@ -749,6 +753,7 @@ public SELF containsExactly(Boolean[] values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones. * @since 2.6.0 / 3.6.0 @@ -775,6 +780,7 @@ public SELF containsExactlyInAnyOrder(boolean... values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones. * @since 3.19.0 @@ -802,7 +808,7 @@ public SELF containsExactlyInAnyOrder(Boolean[] values) { * @param values the values whose at least one which is expected to be in the array under test. * @return {@code this} assertion object. * @throws NullPointerException if the array of values is {@code null}. - * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty. + * @throws AssertionError if the array of values is empty and the array under test is not empty. * @throws AssertionError if the array under test is {@code null}. * @throws AssertionError if the array under test does not contain any of the given {@code values}. * @since 2.9.0 / 3.9.0 @@ -829,7 +835,7 @@ public SELF containsAnyOf(boolean... values) { * @param values the values whose at least one which is expected to be in the array under test. * @return {@code this} assertion object. * @throws NullPointerException if the array of values is {@code null}. - * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty. + * @throws AssertionError if the array of values is empty and the array under test is not empty. * @throws AssertionError if the array under test is {@code null}. * @throws AssertionError if the array under test does not contain any of the given {@code values}. * @since 3.19.0 diff --git a/assertj-core/src/main/java/org/assertj/core/api/AbstractByteArrayAssert.java b/assertj-core/src/main/java/org/assertj/core/api/AbstractByteArrayAssert.java index d44bfb5b9b..b5495c8827 100644 --- a/assertj-core/src/main/java/org/assertj/core/api/AbstractByteArrayAssert.java +++ b/assertj-core/src/main/java/org/assertj/core/api/AbstractByteArrayAssert.java @@ -211,10 +211,10 @@ public SELF hasSameSizeAs(Iterable other) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not contain the given values. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not contain the given values. */ public SELF contains(byte... values) { arrays.assertContains(info, actual, values); @@ -236,10 +236,10 @@ public SELF contains(byte... values) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not contain the given values. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not contain the given values. * @since 3.19.0 */ public SELF contains(Byte[] values) { @@ -263,10 +263,10 @@ public SELF contains(Byte[] values) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not contain the given values. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not contain the given values. * @since 2.6.0 / 3.6.0 */ public SELF contains(int... values) { @@ -289,13 +289,12 @@ public SELF contains(int... values) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array - * contains some - * or none of the given values, or the actual array contains more values than the - * given ones. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains + * some or none of the given values, or the actual array contains more values than the + * given ones. */ public SELF containsOnly(byte... values) { arrays.assertContainsOnly(info, actual, values); @@ -317,13 +316,12 @@ public SELF containsOnly(byte... values) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array - * contains some - * or none of the given values, or the actual array contains more values than the - * given ones. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains + * some or none of the given values, or the actual array contains more values than the + * given ones. * @since 3.19.0 */ public SELF containsOnly(Byte[] values) { @@ -347,13 +345,12 @@ public SELF containsOnly(Byte[] values) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array - * contains some - * or none of the given values, or the actual array contains more values than the - * given ones. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains + * some or none of the given values, or the actual array contains more values than the + * given ones. * @since 2.6.0 / 3.6.0 */ public SELF containsOnly(int... values) { @@ -375,13 +372,12 @@ public SELF containsOnly(int... values) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group - * contains some - * or none of the given values, or the actual group contains more than once these - * values. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains + * some or none of the given values, or the actual group contains more than once these + * values. */ public SELF containsOnlyOnce(byte... values) { arrays.assertContainsOnlyOnce(info, actual, values); @@ -402,13 +398,12 @@ public SELF containsOnlyOnce(byte... values) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group - * contains some - * or none of the given values, or the actual group contains more than once these - * values. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains + * some or none of the given values, or the actual group contains more than once these + * values. * @since 3.19.0 */ public SELF containsOnlyOnce(Byte[] values) { @@ -431,13 +426,12 @@ public SELF containsOnlyOnce(Byte[] values) { * * @param values the given values. * @return {@code this} assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group - * contains some - * or none of the given values, or the actual group contains more than once these - * values. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains + * some or none of the given values, or the actual group contains more than once these + * values. * @since 2.6.0 / 3.6.0 */ public SELF containsOnlyOnce(int... values) { @@ -462,6 +456,7 @@ public SELF containsOnlyOnce(int... values) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given sequence. */ public SELF containsSequence(byte... sequence) { @@ -486,6 +481,7 @@ public SELF containsSequence(byte... sequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given sequence. * @since 3.19.0 */ @@ -512,6 +508,7 @@ public SELF containsSequence(Byte[] sequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given sequence. * @since 2.6.0 / 3.6.0 */ @@ -538,6 +535,7 @@ public SELF containsSequence(int... sequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given subsequence. */ public SELF containsSubsequence(byte... subsequence) { @@ -563,6 +561,7 @@ public SELF containsSubsequence(byte... subsequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given subsequence. * @since 3.19.0 */ @@ -590,6 +589,7 @@ public SELF containsSubsequence(Byte[] subsequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given subsequence. * @since 2.6.0 / 3.6.0 */ @@ -802,10 +802,10 @@ public SELF doesNotHaveDuplicates() { * * @param sequence the sequence of values to look for. * @return myself assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not start with the given sequence. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not start with the given sequence. */ public SELF startsWith(byte... sequence) { arrays.assertStartsWith(info, actual, sequence); @@ -826,10 +826,10 @@ public SELF startsWith(byte... sequence) { * * @param sequence the sequence of values to look for. * @return myself assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not start with the given sequence. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not start with the given sequence. * @since 3.19.0 */ public SELF startsWith(Byte[] sequence) { @@ -852,10 +852,10 @@ public SELF startsWith(Byte[] sequence) { * * @param sequence the sequence of values to look for. * @return myself assertion object. - * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. - * @throws AssertionError if the actual array is {@code null}. - * @throws AssertionError if the actual array does not start with the given sequence. + * @throws NullPointerException if the given argument is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. + * @throws AssertionError if the actual array is {@code null}. + * @throws AssertionError if the actual array does not start with the given sequence. * @since 2.6.0 / 3.6.0 */ public SELF startsWith(int... sequence) { @@ -878,7 +878,6 @@ public SELF startsWith(int... sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ @@ -902,7 +901,6 @@ public SELF endsWith(byte... sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. * @since 3.19.0 @@ -928,7 +926,6 @@ public SELF endsWith(Byte[] sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. * @since 2.6.0 / 3.6.0 @@ -985,6 +982,7 @@ public SELF usingDefaultElementComparator() { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual * group * contains some or none of the given values, or the actual group contains more values @@ -1018,6 +1016,7 @@ public SELF containsExactly(byte... values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual * group * contains some or none of the given values, or the actual group contains more values @@ -1051,6 +1050,7 @@ public SELF containsExactly(Byte[] values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual * group * contains some or none of the given values, or the actual group contains more values @@ -1080,6 +1080,7 @@ public SELF containsExactly(int... values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones. * @since 2.6.0 / 3.6.0 @@ -1106,6 +1107,7 @@ public SELF containsExactlyInAnyOrder(byte... values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones. * @since 3.19.0 @@ -1133,6 +1135,7 @@ public SELF containsExactlyInAnyOrder(Byte[] values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones. * @since 2.6.0 / 3.6.0 @@ -1162,7 +1165,7 @@ public SELF containsExactlyInAnyOrder(int... values) { * @param values the values whose at least one which is expected to be in the array under test. * @return {@code this} assertion object. * @throws NullPointerException if the array of values is {@code null}. - * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty. + * @throws AssertionError if the array of values is empty and the array under test is not empty. * @throws AssertionError if the array under test is {@code null}. * @throws AssertionError if the array under test does not contain any of the given {@code values}. * @since 2.9.0 / 3.9.0 @@ -1192,7 +1195,7 @@ public SELF containsAnyOf(byte... values) { * @param values the values whose at least one which is expected to be in the array under test. * @return {@code this} assertion object. * @throws NullPointerException if the array of values is {@code null}. - * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty. + * @throws AssertionError if the array of values is empty and the array under test is not empty. * @throws AssertionError if the array under test is {@code null}. * @throws AssertionError if the array under test does not contain any of the given {@code values}. * @since 3.19.0 @@ -1223,7 +1226,7 @@ public SELF containsAnyOf(Byte[] values) { * @param values the values whose at least one which is expected to be in the array under test. * @return {@code this} assertion object. * @throws NullPointerException if the array of values is {@code null}. - * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty. + * @throws AssertionError if the array of values is empty and the array under test is not empty. * @throws AssertionError if the array under test is {@code null}. * @throws AssertionError if the array under test does not contain any of the given {@code values}. * @since 2.9.0 / 3.9.0 diff --git a/assertj-core/src/main/java/org/assertj/core/api/AbstractCharArrayAssert.java b/assertj-core/src/main/java/org/assertj/core/api/AbstractCharArrayAssert.java index 20404bbdd7..8978d39242 100644 --- a/assertj-core/src/main/java/org/assertj/core/api/AbstractCharArrayAssert.java +++ b/assertj-core/src/main/java/org/assertj/core/api/AbstractCharArrayAssert.java @@ -210,7 +210,7 @@ public SELF hasSameSizeAs(Iterable other) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ @@ -235,7 +235,7 @@ public SELF contains(char... values) { * @param values the given {@code Character} array of values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. * @since 3.19.0 @@ -262,7 +262,7 @@ public SELF contains(Character[] values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some * or none of the given values, or the actual array contains more values than the given ones. @@ -288,7 +288,7 @@ public SELF containsOnly(char... values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some * or none of the given values, or the actual array contains more values than the given ones. @@ -315,7 +315,7 @@ public SELF containsOnly(Character[] values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some * or none of the given values, or the actual group contains more than once these values. @@ -340,7 +340,7 @@ public SELF containsOnlyOnce(char... values) { * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some * or none of the given values, or the actual group contains more than once these values. @@ -369,6 +369,7 @@ public SELF containsOnlyOnce(Character[] values) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given sequence. */ public SELF containsSequence(char... sequence) { @@ -393,6 +394,7 @@ public SELF containsSequence(char... sequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given sequence. * @since 3.19.0 */ @@ -420,6 +422,7 @@ public SELF containsSequence(Character[] sequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given subsequence. */ public SELF containsSubsequence(char... subsequence) { @@ -445,6 +448,7 @@ public SELF containsSubsequence(char... subsequence) { * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array does not contain the given subsequence. * @since 3.19.0 */ @@ -584,7 +588,7 @@ public SELF doesNotHaveDuplicates() { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ @@ -608,7 +612,7 @@ public SELF startsWith(char... sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. * @since 3.19.0 @@ -634,7 +638,6 @@ public SELF startsWith(Character[] sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ @@ -658,7 +661,6 @@ public SELF endsWith(char... sequence) { * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. - * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. * @since 3.19.0 @@ -713,6 +715,7 @@ public SELF usingDefaultElementComparator() { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones * or values are the same but the order is not. @@ -736,6 +739,7 @@ public SELF containsExactly(char... values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones * or values are the same but the order is not. @@ -764,6 +768,7 @@ public SELF containsExactly(Character[] values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones. * @since 2.6.0 / 3.6.0 @@ -790,6 +795,7 @@ public SELF containsExactlyInAnyOrder(char... values) { * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. + * @throws AssertionError if the given argument is an empty array and the actual array is not empty. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones. * @since 3.19.0 @@ -845,7 +851,7 @@ public SELF inUnicode() { * @param values the values whose at least one which is expected to be in the array under test. * @return {@code this} assertion object. * @throws NullPointerException if the array of values is {@code null}. - * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty. + * @throws AssertionError if the array of values is empty and the array under test is not empty. * @throws AssertionError if the array under test is {@code null}. * @throws AssertionError if the array under test does not contain any of the given {@code values}. * @since 2.9.0 / 3.9.0 @@ -875,7 +881,7 @@ public SELF containsAnyOf(char... values) { * @param values the array of values whose at least one which is expected to be in the array under test. * @return {@code this} assertion object. * @throws NullPointerException if the array of values is {@code null}. - * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty. + * @throws AssertionError if the array of values is empty and the array under test is not empty. * @throws AssertionError if the array under test is {@code null}. * @throws AssertionError if the array under test does not contain any of the given {@code values}. * @since 3.19.0 diff --git a/assertj-core/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java b/assertj-core/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java index 0668b35fc9..95b96ed9e3 100644 --- a/assertj-core/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java +++ b/assertj-core/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java @@ -12,19 +12,32 @@ */ package org.assertj.core.api; +import static java.util.Arrays.stream; +import static java.util.stream.Collectors.toCollection; import static org.assertj.core.api.Assertions.contentOf; import static org.assertj.core.error.ShouldBeASCII.shouldBeASCII; import static org.assertj.core.error.ShouldBeAlphabetic.shouldBeAlphabetic; import static org.assertj.core.error.ShouldBeAlphanumeric.shouldBeAlphanumeric; +import static org.assertj.core.error.ShouldBeBlank.shouldBeBlank; import static org.assertj.core.error.ShouldBeHexadecimal.shouldBeHexadecimal; import static org.assertj.core.error.ShouldBePrintable.shouldBePrintable; import static org.assertj.core.error.ShouldBeVisible.shouldBeVisible; +import static org.assertj.core.error.ShouldContainCharSequence.shouldContainIgnoringWhitespaces; +import static org.assertj.core.error.ShouldContainOneOrMoreWhitespaces.shouldContainOneOrMoreWhitespaces; +import static org.assertj.core.error.ShouldContainOnlyWhitespaces.shouldContainOnlyWhitespaces; +import static org.assertj.core.error.ShouldNotBeBlank.shouldNotBeBlank; +import static org.assertj.core.error.ShouldNotContainAnyWhitespaces.shouldNotContainAnyWhitespaces; +import static org.assertj.core.error.ShouldNotContainOnlyWhitespaces.shouldNotContainOnlyWhitespaces; +import static org.assertj.core.internal.Strings.doCommonCheckForCharSequence; +import static org.assertj.core.internal.Strings.removeAllWhitespaces; import static org.assertj.core.util.IterableUtil.toArray; import java.io.File; import java.io.LineNumberReader; import java.text.Normalizer; import java.util.Comparator; +import java.util.LinkedHashSet; +import java.util.Set; import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -155,10 +168,14 @@ public SELF isNotEmpty() { * @since 2.6.0 / 3.6.0 */ public SELF isBlank() { - strings.assertBlank(info, actual); + assertBlank(actual); return myself; } + private void assertBlank(CharSequence actual) { + if (!isBlank(actual)) throw assertionError(shouldBeBlank(actual)); + } + /** * Verifies that the actual {@code CharSequence} is: *