├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ ├── main.yml │ └── release.yml ├── .gitignore ├── .idea └── icon.svg ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── assertj-generator ├── javadoc-theme │ ├── assertj-theme.css │ └── hljs-theme.css ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── assertj │ │ │ └── assertions │ │ │ └── generator │ │ │ ├── AssertionGenerator.java │ │ │ ├── AssertionsEntryPointGenerator.java │ │ │ ├── AssertionsEntryPointType.java │ │ │ ├── BaseAssertionGenerator.java │ │ │ ├── DefaultTemplateRegistryProducer.java │ │ │ ├── GenerateAssertion.java │ │ │ ├── Template.java │ │ │ ├── TemplateRegistry.java │ │ │ ├── cli │ │ │ └── AssertionGeneratorLauncher.java │ │ │ ├── description │ │ │ ├── ClassDescription.java │ │ │ ├── DataDescription.java │ │ │ ├── FieldDescription.java │ │ │ ├── GetterDescription.java │ │ │ ├── Visibility.java │ │ │ └── converter │ │ │ │ ├── AnnotationConfiguration.java │ │ │ │ ├── ClassDescriptionConverter.java │ │ │ │ └── ClassToClassDescriptionConverter.java │ │ │ └── util │ │ │ ├── ClassUtil.java │ │ │ └── StringUtil.java │ ├── resources │ │ ├── assemblies │ │ │ ├── unix-assembly.xml │ │ │ └── windows-assembly.xml │ │ ├── logback.xml │ │ ├── scripts │ │ │ ├── generate-assertions.bat │ │ │ └── generate-assertions.sh │ │ └── templates │ │ │ ├── auto_closeable_bdd_soft_assertions_entry_point_class_template.txt │ │ │ ├── auto_closeable_soft_assertions_entry_point_class_template.txt │ │ │ ├── bdd_assertion_entry_point_method_template.txt │ │ │ ├── bdd_assertions_entry_point_class_template.txt │ │ │ ├── bdd_soft_assertion_entry_point_method_template.txt │ │ │ ├── bdd_soft_assertions_entry_point_class_template.txt │ │ │ ├── custom_abstract_assertion_class_template.txt │ │ │ ├── custom_assertion_class_template.txt │ │ │ ├── custom_hierarchical_assertion_class_template.txt │ │ │ ├── has_assertion_template.txt │ │ │ ├── has_assertion_template_for_char.txt │ │ │ ├── has_assertion_template_for_character.txt │ │ │ ├── has_assertion_template_for_primitive.txt │ │ │ ├── has_assertion_template_for_primitive_wrapper.txt │ │ │ ├── has_assertion_template_for_real_number.txt │ │ │ ├── has_assertion_template_for_real_number_wrapper.txt │ │ │ ├── has_assertion_template_for_whole_number.txt │ │ │ ├── has_assertion_template_for_whole_number_wrapper.txt │ │ │ ├── has_elements_assertion_template_for_array.txt │ │ │ ├── has_elements_assertion_template_for_iterable.txt │ │ │ ├── is_assertion_template.txt │ │ │ ├── is_without_negative_assertion_template.txt │ │ │ ├── is_wrapper_assertion_template.txt │ │ │ ├── is_wrapper_without_negative_assertion_template.txt │ │ │ ├── junit_bdd_soft_assertions_entry_point_class_template.txt │ │ │ ├── junit_soft_assertions_entry_point_class_template.txt │ │ │ ├── soft_assertion_entry_point_method_template.txt │ │ │ ├── soft_assertions_entry_point_class_template.txt │ │ │ ├── standard_assertion_entry_point_method_template.txt │ │ │ └── standard_assertions_entry_point_class_template.txt │ └── scripts │ │ └── build.gradle │ └── test │ ├── java │ ├── my │ │ └── assertions │ │ │ └── OuterClassStaticNestedPersonAssert.java │ └── org │ │ └── assertj │ │ └── assertions │ │ └── generator │ │ ├── AssertionGeneratorOverrideTemplateTest.java │ │ ├── AssertionGeneratorTest.java │ │ ├── AssertionsEntryPointGeneratorTest.java │ │ ├── BeanWithExceptionsTest.java │ │ ├── ClassUsingDifferentClassesWithSameName.java │ │ ├── GenerationHandler.java │ │ ├── NestedClassesTest.java │ │ ├── PlayerAssertTest.java │ │ ├── TemplateTest.java │ │ ├── data │ │ ├── AnnotatedClass.java │ │ ├── AutoValue.java │ │ ├── AutoValueAnnotatedClass.java │ │ ├── BeanWithOneException.java │ │ ├── BeanWithTwoExceptions.java │ │ ├── BlockBuster.java │ │ ├── BooleanPredicates.java │ │ ├── Dollar$.java │ │ ├── EnemyReport.java │ │ ├── FieldPropertyClash.java │ │ ├── InterferencePrimitives.java │ │ ├── Keywords.java │ │ ├── Movie.java │ │ ├── Name.java │ │ ├── OuterClass.java │ │ ├── ParameterClashWithVariables.java │ │ ├── Primitives.java │ │ ├── Team.java │ │ ├── TreeEnum.java │ │ ├── WithPrivateFields.java │ │ ├── WithPrivateFieldsParent.java │ │ ├── art │ │ │ └── ArtWork.java │ │ ├── cars │ │ │ └── Car.java │ │ ├── inner │ │ │ ├── Data.java │ │ │ └── PackagePrivate.java │ │ ├── lotr │ │ │ ├── FellowshipOfTheRing.java │ │ │ ├── Race.java │ │ │ ├── Ring.java │ │ │ └── TolkienCharacter.java │ │ ├── nba │ │ │ ├── Player.java │ │ │ ├── PlayerAgent.java │ │ │ └── team │ │ │ │ ├── Coach.java │ │ │ │ └── Team.java │ │ └── package-info.java │ │ ├── description │ │ ├── FieldDescriptionTest.java │ │ ├── GetterDescriptionTest.java │ │ └── converter │ │ │ └── ClassToClassDescriptionConverterTest.java │ │ └── util │ │ ├── ClassUtilTest.java │ │ ├── PackagePrivate.java │ │ └── StringUtilTest.java │ └── resources │ ├── AbstractAnnotatedClassAssert.expected.txt │ ├── AbstractArtWorkAssert.expected.txt │ ├── AbstractAutoValueAnnotatedClassAssert.expected.txt │ ├── AbstractBlockBusterAssert.expected.txt │ ├── AbstractBooleanPredicatesAssert.expected.txt │ ├── AbstractClassUsingDifferentClassesWithSameNameAssert.expected.txt │ ├── AbstractDollar$Assert.expected.txt │ ├── AbstractFieldPropertyClashAssert.expected.txt │ ├── AbstractInterferencePrimitivesAssert.expected.txt │ ├── AbstractKeywordsAssert.expected.txt │ ├── AbstractMovieAssert.expected.txt │ ├── AbstractMultipleGenericsAssert.expected.txt │ ├── AbstractNameAssert.expected.txt │ ├── AbstractOptionalAssert.expected.txt │ ├── AbstractPlayerAgentAssert.expected.txt │ ├── AbstractPlayerAgentAssert.generated.in.custom.package.expected.txt │ ├── AbstractPlayerAssert.expected.txt │ ├── AbstractPlayerAssert.generated.in.custom.package.expected.txt │ ├── AbstractPrimitivesAssert.expected.txt │ ├── AbstractTeamAssert.expected.txt │ ├── AbstractWithPrivateFieldsAssert.expected.txt │ ├── AbstractWithPrivateFieldsParentAssert.expected.txt │ ├── AnnotatedClassAssert.expected.txt │ ├── AnnotatedClassAssert.flat.expected.txt │ ├── ArtWorkAssert.expected.txt │ ├── Assertions.expected.txt │ ├── AssertionsForClassesWithSameName.expected.txt │ ├── AssertionsWithCustomPackage.expected.txt │ ├── AutoCloseableBDDSoftAssertions.expected.txt │ ├── AutoCloseableSoftAssertions.expected.txt │ ├── AutoValueAnnotatedClassAssert.expected.txt │ ├── AutoValueAnnotatedClassAssert.flat.expected.txt │ ├── BDDSoftAssertions.expected.txt │ ├── BddAssertions.expected.txt │ ├── BeanWithOneException.expected.txt │ ├── BlockBusterAssert.expected.txt │ ├── BooleanPredicatesAssert.expected.txt │ ├── BooleanPredicatesAssert.flat.expected.txt │ ├── CarAssert.expected.txt │ ├── ClassUsingDifferentClassesWithSameNameAssert.expected.txt │ ├── ClassUsingDifferentClassesWithSameNameAssert.flat.expected.txt │ ├── Dollar$Assert.expected.txt │ ├── Dollar$Assert.flat.expected.txt │ ├── FieldPropertyClashAssert.expected.txt │ ├── FieldPropertyClashAssert.flat.expected.txt │ ├── InterferencePrimitivesAssert.expected.txt │ ├── InterferencePrimitivesAssert.flat.expected.txt │ ├── JUnitBDDSoftAssertions.expected.txt │ ├── JUnitSoftAssertions.expected.txt │ ├── KeywordsAssert.expected.txt │ ├── KeywordsAssert.flat.expected.txt │ ├── MovieAssert.expected.txt │ ├── MovieAssert.flat.expected.txt │ ├── MultipleGenericsAssert.expected.txt │ ├── MultipleGenericsAssert.flat.expected.txt │ ├── MyAssertions.expected.txt │ ├── NameAssert.expected.txt │ ├── NameAssert.flat.expected.txt │ ├── NestedClassAssert.hierarchical.template.expected.txt │ ├── NestedClassAssert.template.expected.txt │ ├── NestedClassAssert.template.generated.in.custom.package.expected.txt │ ├── OptionalAssert.expected.txt │ ├── OptionalAssert.flat.expected.txt │ ├── ParameterClashWithVariablesAssert.flat.expected.txt │ ├── PlayerAgentAssert.expected.txt │ ├── PlayerAgentAssert.flat.expected.txt │ ├── PlayerAgentAssert.generated.in.custom.package.expected.txt │ ├── PlayerAgentAssert.generated.in.custom.package.flat.expected.txt │ ├── PlayerAssert.expected.txt │ ├── PlayerAssert.flat.expected.txt │ ├── PlayerAssert.generated.in.custom.package.expected.txt │ ├── PlayerAssert.generated.in.custom.package.flat.expected.txt │ ├── PrimitivesAssert.expected.txt │ ├── PrimitivesAssert.flat.expected.txt │ ├── SoftAssertions.expected.txt │ ├── TeamAssert.expected.txt │ ├── TeamAssert.flat.expected.txt │ ├── WithPrivateFieldsAssert.expected.txt │ ├── WithPrivateFieldsAssert.flat.expected.txt │ ├── WithPrivateFieldsParentAssert.expected.txt │ └── customtemplates │ ├── custom_has_assertion_template_for_whole_number.txt │ └── my_assertion_entry_point_class.txt ├── build-assertion-generator-and-maven-plugin.sh ├── mvnw ├── mvnw.cmd └── pom.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig: https://editorconfig.org/ 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | charset = utf-8 11 | 12 | # 2 space indentation for java, xml and yml files 13 | [*.{java,xml,yml,sh}] 14 | indent_style = space 15 | indent_size = 2 16 | 17 | # Maven POM code convention 18 | [pom.xml] 19 | max_line_length = 205 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | env: 6 | MAVEN_ARGS: -B -V -ntp -e -Djansi.passthrough=true -Dstyle.color=always 7 | 8 | jobs: 9 | 10 | test: 11 | 12 | name: Test 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Set up Java 18 | uses: actions/setup-java@v4 19 | with: 20 | distribution: 'zulu' 21 | java-version: '21' 22 | cache: 'maven' 23 | - name: Test 24 | run: ./mvnw $MAVEN_ARGS verify 25 | 26 | javadoc: 27 | 28 | name: Javadoc 29 | runs-on: ubuntu-latest 30 | 31 | steps: 32 | - uses: actions/checkout@v4 33 | - name: Set up Java 34 | uses: actions/setup-java@v4 35 | with: 36 | distribution: 'zulu' 37 | java-version: '21' 38 | cache: 'maven' 39 | - name: Generate Javadoc 40 | run: ./mvnw $MAVEN_ARGS -DskipTests package javadoc:javadoc 41 | 42 | sonar: 43 | 44 | name: Sonar code analysis 45 | runs-on: ubuntu-latest 46 | if: github.repository == 'assertj/assertj-assertions-generator' && github.event_name == 'push' 47 | 48 | steps: 49 | - uses: actions/checkout@v4 50 | - name: Set up Java 51 | uses: actions/setup-java@v4 52 | with: 53 | distribution: 'zulu' 54 | java-version: '21' 55 | cache: 'maven' 56 | - name: Test with Sonar 57 | run: > 58 | ./mvnw -V --no-transfer-progress -e clean verify javadoc:javadoc 59 | org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar 60 | -Dsonar.host.url=https://sonarcloud.io 61 | -Dsonar.organization=assertj 62 | -Dsonar.projectKey=assertj_assertj-assertions-generator 63 | env: 64 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 65 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 66 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | env: 7 | MAVEN_ARGS: -B -V -ntp -e -Djansi.passthrough=true -Dstyle.color=always -Djacoco.skip=true 8 | 9 | jobs: 10 | release: 11 | 12 | name: Release to Maven Central 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Set up Maven Central 18 | uses: actions/setup-java@v4 19 | with: 20 | distribution: 'zulu' 21 | java-version: '21' 22 | server-id: ossrh 23 | server-username: OSSRH_USERNAME 24 | server-password: OSSRH_TOKEN 25 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} 26 | 27 | - name: Publish to Maven Central 28 | run: | 29 | git config user.name '${{ github.actor }}' 30 | git config user.email '${{ github.actor }}@users.noreply.github.com' 31 | ./mvnw $MAVEN_ARGS release:prepare release:perform -Dpassword=${{ secrets.GITHUB_TOKEN }} 32 | env: 33 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} 34 | OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} 35 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | target 3 | /.settings 4 | /.classpath 5 | /.project 6 | .idea/* 7 | !/.idea/icon.svg 8 | *.iml 9 | 10 | 11 | # Package Files # 12 | *.jar 13 | *.war 14 | *.ear 15 | /Vagrantfile 16 | /.vagrant/ 17 | 18 | .flattened-pom.xml 19 | .mvn/wrapper/maven-wrapper.jar 20 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | Thank you for your interest ! 5 | We appreciate your effort and to make sure that your pull request is easy to review, we ask you to make note of the following guidelines : 6 | 7 | * Use **[AssertJ code Eclipse formatting preferences](https://github.com/joel-costigliola/assertj-core/blob/master/src/ide-support/assertj-eclipse-formatter.xml)** (for Idea users, it is possible to import it) 8 | * Unit tests method naming convention is underscore based (like python) and not camel case, we find it is much readable for long test names ! 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AssertJ - Assertions Generator [![Maven Central](https://img.shields.io/maven-central/v/org.assertj/assertj-assertions-generator.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.assertj%22%20AND%20a:%22assertj-assertions-generator%22) [![Javadocs](http://www.javadoc.io/badge/org.assertj/assertj-assertions-generator.svg)](http://www.javadoc.io/doc/org.assertj/assertj-assertions-generator) 2 | 3 | [![CI](https://github.com/assertj/assertj-assertions-generator/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/assertj/assertj-assertions-generator/actions/workflows/main.yml?query=branch%3Amain) 4 | 5 | ## Overview 6 | 7 | The Assertions Generator can create specific assertions for your classes. It comes with : 8 | * a CLI tool (this project) 9 | * a [**maven plugin**](https://github.com/assertj/assertj-assertions-generator-maven-plugin). 10 | * a [**gradle plugin**](https://github.com/assertj/assertj-generator-gradle-plugin). 11 | 12 | Let's say you have a `Player` class with `name` and `team` properties. The generator will create a `PlayerAssert` assertions class with `hasName` and `hasTeam` assertions. This allows you to write : 13 | 14 | ```java 15 | assertThat(mvp).hasName("Lebron James").hasTeam("Miami Heat"); 16 | ``` 17 | 18 | ## Documentation 19 | 20 | Please have a look at the complete documentation in the [**assertions generator section**](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html), including a [**quickstart guide**](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#quickstart). 21 | -------------------------------------------------------------------------------- /assertj-generator/javadoc-theme/assertj-theme.css: -------------------------------------------------------------------------------- 1 | :root { 2 | /* body, block and code fonts */ 3 | --body-font-family: Verdana, Geneva, sans-serif; 4 | --block-font-family: Verdana, Geneva, serif; 5 | /* Text colors for body and block elements */ 6 | --body-text-color: #000000; 7 | --block-text-color: #000000; 8 | /* Background colors for various structural elements */ 9 | --body-background-color: #edd9a6; 10 | --section-background-color: #e9d195; 11 | --detail-background-color: #edd9a6; 12 | /* Colors for navigation bar and table captions */ 13 | --navbar-background-color: #232323; 14 | --navbar-text-color: #edd9a6; 15 | /* Background color for subnavigation and various headers */ 16 | --subnav-background-color: #e5c880; 17 | /* Background and text colors for selected tabs and navigation items */ 18 | --selected-background-color: #e5c880; 19 | --selected-text-color: #000000; 20 | --selected-link-color: #861203; 21 | /* Background colors for generated tables */ 22 | --even-row-color: #edd9a6; 23 | --odd-row-color: #e7ce8e; 24 | /* Text color for page title */ 25 | --title-color: #000000; 26 | /* Text colors for links */ 27 | --link-color: #861203; 28 | --link-color-active: #641003; 29 | /* Border colors for structural elements and user defined tables */ 30 | --border-color: #e5c880; 31 | /* Search input colors */ 32 | --search-input-background-color: #edd9a6; 33 | } 34 | -------------------------------------------------------------------------------- /assertj-generator/javadoc-theme/hljs-theme.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Railscasts-like style (c) Visoft, Inc. (Damien White) 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | background: #232323; 12 | color: #e6e1dc; 13 | /* added by us */ 14 | border-radius:8px; 15 | } 16 | 17 | .hljs-comment, 18 | .hljs-quote { 19 | color: #bc9458; 20 | font-style: italic; 21 | } 22 | 23 | .hljs-keyword, 24 | .hljs-selector-tag { 25 | color: #c26230; 26 | } 27 | 28 | .hljs-string, 29 | .hljs-number, 30 | .hljs-regexp, 31 | .hljs-variable, 32 | .hljs-template-variable { 33 | color: #a5c261; 34 | } 35 | 36 | .hljs-subst { 37 | color: #519f50; 38 | } 39 | 40 | .hljs-tag, 41 | .hljs-name { 42 | color: #e8bf6a; 43 | } 44 | 45 | .hljs-type { 46 | color: #ffc66d; 47 | } 48 | 49 | 50 | .hljs-symbol, 51 | .hljs-bullet, 52 | .hljs-built_in, 53 | .hljs-builtin-name, 54 | .hljs-attr, 55 | .hljs-link { 56 | color: #6d9cbe; 57 | } 58 | 59 | .hljs-params { 60 | color: #d0d0ff; 61 | } 62 | 63 | .hljs-attribute { 64 | color: #cda869; 65 | } 66 | 67 | .hljs-meta { 68 | color: #9b859d; 69 | } 70 | 71 | .hljs-title, 72 | .hljs-section { 73 | color: #ffc66d; 74 | } 75 | 76 | .hljs-addition { 77 | background-color: #144212; 78 | color: #e6e1dc; 79 | display: inline-block; 80 | width: 100%; 81 | } 82 | 83 | .hljs-deletion { 84 | background-color: #600; 85 | color: #e6e1dc; 86 | display: inline-block; 87 | width: 100%; 88 | } 89 | 90 | .hljs-selector-class { 91 | color: #9b703f; 92 | } 93 | 94 | .hljs-selector-id { 95 | color: #8b98ab; 96 | } 97 | 98 | .hljs-emphasis { 99 | font-style: italic; 100 | } 101 | 102 | .hljs-strong { 103 | font-weight: bold; 104 | } 105 | 106 | .hljs-link { 107 | text-decoration: underline; 108 | } 109 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/AssertionsEntryPointGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator; 14 | 15 | import org.assertj.assertions.generator.description.ClassDescription; 16 | 17 | import java.io.File; 18 | import java.io.IOException; 19 | import java.util.Set; 20 | 21 | public interface AssertionsEntryPointGenerator { 22 | 23 | /** 24 | * Returns the assertions entry point class content for the given 25 | * {@link org.assertj.assertions.generator.description.ClassDescription} set. 26 | *

27 | * The idea is to generate an equivalent of assertj-core Assertions class to give easy access to all generated 28 | * assertions. With {@link AssertionsEntryPointType} parameter one can generate standard, BDD or Soft assertions entry 29 | * point class (default is {@link AssertionsEntryPointType#STANDARD}). 30 | *

31 | * You can define the package of the generated entry point class, if null the common base package of the given 32 | * classes, will be used, i.e if some classe are in a.b.c and others in a.b.c.d, then entry point class will be in 33 | * a.b.c. 34 | * 35 | * @param classDescriptionSet the set of ClassDescription we want to generate an entry point for. 36 | * @param assertionsEntryPointType the valueType of entry point class to generate 37 | * @param entryPointClassPackage the package of the generated entry point class 38 | * @return the assertions entry point class content 39 | */ 40 | String generateAssertionsEntryPointClassContentFor(Set classDescriptionSet, 41 | AssertionsEntryPointType assertionsEntryPointType, 42 | String entryPointClassPackage); 43 | 44 | /** 45 | * Same as {@link #generateAssertionsEntryPointClassContentFor(Set, AssertionsEntryPointType, String)} but in addition 46 | * create the corresponding java class file. 47 | * 48 | * @param classDescriptionSet class descriptions 49 | * @param assertionsEntryPointType entry point type 50 | * @param entryPointClassPackage entry point class package name 51 | * @throws java.io.IOException if entry point file can't be created. 52 | * @return the generated file 53 | */ 54 | File generateAssertionsEntryPointClassFor(Set classDescriptionSet, 55 | AssertionsEntryPointType assertionsEntryPointType, 56 | String entryPointClassPackage) throws IOException; 57 | 58 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/AssertionsEntryPointType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator; 14 | 15 | 16 | public enum AssertionsEntryPointType { 17 | STANDARD("Assertions.java"), 18 | BDD("BddAssertions.java"), 19 | SOFT("SoftAssertions.java"), 20 | JUNIT_SOFT("JUnitSoftAssertions.java"), 21 | BDD_SOFT("BDDSoftAssertions.java"), 22 | JUNIT_BDD_SOFT("JUnitBDDSoftAssertions.java"), 23 | AUTO_CLOSEABLE_SOFT("AutoCloseableSoftAssertions.java"), 24 | AUTO_CLOSEABLE_BDD_SOFT("AutoCloseableBDDSoftAssertions.java"); 25 | 26 | private String fileName; 27 | 28 | AssertionsEntryPointType(String fileName) { 29 | this.fileName = fileName; 30 | } 31 | 32 | public String getFileName() { 33 | return fileName; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/GenerateAssertion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator; 14 | 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.RetentionPolicy; 17 | 18 | /** 19 | * Use this annotation to tell the generator to generate assertions for the annotated elements, you can annotate public 20 | * methods or classes, if used on a class all public methods are selected for assertions generation. 21 | *

22 | * In the following example, assertions will be generated for thisIsAProperty, anotherProperty and getStuff 23 | * (standard getter): 24 | *


25 |  * public class AnnotatedClass {
26 |  *
27 |  *  {@literal @}GenerateAssertion
28 |  *   public boolean thisIsAProperty() {
29 |  *     return false;
30 |  *   }
31 |  *
32 |  *   public boolean thisIsNotAProperty() {
33 |  *     return false;
34 |  *   }
35 |  *
36 |  *   public boolean getStuff() {
37 |  *   return false;
38 |  *   }
39 |  *
40 |  *  {@literal @}GenerateAssertion
41 |  *   public Object anotherProperty() {
42 |  *     return null;
43 |  *   }
44 |  * }
45 | * In the next example, assertions will be generated for all methods 46 | * (standard getter): 47 | *
  {@literal @}GenerateAssertion
48 |  * public class AnnotatedClass {
49 |  *
50 |  *   public boolean thisIsAProperty() {
51 |  *     return false;
52 |  *   }
53 |  *
54 |  *   public boolean getStuff() {
55 |  *   return false;
56 |  *   }
57 |  *
58 |  *   public Object anotherProperty() {
59 |  *     return null;
60 |  *   }
61 |  * }
62 | */ 63 | @Retention(RetentionPolicy.RUNTIME) 64 | public @interface GenerateAssertion { 65 | } 66 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/TemplateRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator; 14 | 15 | import java.util.HashMap; 16 | 17 | import org.apache.commons.lang3.Validate; 18 | 19 | @SuppressWarnings("serial") 20 | public class TemplateRegistry extends HashMap { 21 | 22 | public void register(Template template) { 23 | checkTemplateParameter(template); 24 | 25 | super.put(template.getType(), template); 26 | } 27 | 28 | public Template getTemplate(Template.Type templateType) { 29 | return super.get(templateType); 30 | } 31 | 32 | private static void checkTemplateParameter(Template assertionClassTemplate) { 33 | Validate.notNull(assertionClassTemplate, "Expecting a non null Template"); 34 | Validate.notNull(assertionClassTemplate.getContent(), "Expecting a non null content in the Template"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/description/FieldDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.description; 14 | 15 | import com.google.common.reflect.TypeToken; 16 | import org.assertj.assertions.generator.util.ClassUtil; 17 | 18 | import java.lang.reflect.Field; 19 | 20 | import static org.apache.commons.lang3.StringUtils.capitalize; 21 | import static org.assertj.assertions.generator.util.ClassUtil.propertyNameOf; 22 | 23 | /** 24 | * Stores the information needed to generate an assertion for a field. 25 | *

26 | * Let's say we have the following method in class Person : 27 | * 28 | *

29 |  * public int age
30 |  * 
31 | *

32 | * To generate PersonAssert hasAge(int expectedAge) assertion in PersonAssert, we 33 | * need to know : 34 | *

39 | * This class is immutable. 40 | * 41 | * @author Joel Costigliola 42 | */ 43 | public class FieldDescription extends DataDescription implements Comparable { 44 | 45 | public FieldDescription(Field field, TypeToken owningType) { 46 | this(field, Visibility.PUBLIC, owningType); 47 | } 48 | 49 | public FieldDescription(Field field, Visibility visibility, TypeToken owningType) { 50 | super(propertyNameOf(field), field, visibility, owningType.resolveType(field.getGenericType()), owningType); 51 | } 52 | 53 | @Override 54 | public int compareTo(FieldDescription other) { 55 | return super.compareTo(other); 56 | } 57 | 58 | @Override 59 | public Field getOriginalMember() { 60 | return (Field) super.getOriginalMember(); 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return "FieldDescription[originalMember=" + originalMember + ", valueType=" + valueType + ", visibility=" 66 | + visibility + ']'; 67 | } 68 | 69 | @Override 70 | public boolean isPredicate() { 71 | return ClassUtil.isBoolean(valueType); 72 | } 73 | 74 | @Override 75 | public String getPredicate() { 76 | return hasNegativePredicate() ? originalMember.getName() : "is" + capitalize(originalMember.getName()); 77 | } 78 | 79 | @Override 80 | public String getNegativePredicate() { 81 | return !hasNegativePredicate() ? "isNot" + capitalize(originalMember.getName()) : super.getNegativePredicate(); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/description/GetterDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.description; 14 | 15 | import com.google.common.collect.ImmutableList; 16 | import com.google.common.reflect.Invokable; 17 | import com.google.common.reflect.TypeToken; 18 | 19 | import java.lang.reflect.Method; 20 | 21 | import static org.assertj.assertions.generator.util.ClassUtil.isBoolean; 22 | import static org.assertj.assertions.generator.util.ClassUtil.isValidPredicateName; 23 | 24 | /** 25 | * Stores the information needed to generate an assertion for a public getter method. 26 | *

27 | * Let's say we have the following method in class Person : 28 | * 29 | *

30 |  * public int getAge()
31 |  * 
32 | *

33 | * To generate PersonAssert hasAge(int expectedAge) assertion in PersonAssert, we 34 | * need to know : 35 | *

39 | * Note that Person doesn't need to have an age field, just the getAge method. 40 | *

41 | * 42 | * @author Joel Costigliola 43 | * 44 | */ 45 | public class GetterDescription extends DataDescription implements Comparable { 46 | 47 | private final Invokable invokable; 48 | private final ImmutableList> exceptions; 49 | 50 | public GetterDescription(String propertyName, TypeToken owningType, Method method) { 51 | super(propertyName, method, Visibility.PUBLIC, owningType.method(method).getReturnType(), owningType); 52 | this.invokable = owningType.method(method); 53 | this.exceptions = invokable.getExceptionTypes(); 54 | } 55 | 56 | @Override 57 | public Method getOriginalMember() { 58 | return (Method) super.getOriginalMember(); 59 | } 60 | 61 | @Override 62 | public int compareTo(GetterDescription other) { 63 | return super.compareTo(other); 64 | } 65 | 66 | public ImmutableList> getExceptions() { 67 | return exceptions; 68 | } 69 | 70 | @Override 71 | public boolean isPredicate() { 72 | return isBoolean(valueType) && isValidPredicateName(originalMember.getName()); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/description/Visibility.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.description; 14 | 15 | public enum Visibility { 16 | PUBLIC, PROTECTED, PACKAGE, PRIVATE 17 | } 18 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/description/converter/AnnotationConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.description.converter; 14 | 15 | import java.util.Set; 16 | 17 | import com.google.common.collect.Sets; 18 | 19 | /** 20 | * Defines which annotations to use to annotate getters method or class to generate assertions for. 21 | * 22 | * @see org.assertj.assertions.generator.GenerateAssertion 23 | */ 24 | public class AnnotationConfiguration { 25 | 26 | private final Set> includedAnnotations; 27 | 28 | public AnnotationConfiguration(Set> includedAnnotations) { 29 | this.includedAnnotations = includedAnnotations; 30 | } 31 | 32 | public AnnotationConfiguration(Class... includedAnnotations) { 33 | this.includedAnnotations = Sets.newHashSet(includedAnnotations); 34 | } 35 | 36 | public Set> includedAnnotations() { 37 | return includedAnnotations; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/description/converter/ClassDescriptionConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.description.converter; 14 | 15 | import org.assertj.assertions.generator.description.ClassDescription; 16 | 17 | /** 18 | * 19 | * General contract to convert an object to a {@link ClassDescription}. 20 | * 21 | * @param the valueType to convert to {@link ClassDescription}. 22 | * @author Joel Costigliola 23 | * 24 | */ 25 | public interface ClassDescriptionConverter { 26 | 27 | /** 28 | * Convert T instance to a {@link ClassDescription} instance. 29 | * @param instance to convert to a {@link ClassDescription} instance. 30 | * @return the {@link ClassDescription} instance from given T instance. 31 | */ 32 | ClassDescription convertToClassDescription(T instance); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /assertj-generator/src/main/java/org/assertj/assertions/generator/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.util; 14 | 15 | import com.google.common.base.CaseFormat; 16 | 17 | public class StringUtil { 18 | 19 | public static String camelCaseToWords(String camelCaseString) { 20 | return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, camelCaseString).replace('_', ' '); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/assemblies/unix-assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | unix 4 | 5 | 6 | zip 7 | 8 | 9 | 10 | 11 | 12 | true 13 | lib 14 | false 15 | 16 | 17 | 18 | 19 | 20 | 21 | ${project.basedir}/src/main/resources/scripts 22 | 23 | 24 | *.sh 25 | 26 | 0777 27 | 0755 28 | 29 | 30 | ${project.basedir}/src/main/resources/templates 31 | templates 32 | 33 | *template*.txt 34 | 35 | 0666 36 | 0755 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/assemblies/windows-assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | windows 4 | 5 | 6 | zip 7 | 8 | 9 | 10 | 11 | 12 | true 13 | lib 14 | false 15 | 16 | 17 | 18 | 19 | 20 | 21 | ${project.basedir}/src/main/resources/scripts 22 | 23 | 24 | *.bat 25 | 26 | 0777 27 | 0755 28 | 29 | 30 | ${project.basedir}/src/main/resources/templates 31 | templates 32 | 33 | *template*.txt 34 | 35 | 0666 36 | 0755 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/scripts/generate-assertions.bat: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Fest Assertions generator Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a Java home dir 25 | @REM 26 | @REM ---------------------------------------------------------------------------- 27 | 28 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 29 | @echo off 30 | 31 | @REM set %HOME% to equivalent of $HOME 32 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 33 | 34 | @REM ==== START VALIDATION ==== 35 | if not "%JAVA_HOME%" == "" goto OkJHome 36 | 37 | echo. 38 | echo ERROR: JAVA_HOME not found in your environment. 39 | echo Please set the JAVA_HOME variable in your environment to match the 40 | echo location of your Java installation 41 | echo. 42 | goto error 43 | 44 | :OkJHome 45 | if exist "%JAVA_HOME%\bin\java.exe" goto runGenerator 46 | 47 | echo. 48 | echo ERROR: JAVA_HOME is set to an invalid directory. 49 | echo JAVA_HOME = "%JAVA_HOME%" 50 | echo Please set the JAVA_HOME variable in your environment to match the 51 | echo location of your Java installation 52 | echo. 53 | goto error 54 | 55 | @REM ==== END VALIDATION ==== 56 | 57 | 58 | @REM Start generator 59 | :runGenerator 60 | SET JAVA_EXE="%JAVA_HOME%\bin\java.exe" 61 | set CMD_LINE_ARGS=%* 62 | 63 | %JAVA_EXE% -classpath ".;lib/*" org.assertj.assertions.generator.cli.AssertionGeneratorLauncher %CMD_LINE_ARGS% 64 | if ERRORLEVEL 1 goto error 65 | goto end 66 | 67 | :error 68 | echo Failed to execute Fest Assertions Generator 69 | 70 | :end 71 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/auto_closeable_bdd_soft_assertions_entry_point_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * A version of {@link BDDSoftAssertions} that uses try-with-resources statement to automatically call 5 | * {@link BDDSoftAssertions#assertAll()} so that you don't forget to. 6 | *

7 | * Example: 8 | *

 public class AutoCloseableBDDSoftAssertionsTest {
 9 |  * 
10 |  * @Test
11 |  * public void host_dinner_party_where_nobody_dies() {
12 |  *   Mansion mansion = new Mansion();
13 |  * 
14 |  *   mansion.hostPotentiallyMurderousDinnerParty();
15 |  * 
16 |  *   try (AutoCloseableBDDSoftAssertions softly = new AutoCloseableBDDSoftAssertions()) {
17 |  *     softly.then(mansion.guests()).as("Living Guests").isEqualTo(7);
18 |  *     softly.then(mansion.kitchen()).as("Kitchen").isEqualTo("clean");
19 |  *     // no need to call assertAll, it is done when softly is closed.
20 |  *   }
21 |  * }
22 |  * 
23 | */ 24 | public class AutoCloseableBDDSoftAssertions extends org.assertj.core.api.BDDSoftAssertions implements AutoCloseable { 25 | ${all_assertions_entry_points} 26 | @Override 27 | public void close() throws SoftAssertionError { 28 | assertAll(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/auto_closeable_soft_assertions_entry_point_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * A version of {@link SoftAssertions} that uses try-with-resources statement to automatically call 5 | * {@link SoftAssertions#assertAll()} so that you don't forget to. 6 | *

7 | * Example: 8 | *

 public class AutoCloseableSoftAssertionsTest {
 9 |  * 
10 |  * @Test
11 |  * public void host_dinner_party_where_nobody_dies() {
12 |  *   Mansion mansion = new Mansion();
13 |  *   mansion.hostPotentiallyMurderousDinnerParty();
14 |  *   try (AutoCloseableSoftAssertions softly = new AutoCloseableSoftAssertions()) {
15 |  *      softly.assertThat(mansion.guests()).as("Living Guests").isEqualTo(7);
16 |  *      softly.assertThat(mansion.kitchen()).as("Kitchen").isEqualTo("clean");
17 |  *      // no need to call assertAll, it is done when softly is closed.
18 |  *   }
19 |  * }
20 |  * 
21 | */ 22 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 23 | public class AutoCloseableSoftAssertions extends org.assertj.core.api.SoftAssertions implements AutoCloseable { 24 | ${all_assertions_entry_points} 25 | @Override 26 | public void close() throws org.assertj.core.api.SoftAssertionError { 27 | assertAll(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/bdd_assertion_entry_point_method_template.txt: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new instance of {@link ${custom_assertion_class}}. 3 | * 4 | * @param actual the actual value. 5 | * @return the created assertion object. 6 | */ 7 | @org.assertj.core.util.CheckReturnValue 8 | public static ${custom_assertion_class} then(${class_to_assert} actual) { 9 | return new ${custom_assertion_class}(actual); 10 | } 11 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/bdd_assertions_entry_point_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * Entry point for BDD assertions of different data types. 5 | */ 6 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 7 | public class BddAssertions { 8 | ${all_assertions_entry_points} 9 | /** 10 | * Creates a new {@link BddAssertions}. 11 | */ 12 | protected BddAssertions() { 13 | // empty 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/bdd_soft_assertion_entry_point_method_template.txt: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new "soft" instance of {@link ${custom_assertion_class}}. 3 | * 4 | * @param actual the actual value. 5 | * @return the created "soft" assertion object. 6 | */ 7 | @org.assertj.core.util.CheckReturnValue 8 | public ${custom_assertion_class} then(${class_to_assert} actual) { 9 | return proxy(${custom_assertion_class}.class, ${class_to_assert}.class, actual); 10 | } 11 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/bdd_soft_assertions_entry_point_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * Entry point for BDD soft assertions of different data types. 5 | */ 6 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 7 | public class BDDSoftAssertions extends org.assertj.core.api.BDDSoftAssertions { 8 | ${all_assertions_entry_points} 9 | } 10 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/custom_abstract_assertion_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | ${imports} 3 | /** 4 | * Abstract base class for {@link ${class_to_assert}} specific assertions - Generated by CustomAssertionGenerator. 5 | */ 6 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 7 | public abstract class ${custom_assertion_class}, A extends ${class_to_assert}> extends ${super_assertion_class} { 8 | 9 | /** 10 | * Creates a new {@link ${custom_assertion_class}} to make assertions on actual ${class_to_assert}. 11 | * @param actual the ${class_to_assert} we want to make assertions on. 12 | */ 13 | protected ${custom_assertion_class}(A actual, Class selfType) { 14 | super(actual, selfType); 15 | } 16 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/custom_assertion_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | ${imports} 3 | /** 4 | * {@link ${class_to_assert}} specific assertions - Generated by CustomAssertionGenerator. 5 | */ 6 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 7 | public class ${custom_assertion_class} extends AbstractObjectAssert<${custom_assertion_class}, ${class_to_assert}> { 8 | 9 | /** 10 | * Creates a new {@link ${custom_assertion_class}} to make assertions on actual ${class_to_assert}. 11 | * @param actual the ${class_to_assert} we want to make assertions on. 12 | */ 13 | public ${custom_assertion_class}(${class_to_assert} actual) { 14 | super(actual, ${custom_assertion_class}.class); 15 | } 16 | 17 | /** 18 | * An entry point for ${custom_assertion_class} to follow AssertJ standard assertThat() statements.
19 | * With a static import, one can write directly: assertThat(my${class_to_assert}) and get specific assertion with code completion. 20 | * @param actual the ${class_to_assert} we want to make assertions on. 21 | * @return a new {@link ${custom_assertion_class}} 22 | */ 23 | @org.assertj.core.util.CheckReturnValue 24 | public static ${custom_assertion_class} assertThat(${class_to_assert} actual) { 25 | return new ${custom_assertion_class}(actual); 26 | } 27 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/custom_hierarchical_assertion_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | ${imports} 3 | /** 4 | * {@link ${class_to_assert}} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link Abstract${custom_assertion_class}} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class ${custom_assertion_class} extends Abstract${custom_assertion_class}<${custom_assertion_class}, ${class_to_assert}> { 11 | 12 | /** 13 | * Creates a new {@link ${custom_assertion_class}} to make assertions on actual ${class_to_assert}. 14 | * @param actual the ${class_to_assert} we want to make assertions on. 15 | */ 16 | public ${custom_assertion_class}(${class_to_assert} actual) { 17 | super(actual, ${custom_assertion_class}.class); 18 | } 19 | 20 | /** 21 | * An entry point for ${custom_assertion_class} to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(my${class_to_assert}) and get specific assertion with code completion. 23 | * @param actual the ${class_to_assert} we want to make assertions on. 24 | * @return a new {@link ${custom_assertion_class}} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static ${custom_assertion_class} assertThat(${class_to_assert} actual) { 28 | return new ${custom_assertion_class}(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // null safe check 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (!Objects.deepEquals(actual${Property}, ${property_safe})) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template_for_char.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // check ${property} char matches 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (actual${Property} != ${property_safe}) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template_for_character.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // null safe check 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (!Objects.deepEquals(actual${Property}, ${property_safe})) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template_for_primitive.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // check 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (actual${Property} != ${property_safe}) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template_for_primitive_wrapper.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // null safe check 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (!Objects.deepEquals(actual${Property}, ${property_safe})) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template_for_real_number.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // check value for ${property} 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (actual${Property} != ${property_safe}) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } 24 | 25 | /** 26 | * Verifies that the actual ${class_to_assert}'s ${property} is close to the given value by less than the given offset. 27 | *

28 | * If difference is equal to the offset value, assertion is considered successful. 29 | * @param ${property_safe} the value to compare the actual ${class_to_assert}'s ${property} to. 30 | * @param assertjOffset the given offset. 31 | * @return this assertion object. 32 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not close enough to the given value.${throws_javadoc} 33 | */ 34 | public ${self_type} has${Property}CloseTo(${propertyType} ${property_safe}, ${propertyType} assertjOffset) ${throws}{ 35 | // check that actual ${class_to_assert} we want to make assertions on is not null. 36 | isNotNull(); 37 | 38 | ${propertyType} actual${Property} = actual.${getter}(); 39 | 40 | // overrides the default error message with a more explicit one 41 | String assertjErrorMessage = String.format("\nExpecting ${property}:\n <%s>\nto be close to:\n <%s>\nby less than <%s> but difference was <%s>", 42 | actual${Property}, ${property_safe}, assertjOffset, Math.abs(${property_safe} - actual${Property})); 43 | 44 | // check 45 | Assertions.assertThat(actual${Property}).overridingErrorMessage(assertjErrorMessage).isCloseTo(${property_safe}, Assertions.within(assertjOffset)); 46 | 47 | // return the current assertion for method chaining 48 | return ${myself}; 49 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template_for_real_number_wrapper.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // null safe check 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (!Objects.deepEquals(actual${Property}, ${property_safe})) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } 24 | 25 | /** 26 | * Verifies that the actual ${class_to_assert}'s ${property} is close to the given value by less than the given offset. 27 | *

28 | * If difference is equal to the offset value, assertion is considered successful. 29 | * @param ${property_safe} the value to compare the actual ${class_to_assert}'s ${property} to. 30 | * @param assertjOffset the given offset. 31 | * @return this assertion object. 32 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not close enough to the given value.${throws_javadoc} 33 | */ 34 | public ${self_type} has${Property}CloseTo(${propertyType} ${property_safe}, ${propertyType} assertjOffset) ${throws}{ 35 | // check that actual ${class_to_assert} we want to make assertions on is not null. 36 | isNotNull(); 37 | 38 | ${propertyType} actual${Property} = actual.${getter}(); 39 | 40 | // overrides the default error message with a more explicit one 41 | String assertjErrorMessage = String.format("\nExpecting ${property}:\n <%s>\nto be close to:\n <%s>\nby less than <%s> but difference was <%s>", 42 | actual${Property}, ${property_safe}, assertjOffset, Math.abs(${property_safe} - actual${Property})); 43 | 44 | // check 45 | Assertions.assertThat(actual${Property}).overridingErrorMessage(assertjErrorMessage).isCloseTo(${property_safe}, Assertions.within(assertjOffset)); 46 | 47 | // return the current assertion for method chaining 48 | return ${myself}; 49 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template_for_whole_number.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // check 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (actual${Property} != ${property_safe}) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/has_assertion_template_for_whole_number_wrapper.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | // overrides the default error message with a more explicit one 13 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 14 | 15 | // null safe check 16 | ${propertyType} actual${Property} = actual.${getter}(); 17 | if (!Objects.deepEquals(actual${Property}, ${property_safe})) { 18 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 19 | } 20 | 21 | // return the current assertion for method chaining 22 | return ${myself}; 23 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/is_assertion_template.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert} ${predicate_for_javadoc}. 4 | * @return this assertion object. 5 | * @throws AssertionError - if the actual ${class_to_assert} ${negative_predicate_for_javadoc}.${throws_javadoc} 6 | */ 7 | public ${self_type} ${predicate}() ${throws}{ 8 | // check that actual ${class_to_assert} we want to make assertions on is not null. 9 | isNotNull(); 10 | 11 | // check that property call/field access is true 12 | if (!actual.${predicate}()) { 13 | failWithMessage("\nExpecting that actual ${class_to_assert} ${predicate_for_error_message_part1} but ${predicate_for_error_message_part2}."); 14 | } 15 | 16 | // return the current assertion for method chaining 17 | return ${myself}; 18 | } 19 | 20 | /** 21 | * Verifies that the actual ${class_to_assert} ${negative_predicate_for_javadoc}. 22 | * @return this assertion object. 23 | * @throws AssertionError - if the actual ${class_to_assert} ${predicate_for_javadoc}.${throws_javadoc} 24 | */ 25 | public ${self_type} ${neg_predicate}() ${throws}{ 26 | // check that actual ${class_to_assert} we want to make assertions on is not null. 27 | isNotNull(); 28 | 29 | // check that property call/field access is false 30 | if (actual.${predicate}()) { 31 | failWithMessage("\nExpecting that actual ${class_to_assert} ${negative_predicate_for_error_message_part1} but ${negative_predicate_for_error_message_part2}."); 32 | } 33 | 34 | // return the current assertion for method chaining 35 | return ${myself}; 36 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/is_without_negative_assertion_template.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert} ${predicate_for_javadoc}. 4 | * @return this assertion object. 5 | * @throws AssertionError - if the actual ${class_to_assert} ${negative_predicate_for_javadoc}.${throws_javadoc} 6 | */ 7 | public ${self_type} ${predicate}() ${throws}{ 8 | // check that actual ${class_to_assert} we want to make assertions on is not null. 9 | isNotNull(); 10 | 11 | // check 12 | if (!actual.${predicate}()) { 13 | failWithMessage("\nExpecting that actual ${class_to_assert} ${predicate_for_error_message_part1} but ${predicate_for_error_message_part2}."); 14 | } 15 | 16 | // return the current assertion for method chaining 17 | return ${myself}; 18 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/is_wrapper_assertion_template.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert} ${predicate_for_javadoc}. 4 | * @return this assertion object. 5 | * @throws AssertionError - if the actual ${class_to_assert} ${negative_predicate_for_javadoc}.${throws_javadoc} 6 | */ 7 | public ${self_type} ${predicate}() ${throws}{ 8 | // check that actual ${class_to_assert} we want to make assertions on is not null. 9 | isNotNull(); 10 | 11 | // null safe check 12 | if (Objects.deepEquals(Boolean.FALSE, actual.${predicate}())) { 13 | failWithMessage("\nExpecting that actual ${class_to_assert} ${predicate_for_error_message_part1} but ${predicate_for_error_message_part2}."); 14 | } 15 | 16 | // return the current assertion for method chaining 17 | return ${myself}; 18 | } 19 | 20 | /** 21 | * Verifies that the actual ${class_to_assert} ${negative_predicate_for_javadoc}. 22 | * @return this assertion object. 23 | * @throws AssertionError - if the actual ${class_to_assert} ${predicate_for_javadoc}.${throws_javadoc} 24 | */ 25 | public ${self_type} ${neg_predicate}() ${throws}{ 26 | // check that actual ${class_to_assert} we want to make assertions on is not null. 27 | isNotNull(); 28 | 29 | // null safe check 30 | if (Objects.deepEquals(Boolean.TRUE, actual.${predicate}())) { 31 | failWithMessage("\nExpecting that actual ${class_to_assert} ${negative_predicate_for_error_message_part1} but ${negative_predicate_for_error_message_part2}."); 32 | } 33 | 34 | // return the current assertion for method chaining 35 | return ${myself}; 36 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/is_wrapper_without_negative_assertion_template.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert} ${predicate_for_javadoc}. 4 | * @return this assertion object. 5 | * @throws AssertionError - if the actual ${class_to_assert} ${negative_predicate_for_javadoc}.${throws_javadoc} 6 | */ 7 | public ${self_type} ${predicate}() ${throws}{ 8 | // check that actual ${class_to_assert} we want to make assertions on is not null. 9 | isNotNull(); 10 | 11 | // null safe check 12 | if (Objects.deepEquals(Boolean.FALSE, actual.${predicate}())) { 13 | failWithMessage("\nExpecting that actual ${class_to_assert} ${predicate_for_error_message_part1} but ${predicate_for_error_message_part2}."); 14 | } 15 | 16 | // return the current assertion for method chaining 17 | return ${myself}; 18 | } -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/junit_bdd_soft_assertions_entry_point_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * Like {@link BDDSoftAssertions} but as a junit rule that takes care of calling 5 | * {@link SoftAssertions#assertAll() assertAll()} at the end of each test. 6 | *

7 | * Example: 8 | *

 public class SoftlyTest {
 9 |  *
10 |  *     @Rule
11 |  *     public final JUnitBDDSoftAssertions softly = new JUnitBDDSoftAssertions();
12 |  *
13 |  *     @Test
14 |  *     public void soft_bdd_assertions() throws Exception {
15 |  *       softly.then(1).isEqualTo(2);
16 |  *       softly.then(Lists.newArrayList(1, 2)).containsOnly(1, 2);
17 |  *       // no need to call assertAll(), this is done automatically.
18 |  *     }
19 |  *  }
20 | */ 21 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 22 | public class JUnitBDDSoftAssertions extends org.assertj.core.api.JUnitBDDSoftAssertions { 23 | ${all_assertions_entry_points} 24 | } 25 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/junit_soft_assertions_entry_point_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * Like {@link SoftAssertions} but as a junit rule that takes care of calling 5 | * {@link SoftAssertions#assertAll() assertAll()} at the end of each test. 6 | *

7 | * Example: 8 | *

 public class SoftlyTest {
 9 |  *
10 |  *     @Rule
11 |  *     public final JUnitBDDSoftAssertions softly = new JUnitBDDSoftAssertions();
12 |  *
13 |  *     @Test
14 |  *     public void soft_bdd_assertions() throws Exception {
15 |  *       softly.assertThat(1).isEqualTo(2);
16 |  *       softly.assertThat(Lists.newArrayList(1, 2)).containsOnly(1, 2);
17 |  *       // no need to call assertAll(), this is done automatically.
18 |  *     }
19 |  *  }
20 | */ 21 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 22 | public class JUnitSoftAssertions extends org.assertj.core.api.JUnitSoftAssertions { 23 | ${all_assertions_entry_points} 24 | } 25 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/soft_assertion_entry_point_method_template.txt: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new "soft" instance of {@link ${custom_assertion_class}}. 3 | * 4 | * @param actual the actual value. 5 | * @return the created "soft" assertion object. 6 | */ 7 | @org.assertj.core.util.CheckReturnValue 8 | public ${custom_assertion_class} assertThat(${class_to_assert} actual) { 9 | return proxy(${custom_assertion_class}.class, ${class_to_assert}.class, actual); 10 | } 11 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/soft_assertions_entry_point_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * Entry point for soft assertions of different data types. 5 | */ 6 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 7 | public class SoftAssertions extends org.assertj.core.api.SoftAssertions { 8 | ${all_assertions_entry_points} 9 | } 10 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/standard_assertion_entry_point_method_template.txt: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new instance of {@link ${custom_assertion_class}}. 3 | * 4 | * @param actual the actual value. 5 | * @return the created assertion object. 6 | */ 7 | @org.assertj.core.util.CheckReturnValue 8 | public static ${custom_assertion_class} assertThat(${class_to_assert} actual) { 9 | return new ${custom_assertion_class}(actual); 10 | } 11 | -------------------------------------------------------------------------------- /assertj-generator/src/main/resources/templates/standard_assertions_entry_point_class_template.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * Entry point for assertions of different data types. Each method in this class is a static factory for the 5 | * type-specific assertion objects. 6 | */ 7 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 8 | public class Assertions { 9 | ${all_assertions_entry_points} 10 | /** 11 | * Creates a new {@link Assertions}. 12 | */ 13 | protected Assertions() { 14 | // empty 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /assertj-generator/src/main/scripts/build.gradle: -------------------------------------------------------------------------------- 1 | // use assertj generator from gradle example 2 | 3 | def assertjOutput = file('src-gen/test/java') 4 | 5 | configurations { 6 | assertj 7 | } 8 | 9 | dependencies { 10 | testCompile 'org.assertj:assertj-core:3.2.0' 11 | 12 | assertj 'org.assertj:assertj-assertions-generator:2.0.0' 13 | assertj project(':bacsapp:metadata') 14 | } 15 | 16 | sourceSets { 17 | test { 18 | java { 19 | srcDir 'src/test/java' 20 | srcDir 'src-gen/test/java' 21 | } 22 | } 23 | } 24 | 25 | task assertjClean(type: Delete) { 26 | delete assertjOutput 27 | } 28 | 29 | task assertjGen(dependsOn: assertjClean, type: JavaExec) { 30 | doFirst { 31 | if (!assertjOutput.exists()) { 32 | logger.info("Creating `$assertjOutput` directory") 33 | 34 | if (!assertjOutput.mkdirs()) { 35 | throw new InvalidUserDataException("Unable to create `$assertjOutput` directory") 36 | } 37 | } 38 | } 39 | 40 | main 'org.assertj.assertions.generator.cli.AssertionGeneratorLauncher' 41 | classpath = files(configurations.assertj) 42 | workingDir = assertjOutput 43 | args = [ 44 | // TODO: instear FQCN or FQPN 45 | ] 46 | } 47 | 48 | compileTestJava.dependsOn(assertjGen) -------------------------------------------------------------------------------- /assertj-generator/src/test/java/my/assertions/OuterClassStaticNestedPersonAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package my.assertions; 14 | 15 | import java.util.Objects; 16 | import org.assertj.assertions.generator.data.OuterClass; 17 | import org.assertj.core.api.AbstractObjectAssert; 18 | 19 | /** 20 | * this class was generated but kep in source control to see what was needed in term of import when dealing with nested classes 21 | */ 22 | @javax.annotation.processing.Generated(value = "assertj-assertions-generator") 23 | public class OuterClassStaticNestedPersonAssert 24 | extends AbstractObjectAssert { 25 | 26 | /** 27 | * Creates a new {@link OuterClassStaticNestedPersonAssert} to make assertions on actual OuterClass.StaticNestedPerson. 28 | * @param actual the OuterClass.StaticNestedPerson we want to make assertions on. 29 | */ 30 | public OuterClassStaticNestedPersonAssert(OuterClass.StaticNestedPerson actual) { 31 | super(actual, OuterClassStaticNestedPersonAssert.class); 32 | } 33 | 34 | /** 35 | * An entry point for OuterClassStaticNestedPersonAssert to follow AssertJ standard assertThat() statements.
36 | * With a static import, one can write directly: assertThat(myOuterClass.StaticNestedPerson) and get specific assertion with code completion. 37 | * @param actual the OuterClass.StaticNestedPerson we want to make assertions on. 38 | * @return a new {@link OuterClassStaticNestedPersonAssert} 39 | */ 40 | @org.assertj.core.util.CheckReturnValue 41 | public static OuterClassStaticNestedPersonAssert assertThat(OuterClass.StaticNestedPerson actual) { 42 | OuterClass.StaticNestedPerson.SNP_InnerPerson d = null; 43 | OuterClass.StaticNestedPerson.SNP_StaticNestedPerson f = null; 44 | return new OuterClassStaticNestedPersonAssert(actual); 45 | } 46 | 47 | /** 48 | * Verifies that the actual OuterClass.StaticNestedPerson's name is equal to the given one. 49 | * @param name the given name to compare the actual OuterClass.StaticNestedPerson's name to. 50 | * @return this assertion object. 51 | * @throws AssertionError - if the actual OuterClass.StaticNestedPerson's name is not equal to the given one. 52 | */ 53 | public OuterClassStaticNestedPersonAssert hasName(String name) { 54 | // check that actual OuterClass.StaticNestedPerson we want to make assertions on is not null. 55 | isNotNull(); 56 | 57 | // overrides the default error message with a more explicit one 58 | String assertjErrorMessage = "\nExpecting name of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 59 | 60 | // null safe check 61 | String actualName = actual.getName(); 62 | if (!Objects.deepEquals(actualName, name)) { 63 | failWithMessage(assertjErrorMessage, actual, name, actualName); 64 | } 65 | 66 | // return the current assertion for method chaining 67 | return this; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/AssertionGeneratorOverrideTemplateTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator; 14 | 15 | import org.assertj.assertions.generator.data.cars.Car; 16 | import org.assertj.assertions.generator.description.converter.ClassToClassDescriptionConverter; 17 | import org.junit.jupiter.api.BeforeEach; 18 | import org.junit.jupiter.api.Test; 19 | import org.junit.jupiter.api.io.TempDir; 20 | 21 | import java.io.File; 22 | import java.io.IOException; 23 | import java.nio.file.Path; 24 | import java.nio.file.Paths; 25 | 26 | import static org.assertj.assertions.generator.Template.Type.ABSTRACT_ASSERT_CLASS; 27 | import static org.assertj.core.api.Assertions.assertThat; 28 | import static org.assertj.core.api.Assertions.assertThatNullPointerException; 29 | import static org.assertj.core.api.Assertions.assertThatRuntimeException; 30 | 31 | class AssertionGeneratorOverrideTemplateTest { 32 | 33 | private BaseAssertionGenerator assertionGenerator; 34 | private ClassToClassDescriptionConverter converter; 35 | private GenerationHandler genHandle; 36 | 37 | @BeforeEach 38 | void before(@TempDir Path tempDir) throws IOException { 39 | assertionGenerator = new BaseAssertionGenerator(); 40 | assertionGenerator.setDirectoryWhereAssertionFilesAreGenerated(tempDir.toFile()); 41 | converter = new ClassToClassDescriptionConverter(); 42 | genHandle = new GenerationHandler(tempDir, Paths.get("src/test/resources")); 43 | } 44 | 45 | @Test 46 | void should_fail_if_custom_template_is_null() { 47 | assertThatNullPointerException().isThrownBy(() -> assertionGenerator.register(null)); 48 | } 49 | 50 | @Test 51 | void should_fail_if_custom_template_content_is_null() { 52 | assertThatNullPointerException().isThrownBy(() -> assertionGenerator.register(new Template(ABSTRACT_ASSERT_CLASS, (File) null))); 53 | } 54 | 55 | @Test 56 | void should_fail_if_custom_template_content_cant_be_read() { 57 | assertThatRuntimeException().isThrownBy(() -> assertionGenerator.register(new Template(ABSTRACT_ASSERT_CLASS, new File("not_existing.template")))); 58 | } 59 | 60 | @Test 61 | void should_generate_assertion_with_custom_template() throws IOException { 62 | assertionGenerator.register(new Template(Template.Type.HAS_FOR_WHOLE_NUMBER, 63 | new File("customtemplates" + File.separator, 64 | "custom_has_assertion_template_for_whole_number.txt"))); 65 | 66 | assertionGenerator.generateCustomAssertionFor(converter.convertToClassDescription(Car.class)); 67 | File expectedFile = genHandle.getResourcesDir().resolve("CarAssert.expected.txt").toAbsolutePath().toFile(); 68 | File actualFile = genHandle.fileGeneratedFor(Car.class); 69 | // compile it! 70 | genHandle.compileGeneratedFilesFor(Car.class); 71 | 72 | assertThat(actualFile).hasSameTextualContentAs(expectedFile); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/ClassUsingDifferentClassesWithSameName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator; 14 | 15 | // used in test - getters implemntation don't matter 16 | public class ClassUsingDifferentClassesWithSameName { 17 | public org.assertj.assertions.generator.data.nba.team.Team getNbaTeam() { 18 | return null; 19 | } 20 | 21 | public org.assertj.assertions.generator.data.Team getTeam() { 22 | return null; 23 | } 24 | } -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/PlayerAssertTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator; 14 | 15 | // import static org.assertj.assertions.generator.data.PlayerAssert.assertThat; 16 | 17 | import org.junit.jupiter.api.Test; 18 | 19 | public class PlayerAssertTest { 20 | 21 | @Test 22 | void test() { 23 | // uncomment to test 24 | // Player tonyParker = new Player(new Name("Tony", "Parker"), "Spurs"); 25 | // tonyParker.setAssistsPerGame(9); 26 | // tonyParker.setPointsPerGame(21); 27 | // tonyParker.setReboundsPerGame(5); 28 | // tonyParker.setPreviousTeams(new String[] { "paris" }); 29 | // Player tim = new Player(new Name("Tim", "Duncan"), "Spurs"); 30 | // tonyParker.getTeamMates().add(tim); 31 | // 32 | // assertThat(tonyParker).isNotRookie() 33 | // .hasTeam("paris") 34 | // .hasTeamMates(new Player(new Name("Kobe", "Bryant"), "Lakers"), tim) 35 | // .hasTeam("spurs") 36 | // .hasPreviousTeams("paris") 37 | // .hasPointsPerGame(21); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/TemplateTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator; 14 | 15 | import org.junit.jupiter.api.Test; 16 | 17 | import static org.assertj.assertions.generator.BaseAssertionGenerator.TEMPLATES_DIR; 18 | import static org.assertj.assertions.generator.DefaultTemplateRegistryProducer.DEFAULT_HAS_ASSERTION_TEMPLATE; 19 | import static org.assertj.assertions.generator.Template.Type.ASSERT_CLASS; 20 | import static org.assertj.assertions.generator.Template.Type.HAS; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.assertj.core.api.Assertions.fail; 23 | 24 | import java.io.File; 25 | import java.net.URL; 26 | 27 | class TemplateTest { 28 | 29 | @Test 30 | void should_throw_an_exception_when_url_is_a_directory() { 31 | URL templateURL = getClass().getClassLoader().getResource(TEMPLATES_DIR); 32 | try { 33 | new Template(ASSERT_CLASS, templateURL); 34 | fail("A directory url should throw an exception"); 35 | } catch (RuntimeException e) { 36 | assertThat(e).hasMessageStartingWith("Failed to read template from an URL which is not a file"); 37 | } 38 | } 39 | 40 | @Test 41 | void should_create_template_from_url() { 42 | URL templateURL = getClass().getClassLoader().getResource(TEMPLATES_DIR + DEFAULT_HAS_ASSERTION_TEMPLATE); 43 | Template template = new Template(ASSERT_CLASS, templateURL); 44 | assertThat(template.getContent()).isNotEmpty(); 45 | } 46 | 47 | @Test 48 | void should_create_template_from_file() { 49 | File templateFile = new File(TEMPLATES_DIR, DEFAULT_HAS_ASSERTION_TEMPLATE); 50 | Template template = new Template(HAS, templateFile); 51 | assertThat(template.getContent()).isNotEmpty(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/AnnotatedClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | import org.assertj.assertions.generator.GenerateAssertion; 16 | 17 | /** 18 | * class with annotated non standard getters in order to generate assertions for them. 19 | */ 20 | public class AnnotatedClass { 21 | 22 | @GenerateAssertion 23 | public boolean thisIsAProperty() { 24 | return false; 25 | } 26 | 27 | public boolean thisIsNotAProperty() { 28 | return false; 29 | } 30 | 31 | // assertion will be generated as this is a standard getter 32 | public boolean getStuff() { 33 | return false; 34 | } 35 | 36 | @GenerateAssertion 37 | public Object anotherProperty() { 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/AutoValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.RetentionPolicy; 17 | 18 | @Retention(RetentionPolicy.RUNTIME) 19 | public @interface AutoValue { 20 | } 21 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/AutoValueAnnotatedClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | @AutoValue 16 | public class AutoValueAnnotatedClass { 17 | 18 | public boolean thisIsAProperty() { 19 | return false; 20 | } 21 | 22 | // assertion will be generated as this is a standard getter 23 | public boolean getStuff() { 24 | return false; 25 | } 26 | 27 | public Object anotherProperty() { 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/BeanWithOneException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | import java.io.IOException; 16 | import java.util.List; 17 | 18 | /** 19 | * This is a bean whose getters throws one exception. 20 | */ 21 | public class BeanWithOneException { 22 | @SuppressWarnings("unused") 23 | public String getStringPropertyThrowsException() throws IOException { 24 | return null; 25 | } 26 | 27 | @SuppressWarnings("unused") 28 | public boolean isBooleanPropertyThrowsException() throws IOException { 29 | return false; 30 | } 31 | 32 | @SuppressWarnings("unused") 33 | public String[] getArrayPropertyThrowsException() throws IOException { 34 | return null; 35 | } 36 | 37 | @SuppressWarnings("unused") 38 | public List getIterablePropertyThrowsException() throws IOException { 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/BeanWithTwoExceptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | import java.io.IOException; 16 | import java.sql.SQLException; 17 | import java.util.List; 18 | 19 | /** 20 | * This is a bean whose getters throws two exceptions. 21 | */ 22 | public class BeanWithTwoExceptions { 23 | @SuppressWarnings("unused") 24 | public String getStringPropertyThrowsException() throws IOException, SQLException { 25 | return null; 26 | } 27 | 28 | @SuppressWarnings("unused") 29 | public boolean isBooleanPropertyThrowsException() throws IOException, SQLException { 30 | return false; 31 | } 32 | 33 | @SuppressWarnings("unused") 34 | public String[] getArrayPropertyThrowsException() throws IOException, SQLException { 35 | return null; 36 | } 37 | 38 | @SuppressWarnings("unused") 39 | public List getIterablePropertyThrowsException() throws IOException, SQLException { 40 | return null; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/BlockBuster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | import java.util.Date; 16 | 17 | public class BlockBuster extends Movie { 18 | 19 | public BlockBuster(String title, Date releaseDate) { 20 | super(title, releaseDate); 21 | } 22 | 23 | public int numberOfSpectators = 0; 24 | 25 | public int getRevenue() { 26 | return Integer.MAX_VALUE; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/BooleanPredicates.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | /** 16 | * This is a class which has various boolean predicates. 17 | */ 18 | public class BooleanPredicates { 19 | 20 | public boolean bad; 21 | 22 | public boolean isGoodField; 23 | public boolean isGood() { 24 | return true; 25 | } 26 | 27 | public boolean wasGoodField; 28 | public boolean wasGood() { 29 | return true; 30 | } 31 | 32 | public boolean canBeGoodField; 33 | public boolean canBeGood() { 34 | return true; 35 | } 36 | 37 | public boolean shouldBeGoodField; 38 | public boolean shouldBeGood() { 39 | return true; 40 | } 41 | 42 | public boolean willBeGoodField; 43 | public boolean willBeGood() { 44 | return true; 45 | } 46 | 47 | public boolean hasGoodField; 48 | public boolean hasGood() { 49 | return true; 50 | } 51 | 52 | public boolean getGood() { 53 | return true; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/Dollar$.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | // test for https://github.com/joel-costigliola/assertj-assertions-generator/issues/18 16 | public class Dollar$ { 17 | public String test; 18 | 19 | } -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/EnemyReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | public class EnemyReport { 16 | 17 | public String realTarget; 18 | public boolean isTarget; 19 | private String privateTarget; 20 | 21 | public String getTarget() { 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/FieldPropertyClash.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | /** 16 | * This is a class with properties that clash with public fields. 17 | */ 18 | public class FieldPropertyClash { 19 | public String actual; 20 | public String string; 21 | public String getString() { 22 | return ""; 23 | } 24 | 25 | // joel-costigliola/assertj-assertions-generator#105 26 | // Predicate properties were not properly discerned vs non-predicate 27 | public boolean isBoolean; 28 | public boolean isBoolean() { return false; } 29 | 30 | public boolean isNotBoolean() { return false; } 31 | 32 | 33 | public boolean shouldNotBeSomewhere; 34 | public boolean shouldNotBeSomewhere() { return shouldNotBeSomewhere; } 35 | 36 | // different "tenses" 37 | public boolean willBeOutside; 38 | public boolean willNotBeOutside() { return willBeOutside; } 39 | 40 | // 41 | public boolean willNotBeUpsideDown; 42 | public boolean willBeUpsideDown() { return !willNotBeUpsideDown; } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/InterferencePrimitives.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | public class InterferencePrimitives { 16 | 17 | private boolean working; 18 | 19 | private Boolean aBoolean; 20 | 21 | public boolean isWorking() { 22 | return working; 23 | } 24 | 25 | public boolean isNotWorking() { 26 | return !working; 27 | } 28 | 29 | public Boolean isABoolean() { 30 | return aBoolean; 31 | } 32 | 33 | public Boolean isNotABoolean() { 34 | return !aBoolean; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/Movie.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | import org.assertj.assertions.generator.data.art.ArtWork; 16 | 17 | import java.util.Date; 18 | 19 | @SuppressWarnings("unused") 20 | public class Movie extends ArtWork { 21 | 22 | private final Date releaseDate; 23 | private PublicCategory publicCategory; 24 | public String producer; 25 | public double rating; 26 | public boolean xrated; 27 | 28 | public Movie(String title, Date releaseDate) { 29 | super(title); 30 | this.releaseDate = releaseDate; 31 | } 32 | 33 | public Date getReleaseDate() { 34 | return releaseDate; 35 | } 36 | 37 | public PublicCategory getPublicCategory() { 38 | return publicCategory; 39 | } 40 | 41 | @Override 42 | public int hashCode() { 43 | final int prime = 31; 44 | int result = super.hashCode(); 45 | result = prime * result + ((releaseDate == null) ? 0 : releaseDate.hashCode()); 46 | return result; 47 | } 48 | 49 | @Override 50 | public boolean equals(Object obj) { 51 | if (this == obj) 52 | return true; 53 | if (!super.equals(obj)) 54 | return false; 55 | if (getClass() != obj.getClass()) 56 | return false; 57 | Movie other = (Movie) obj; 58 | if (releaseDate == null) { 59 | if (other.releaseDate != null) 60 | return false; 61 | } else if (!releaseDate.equals(other.releaseDate)) 62 | return false; 63 | return true; 64 | } 65 | 66 | public static class PublicCategory { 67 | private String name; 68 | 69 | public PublicCategory(String name) { 70 | super(); 71 | this.name = name; 72 | } 73 | 74 | public String getName() { 75 | return name; 76 | } 77 | 78 | } 79 | 80 | static class InternalCategory { 81 | private String name; 82 | 83 | public InternalCategory(String name) { 84 | super(); 85 | this.name = name; 86 | } 87 | 88 | public String getName() { 89 | return name; 90 | } 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/Name.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | 16 | /** 17 | * @author Yvonne Wang 18 | */ 19 | public class Name implements Comparable { 20 | 21 | private String first; 22 | private String last; 23 | 24 | public Name() {} 25 | 26 | public Name(String first) { 27 | setFirst(first); 28 | } 29 | 30 | public Name(String first, String last) { 31 | setFirst(first); 32 | setLast(last); 33 | } 34 | 35 | public String getFirst() { 36 | return first; 37 | } 38 | 39 | public void setFirst(String first) { 40 | this.first = first; 41 | } 42 | 43 | public String getLast() { 44 | return last; 45 | } 46 | 47 | public void setLast(String last) { 48 | this.last = last; 49 | } 50 | 51 | @Override public String toString() { 52 | return String.format("%s[first='%s', last='%s']", getClass().getSimpleName(), first, last); 53 | } 54 | 55 | @Override 56 | public int compareTo(Name o) { 57 | return last.compareTo(o.last); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/OuterClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | public class OuterClass { 16 | public static class StaticNestedPerson { 17 | private String name; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public static class SNP_StaticNestedPerson { 24 | private String name; 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | } 30 | 31 | public class SNP_InnerPerson { 32 | private String name; 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | } 38 | } 39 | 40 | public class InnerPerson { 41 | private String name; 42 | 43 | public String getName() { 44 | return name; 45 | } 46 | 47 | // static class under inner class is not allowed by java language specifications 48 | // (public static class IP_StaticNestedPerson) 49 | 50 | public class IP_InnerPerson { 51 | private String name; 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/ParameterClashWithVariables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | public class ParameterClashWithVariables { 16 | // clashes with assertions for real numbers that take an offset parameter 17 | public String offset; 18 | public double weight; 19 | public float height; 20 | public Float bmi; 21 | public Double bloodPressure; 22 | } 23 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/Primitives.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | /** 16 | * This is a class to test generation of primitive types and their wrapper 17 | */ 18 | public class Primitives { 19 | 20 | public boolean isBoolean() { 21 | return true; 22 | } 23 | 24 | public Boolean isBooleanWrapper() { 25 | return null; 26 | } 27 | 28 | // test #52 29 | private Boolean enabled; 30 | 31 | public Boolean isEnabled() { 32 | return enabled; 33 | } 34 | 35 | public byte getByte() { 36 | return 0; 37 | } 38 | 39 | public Byte getByteWrapper() { 40 | return null; 41 | } 42 | 43 | public char getChar() { 44 | return 'h'; 45 | } 46 | 47 | public Character getCharacter() { 48 | return 'h'; 49 | } 50 | 51 | public double getDouble() { 52 | return 0.0; 53 | } 54 | 55 | public Double getDoubleWrapper() { 56 | return 0.0; 57 | } 58 | 59 | public float getFloat() { 60 | return 1.0f; 61 | } 62 | 63 | public Float getFloatWrapper() { 64 | return 1.0f; 65 | } 66 | 67 | public long getLong() { 68 | return 1l; 69 | } 70 | 71 | public Long getLongWrapper() { 72 | return 1L; 73 | } 74 | 75 | public short getShort() { 76 | return 1; 77 | } 78 | 79 | public Short getShortWrapper() { 80 | return 1; 81 | } 82 | 83 | public int getInt() { 84 | return 1; 85 | } 86 | 87 | public Integer getInteger() { 88 | return 1; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/Team.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import org.assertj.assertions.generator.data.nba.Player; 19 | 20 | public class Team { 21 | 22 | // to check that no assertion is created for public static field 23 | public static String staticField; 24 | 25 | public String name; 26 | public double victoryRatio; 27 | public boolean westCoast; 28 | public int rank; 29 | public List players = new ArrayList(); 30 | public List points = new ArrayList(); 31 | public String[] oldNames = {}; 32 | 33 | // private field : assertion should be generated if configured so 34 | @SuppressWarnings("unused") 35 | private String privateField; 36 | 37 | // property : assertion should be generated 38 | private String division; 39 | 40 | public String getDivision() { 41 | return division; 42 | } 43 | 44 | public Team(String name, String division) { 45 | this.name = name; 46 | this.division = division; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/TreeEnum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | import java.util.Collection; 16 | 17 | import com.google.common.base.Predicate; 18 | import com.google.common.collect.Collections2; 19 | import com.google.common.collect.Lists; 20 | 21 | public enum TreeEnum { 22 | 23 | PARENT, CHILD1(PARENT), CHILD2(PARENT); 24 | 25 | TreeEnum parent; 26 | 27 | private TreeEnum() { 28 | // nothing 29 | } 30 | 31 | private TreeEnum(TreeEnum parent) { 32 | this.parent = parent; 33 | } 34 | 35 | public Collection getChildren() { 36 | return Collections2.filter(Lists.newArrayList(values()), new Predicate() { 37 | @Override 38 | public boolean apply(TreeEnum input) { 39 | return this.equals(input.parent); 40 | } 41 | }); 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/WithPrivateFields.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | public class WithPrivateFields extends WithPrivateFieldsParent { 16 | 17 | private final static String FOO = "foo"; 18 | 19 | private String name; 20 | private boolean minor; 21 | String address; 22 | protected String nickname; 23 | public int age; 24 | 25 | public WithPrivateFields(String name, int age, String address, String nickname) { 26 | this.name = name; 27 | this.age = age; 28 | this.address = address; 29 | this.nickname = nickname; 30 | } 31 | 32 | public String getAddress() { 33 | return address; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/WithPrivateFieldsParent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data; 14 | 15 | public class WithPrivateFieldsParent { 16 | private String country; 17 | private String city; 18 | private Boolean northernHemisphere; 19 | 20 | public String getCity() { 21 | return city; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/art/ArtWork.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.art; 14 | 15 | public abstract class ArtWork { 16 | 17 | protected final String title; 18 | public String creator; 19 | 20 | protected ArtWork(String title) { 21 | super(); 22 | this.title = title; 23 | } 24 | 25 | public String getTitle() { 26 | return title; 27 | } 28 | 29 | @Override 30 | public int hashCode() { 31 | final int prime = 31; 32 | int result = 1; 33 | result = prime * result + ((title == null) ? 0 : title.hashCode()); 34 | return result; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object obj) { 39 | if (this == obj) return true; 40 | if (obj == null) return false; 41 | if (getClass() != obj.getClass()) return false; 42 | ArtWork other = (ArtWork) obj; 43 | if (title == null) { 44 | if (other.title != null) return false; 45 | } else if (!title.equals(other.title)) return false; 46 | return true; 47 | } 48 | 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/cars/Car.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.cars; 14 | 15 | public class Car { 16 | private int wheelsCount; 17 | 18 | public int getWheelsCount() { 19 | return wheelsCount; 20 | } 21 | 22 | public void setWheelsCount(int wheelsCount) { 23 | this.wheelsCount = wheelsCount; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/inner/Data.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.inner; 14 | 15 | public final class Data { 16 | 17 | public static final class NestedClass { 18 | 19 | private String name; 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/inner/PackagePrivate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.inner; 14 | 15 | class PackagePrivate { 16 | } 17 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/lotr/FellowshipOfTheRing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.lotr; 14 | 15 | import static org.assertj.assertions.generator.data.lotr.Race.dwarf; 16 | import static org.assertj.assertions.generator.data.lotr.Race.elf; 17 | import static org.assertj.assertions.generator.data.lotr.Race.hobbit; 18 | import static org.assertj.assertions.generator.data.lotr.Race.maia; 19 | import static org.assertj.assertions.generator.data.lotr.Race.man; 20 | 21 | import java.util.ArrayList; 22 | import java.util.HashMap; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | public class FellowshipOfTheRing { 27 | 28 | protected final TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, hobbit); 29 | protected final TolkienCharacter sam = new TolkienCharacter("Sam", 38, hobbit); 30 | protected final TolkienCharacter merry = new TolkienCharacter("Merry", 36, hobbit); 31 | protected final TolkienCharacter pippin = new TolkienCharacter("Pippin", 28, hobbit); 32 | protected final TolkienCharacter gandalf = new TolkienCharacter("Gandalf", 2020, maia); 33 | protected final TolkienCharacter gimli = new TolkienCharacter("Gimli", 139, dwarf); 34 | protected final TolkienCharacter legolas = new TolkienCharacter("Legolas", 1000, elf); 35 | protected final TolkienCharacter aragorn = new TolkienCharacter("Aragorn", 87, man); 36 | protected final TolkienCharacter boromir = new TolkienCharacter("Boromir", 87, man); 37 | protected final TolkienCharacter sauron = new TolkienCharacter("Sauron", 50000, maia); 38 | protected final TolkienCharacter galadriel = new TolkienCharacter("Legolas", 3000, elf); 39 | protected final TolkienCharacter elrond = new TolkienCharacter("Legolas", 3000, elf); 40 | protected final List fellowshipOfTheRing = new ArrayList(); 41 | 42 | public FellowshipOfTheRing() { 43 | super(); 44 | fellowshipOfTheRing.add(frodo); 45 | fellowshipOfTheRing.add(sam); 46 | fellowshipOfTheRing.add(merry); 47 | fellowshipOfTheRing.add(pippin); 48 | fellowshipOfTheRing.add(gandalf); 49 | fellowshipOfTheRing.add(legolas); 50 | fellowshipOfTheRing.add(gimli); 51 | fellowshipOfTheRing.add(aragorn); 52 | fellowshipOfTheRing.add(boromir); 53 | } 54 | 55 | public Map> getFellowsByRace() { 56 | Map> fellowsByRace = new HashMap>(); 57 | fellowsByRace.put(man, tolkienCharacterList(aragorn, boromir)); 58 | fellowsByRace.put(hobbit, tolkienCharacterList(frodo, sam, pippin, merry)); 59 | fellowsByRace.put(dwarf, tolkienCharacterList(gimli)); 60 | fellowsByRace.put(elf, tolkienCharacterList(legolas)); 61 | fellowsByRace.put(maia, tolkienCharacterList(gandalf)); 62 | return fellowsByRace; 63 | 64 | } 65 | 66 | private static List tolkienCharacterList(TolkienCharacter... characters) { 67 | List list = new ArrayList(characters.length); 68 | for (TolkienCharacter tolkienCharacter : characters) { 69 | list.add(tolkienCharacter); 70 | } 71 | return list; 72 | 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/lotr/Race.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.lotr; 14 | 15 | /** 16 | * Race in Tolkien's Lord of the Rings. 17 | * 18 | * @author Joel Costigliola 19 | */ 20 | public class Race { 21 | 22 | public final static Race hobbit = new Race("Hobbit", false); 23 | public final static Race maia = new Race("Maia", true); 24 | public final static Race man = new Race("Man", false); 25 | public final static Race elf = new Race("Elf", true); 26 | public final static Race dwarf = new Race("Dwarf", false); 27 | public final static Race orc = new Race("Orc", false); 28 | 29 | private final String name; 30 | private final boolean immortal; 31 | 32 | public Race(String name, boolean immortal) { 33 | super(); 34 | this.name = name; 35 | this.immortal = immortal; 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public boolean isImmortal() { 43 | return immortal; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "Race [name=" + name + ", immortal=" + immortal + "]"; 49 | } 50 | 51 | @Override 52 | public int hashCode() { 53 | final int prime = 31; 54 | int result = 1; 55 | result = prime * result + (immortal ? 1231 : 1237); 56 | result = prime * result + ((name == null) ? 0 : name.hashCode()); 57 | return result; 58 | } 59 | 60 | @Override 61 | public boolean equals(Object obj) { 62 | if (this == obj) return true; 63 | if (obj == null) return false; 64 | if (getClass() != obj.getClass()) return false; 65 | Race other = (Race) obj; 66 | if (immortal != other.immortal) return false; 67 | if (name == null) { 68 | if (other.name != null) return false; 69 | } else if (!name.equals(other.name)) return false; 70 | return true; 71 | } 72 | 73 | 74 | 75 | } 76 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/lotr/Ring.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.lotr; 14 | 15 | /** 16 | * Rings of Power in Tolkien's Lord of the Rings. 17 | * 18 | * @author Joel Costigliola 19 | */ 20 | public enum Ring { 21 | oneRing, vilya, nenya, narya, dwarfRing, manRing; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/lotr/TolkienCharacter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.lotr; 14 | 15 | /** 16 | * 17 | * A simple class to illustrate AssertJ assertions. 18 | * 19 | * @author Joel Costigliola 20 | */ 21 | public class TolkienCharacter { 22 | 23 | private String name; 24 | private Race race; 25 | private int age; 26 | 27 | public TolkienCharacter(String name, int age, Race race) { 28 | super(); 29 | this.name = name; 30 | this.age = age; 31 | this.race = race; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public Race getRace() { 39 | return race; 40 | } 41 | 42 | public int getAge() { 43 | return age; 44 | } 45 | 46 | 47 | public void setName(String name) { 48 | this.name = name; 49 | } 50 | 51 | public void setRace(Race race) { 52 | this.race = race; 53 | } 54 | 55 | public void setAge(int age) { 56 | this.age = age; 57 | } 58 | 59 | @Override 60 | public int hashCode() { 61 | final int prime = 31; 62 | int result = 1; 63 | result = prime * result + age; 64 | result = prime * result + ((name == null) ? 0 : name.hashCode()); 65 | result = prime * result + ((race == null) ? 0 : race.hashCode()); 66 | return result; 67 | } 68 | 69 | @Override 70 | public boolean equals(Object obj) { 71 | if (this == obj) return true; 72 | if (obj == null) return false; 73 | if (getClass() != obj.getClass()) return false; 74 | TolkienCharacter other = (TolkienCharacter) obj; 75 | if (age != other.age) return false; 76 | if (name == null) { 77 | if (other.name != null) return false; 78 | } else if (!name.equals(other.name)) return false; 79 | if (race == null) { 80 | if (other.race != null) return false; 81 | } else if (!race.equals(other.race)) return false; 82 | return true; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "Character [name=" + name + ", race=" + race + ", age=" + age + "]"; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/nba/PlayerAgent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.nba; 14 | 15 | public interface PlayerAgent { 16 | 17 | Player getManagedPlayer(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/nba/team/Coach.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.nba.team; 14 | 15 | public class Coach { 16 | 17 | public Team team; 18 | } 19 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/nba/team/Team.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.data.nba.team; 14 | 15 | // another Team class for testing that we generate correctly import of classes with the same name. 16 | public class Team { 17 | 18 | private String name; 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/data/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | /** 14 | * This package contains classes to test the assertion generator 15 | */ 16 | 17 | @VisibleForTesting 18 | package org.assertj.assertions.generator.data; 19 | 20 | import org.assertj.core.util.VisibleForTesting; -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/util/PackagePrivate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.util; 14 | 15 | class PackagePrivate { 16 | } 17 | -------------------------------------------------------------------------------- /assertj-generator/src/test/java/org/assertj/assertions/generator/util/StringUtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 3 | * the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 8 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 9 | * specific language governing permissions and limitations under the License. 10 | * 11 | * Copyright 2012-2025 the original author or authors. 12 | */ 13 | package org.assertj.assertions.generator.util; 14 | 15 | import org.junit.jupiter.api.Test; 16 | 17 | import static org.assertj.assertions.generator.util.StringUtil.camelCaseToWords; 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | class StringUtilTest { 21 | 22 | @Test 23 | void testCamelCaseToWords() throws Exception { 24 | assertThat(camelCaseToWords("BestPlayer")).isEqualTo("best player"); 25 | assertThat(camelCaseToWords("Run")).isEqualTo("run"); 26 | assertThat(camelCaseToWords("RunFasterThanLight")).isEqualTo("run faster than light"); 27 | assertThat(camelCaseToWords("RunAMillionTime")).isEqualTo("run a million time"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractArtWorkAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.art; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractObjectAssert; 5 | 6 | /** 7 | * Abstract base class for {@link ArtWork} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public abstract class AbstractArtWorkAssert, A extends ArtWork> extends AbstractObjectAssert { 11 | 12 | /** 13 | * Creates a new {@link AbstractArtWorkAssert} to make assertions on actual ArtWork. 14 | * @param actual the ArtWork we want to make assertions on. 15 | */ 16 | protected AbstractArtWorkAssert(A actual, Class selfType) { 17 | super(actual, selfType); 18 | } 19 | 20 | /** 21 | * Verifies that the actual ArtWork's title is equal to the given one. 22 | * @param title the given title to compare the actual ArtWork's title to. 23 | * @return this assertion object. 24 | * @throws AssertionError - if the actual ArtWork's title is not equal to the given one. 25 | */ 26 | public S hasTitle(String title) { 27 | // check that actual ArtWork we want to make assertions on is not null. 28 | isNotNull(); 29 | 30 | // overrides the default error message with a more explicit one 31 | String assertjErrorMessage = "\nExpecting title of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 32 | 33 | // null safe check 34 | String actualTitle = actual.getTitle(); 35 | if (!Objects.deepEquals(actualTitle, title)) { 36 | failWithMessage(assertjErrorMessage, actual, title, actualTitle); 37 | } 38 | 39 | // return the current assertion for method chaining 40 | return myself; 41 | } 42 | 43 | /** 44 | * Verifies that the actual ArtWork's creator is equal to the given one. 45 | * @param creator the given creator to compare the actual ArtWork's creator to. 46 | * @return this assertion object. 47 | * @throws AssertionError - if the actual ArtWork's creator is not equal to the given one. 48 | */ 49 | public S hasCreator(String creator) { 50 | // check that actual ArtWork we want to make assertions on is not null. 51 | isNotNull(); 52 | 53 | // overrides the default error message with a more explicit one 54 | String assertjErrorMessage = "\nExpecting creator of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 55 | 56 | // null safe check 57 | String actualCreator = actual.creator; 58 | if (!Objects.deepEquals(actualCreator, creator)) { 59 | failWithMessage(assertjErrorMessage, actual, creator, actualCreator); 60 | } 61 | 62 | // return the current assertion for method chaining 63 | return myself; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractBlockBusterAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * Abstract base class for {@link BlockBuster} specific assertions - Generated by CustomAssertionGenerator. 5 | */ 6 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 7 | public abstract class AbstractBlockBusterAssert, A extends BlockBuster> extends AbstractMovieAssert { 8 | 9 | /** 10 | * Creates a new {@link AbstractBlockBusterAssert} to make assertions on actual BlockBuster. 11 | * @param actual the BlockBuster we want to make assertions on. 12 | */ 13 | protected AbstractBlockBusterAssert(A actual, Class selfType) { 14 | super(actual, selfType); 15 | } 16 | 17 | /** 18 | * Verifies that the actual BlockBuster's revenue is equal to the given one. 19 | * @param revenue the given revenue to compare the actual BlockBuster's revenue to. 20 | * @return this assertion object. 21 | * @throws AssertionError - if the actual BlockBuster's revenue is not equal to the given one. 22 | */ 23 | public S hasRevenue(int revenue) { 24 | // check that actual BlockBuster we want to make assertions on is not null. 25 | isNotNull(); 26 | 27 | // overrides the default error message with a more explicit one 28 | String assertjErrorMessage = "\nExpecting revenue of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 29 | 30 | // check 31 | int actualRevenue = actual.getRevenue(); 32 | if (actualRevenue != revenue) { 33 | failWithMessage(assertjErrorMessage, actual, revenue, actualRevenue); 34 | } 35 | 36 | // return the current assertion for method chaining 37 | return myself; 38 | } 39 | 40 | /** 41 | * Verifies that the actual BlockBuster's numberOfSpectators is equal to the given one. 42 | * @param numberOfSpectators the given numberOfSpectators to compare the actual BlockBuster's numberOfSpectators to. 43 | * @return this assertion object. 44 | * @throws AssertionError - if the actual BlockBuster's numberOfSpectators is not equal to the given one. 45 | */ 46 | public S hasNumberOfSpectators(int numberOfSpectators) { 47 | // check that actual BlockBuster we want to make assertions on is not null. 48 | isNotNull(); 49 | 50 | // overrides the default error message with a more explicit one 51 | String assertjErrorMessage = "\nExpecting numberOfSpectators of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 52 | 53 | // check 54 | int actualNumberOfSpectators = actual.numberOfSpectators; 55 | if (actualNumberOfSpectators != numberOfSpectators) { 56 | failWithMessage(assertjErrorMessage, actual, numberOfSpectators, actualNumberOfSpectators); 57 | } 58 | 59 | // return the current assertion for method chaining 60 | return myself; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractClassUsingDifferentClassesWithSameNameAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractObjectAssert; 5 | 6 | /** 7 | * Abstract base class for {@link ClassUsingDifferentClassesWithSameName} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public abstract class AbstractClassUsingDifferentClassesWithSameNameAssert, A extends ClassUsingDifferentClassesWithSameName> extends AbstractObjectAssert { 11 | 12 | /** 13 | * Creates a new {@link AbstractClassUsingDifferentClassesWithSameNameAssert} to make assertions on actual ClassUsingDifferentClassesWithSameName. 14 | * @param actual the ClassUsingDifferentClassesWithSameName we want to make assertions on. 15 | */ 16 | protected AbstractClassUsingDifferentClassesWithSameNameAssert(A actual, Class selfType) { 17 | super(actual, selfType); 18 | } 19 | 20 | /** 21 | * Verifies that the actual ClassUsingDifferentClassesWithSameName's nbaTeam is equal to the given one. 22 | * @param nbaTeam the given nbaTeam to compare the actual ClassUsingDifferentClassesWithSameName's nbaTeam to. 23 | * @return this assertion object. 24 | * @throws AssertionError - if the actual ClassUsingDifferentClassesWithSameName's nbaTeam is not equal to the given one. 25 | */ 26 | public S hasNbaTeam(org.assertj.assertions.generator.data.nba.team.Team nbaTeam) { 27 | // check that actual ClassUsingDifferentClassesWithSameName we want to make assertions on is not null. 28 | isNotNull(); 29 | 30 | // overrides the default error message with a more explicit one 31 | String assertjErrorMessage = "\nExpecting nbaTeam of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 32 | 33 | // null safe check 34 | org.assertj.assertions.generator.data.nba.team.Team actualNbaTeam = actual.getNbaTeam(); 35 | if (!Objects.deepEquals(actualNbaTeam, nbaTeam)) { 36 | failWithMessage(assertjErrorMessage, actual, nbaTeam, actualNbaTeam); 37 | } 38 | 39 | // return the current assertion for method chaining 40 | return myself; 41 | } 42 | 43 | /** 44 | * Verifies that the actual ClassUsingDifferentClassesWithSameName's team is equal to the given one. 45 | * @param team the given team to compare the actual ClassUsingDifferentClassesWithSameName's team to. 46 | * @return this assertion object. 47 | * @throws AssertionError - if the actual ClassUsingDifferentClassesWithSameName's team is not equal to the given one. 48 | */ 49 | public S hasTeam(org.assertj.assertions.generator.data.Team team) { 50 | // check that actual ClassUsingDifferentClassesWithSameName we want to make assertions on is not null. 51 | isNotNull(); 52 | 53 | // overrides the default error message with a more explicit one 54 | String assertjErrorMessage = "\nExpecting team of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 55 | 56 | // null safe check 57 | org.assertj.assertions.generator.data.Team actualTeam = actual.getTeam(); 58 | if (!Objects.deepEquals(actualTeam, team)) { 59 | failWithMessage(assertjErrorMessage, actual, team, actualTeam); 60 | } 61 | 62 | // return the current assertion for method chaining 63 | return myself; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractDollar$Assert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractObjectAssert; 5 | 6 | /** 7 | * Abstract base class for {@link Dollar$} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public abstract class AbstractDollar$Assert, A extends Dollar$> extends AbstractObjectAssert { 11 | 12 | /** 13 | * Creates a new {@link AbstractDollar$Assert} to make assertions on actual Dollar$. 14 | * @param actual the Dollar$ we want to make assertions on. 15 | */ 16 | protected AbstractDollar$Assert(A actual, Class selfType) { 17 | super(actual, selfType); 18 | } 19 | 20 | /** 21 | * Verifies that the actual Dollar$'s test is equal to the given one. 22 | * @param test the given test to compare the actual Dollar$'s test to. 23 | * @return this assertion object. 24 | * @throws AssertionError - if the actual Dollar$'s test is not equal to the given one. 25 | */ 26 | public S hasTest(String test) { 27 | // check that actual Dollar$ we want to make assertions on is not null. 28 | isNotNull(); 29 | 30 | // overrides the default error message with a more explicit one 31 | String assertjErrorMessage = "\nExpecting test of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 32 | 33 | // null safe check 34 | String actualTest = actual.test; 35 | if (!Objects.deepEquals(actualTest, test)) { 36 | failWithMessage(assertjErrorMessage, actual, test, actualTest); 37 | } 38 | 39 | // return the current assertion for method chaining 40 | return myself; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractInterferencePrimitivesAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractObjectAssert; 5 | 6 | /** 7 | * Abstract base class for {@link InterferencePrimitives} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public abstract class AbstractInterferencePrimitivesAssert, A extends InterferencePrimitives> extends AbstractObjectAssert { 11 | 12 | /** 13 | * Creates a new {@link AbstractInterferencePrimitivesAssert} to make assertions on actual InterferencePrimitives. 14 | * @param actual the InterferencePrimitives we want to make assertions on. 15 | */ 16 | protected AbstractInterferencePrimitivesAssert(A actual, Class selfType) { 17 | super(actual, selfType); 18 | } 19 | 20 | /** 21 | * Verifies that the actual InterferencePrimitives is a boolean. 22 | * @return this assertion object. 23 | * @throws AssertionError - if the actual InterferencePrimitives is not a boolean. 24 | */ 25 | public S isABoolean() { 26 | // check that actual InterferencePrimitives we want to make assertions on is not null. 27 | isNotNull(); 28 | 29 | // null safe check 30 | if (Objects.deepEquals(Boolean.FALSE, actual.isABoolean())) { 31 | failWithMessage("\nExpecting that actual InterferencePrimitives is a boolean but is not."); 32 | } 33 | 34 | // return the current assertion for method chaining 35 | return myself; 36 | } 37 | 38 | /** 39 | * Verifies that the actual InterferencePrimitives is not a boolean. 40 | * @return this assertion object. 41 | * @throws AssertionError - if the actual InterferencePrimitives is a boolean. 42 | */ 43 | public S isNotABoolean() { 44 | // check that actual InterferencePrimitives we want to make assertions on is not null. 45 | isNotNull(); 46 | 47 | // null safe check 48 | if (Objects.deepEquals(Boolean.FALSE, actual.isNotABoolean())) { 49 | failWithMessage("\nExpecting that actual InterferencePrimitives is not a boolean but is."); 50 | } 51 | 52 | // return the current assertion for method chaining 53 | return myself; 54 | } 55 | 56 | /** 57 | * Verifies that the actual InterferencePrimitives is not working. 58 | * @return this assertion object. 59 | * @throws AssertionError - if the actual InterferencePrimitives is working. 60 | */ 61 | public S isNotWorking() { 62 | // check that actual InterferencePrimitives we want to make assertions on is not null. 63 | isNotNull(); 64 | 65 | // check 66 | if (!actual.isNotWorking()) { 67 | failWithMessage("\nExpecting that actual InterferencePrimitives is not working but is."); 68 | } 69 | 70 | // return the current assertion for method chaining 71 | return myself; 72 | } 73 | 74 | /** 75 | * Verifies that the actual InterferencePrimitives is working. 76 | * @return this assertion object. 77 | * @throws AssertionError - if the actual InterferencePrimitives is not working. 78 | */ 79 | public S isWorking() { 80 | // check that actual InterferencePrimitives we want to make assertions on is not null. 81 | isNotNull(); 82 | 83 | // check 84 | if (!actual.isWorking()) { 85 | failWithMessage("\nExpecting that actual InterferencePrimitives is working but is not."); 86 | } 87 | 88 | // return the current assertion for method chaining 89 | return myself; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractNameAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractComparableAssert; 5 | 6 | /** 7 | * Abstract base class for {@link Name} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public abstract class AbstractNameAssert, A extends Name> extends AbstractComparableAssert { 11 | 12 | /** 13 | * Creates a new {@link AbstractNameAssert} to make assertions on actual Name. 14 | * @param actual the Name we want to make assertions on. 15 | */ 16 | protected AbstractNameAssert(A actual, Class selfType) { 17 | super(actual, selfType); 18 | } 19 | 20 | /** 21 | * Verifies that the actual Name's first is equal to the given one. 22 | * @param first the given first to compare the actual Name's first to. 23 | * @return this assertion object. 24 | * @throws AssertionError - if the actual Name's first is not equal to the given one. 25 | */ 26 | public S hasFirst(String first) { 27 | // check that actual Name we want to make assertions on is not null. 28 | isNotNull(); 29 | 30 | // overrides the default error message with a more explicit one 31 | String assertjErrorMessage = "\nExpecting first of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 32 | 33 | // null safe check 34 | String actualFirst = actual.getFirst(); 35 | if (!Objects.deepEquals(actualFirst, first)) { 36 | failWithMessage(assertjErrorMessage, actual, first, actualFirst); 37 | } 38 | 39 | // return the current assertion for method chaining 40 | return myself; 41 | } 42 | 43 | /** 44 | * Verifies that the actual Name's last is equal to the given one. 45 | * @param last the given last to compare the actual Name's last to. 46 | * @return this assertion object. 47 | * @throws AssertionError - if the actual Name's last is not equal to the given one. 48 | */ 49 | public S hasLast(String last) { 50 | // check that actual Name we want to make assertions on is not null. 51 | isNotNull(); 52 | 53 | // overrides the default error message with a more explicit one 54 | String assertjErrorMessage = "\nExpecting last of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 55 | 56 | // null safe check 57 | String actualLast = actual.getLast(); 58 | if (!Objects.deepEquals(actualLast, last)) { 59 | failWithMessage(assertjErrorMessage, actual, last, actualLast); 60 | } 61 | 62 | // return the current assertion for method chaining 63 | return myself; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractOptionalAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package com.google.common.base; 2 | 3 | import org.assertj.core.api.AbstractObjectAssert; 4 | 5 | /** 6 | * Abstract base class for {@link Optional} specific assertions - Generated by CustomAssertionGenerator. 7 | */ 8 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 9 | public abstract class AbstractOptionalAssert, A extends Optional> extends AbstractObjectAssert { 10 | 11 | /** 12 | * Creates a new {@link AbstractOptionalAssert} to make assertions on actual Optional. 13 | * @param actual the Optional we want to make assertions on. 14 | */ 15 | protected AbstractOptionalAssert(A actual, Class selfType) { 16 | super(actual, selfType); 17 | } 18 | 19 | /** 20 | * Verifies that the actual Optional is present. 21 | * @return this assertion object. 22 | * @throws AssertionError - if the actual Optional is not present. 23 | */ 24 | public S isPresent() { 25 | // check that actual Optional we want to make assertions on is not null. 26 | isNotNull(); 27 | 28 | // check that property call/field access is true 29 | if (!actual.isPresent()) { 30 | failWithMessage("\nExpecting that actual Optional is present but is not."); 31 | } 32 | 33 | // return the current assertion for method chaining 34 | return myself; 35 | } 36 | 37 | /** 38 | * Verifies that the actual Optional is not present. 39 | * @return this assertion object. 40 | * @throws AssertionError - if the actual Optional is present. 41 | */ 42 | public S isNotPresent() { 43 | // check that actual Optional we want to make assertions on is not null. 44 | isNotNull(); 45 | 46 | // check that property call/field access is false 47 | if (actual.isPresent()) { 48 | failWithMessage("\nExpecting that actual Optional is not present but is."); 49 | } 50 | 51 | // return the current assertion for method chaining 52 | return myself; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractPlayerAgentAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.nba; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractObjectAssert; 5 | 6 | /** 7 | * Abstract base class for {@link PlayerAgent} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public abstract class AbstractPlayerAgentAssert, A extends PlayerAgent> extends AbstractObjectAssert { 11 | 12 | /** 13 | * Creates a new {@link AbstractPlayerAgentAssert} to make assertions on actual PlayerAgent. 14 | * @param actual the PlayerAgent we want to make assertions on. 15 | */ 16 | protected AbstractPlayerAgentAssert(A actual, Class selfType) { 17 | super(actual, selfType); 18 | } 19 | 20 | /** 21 | * Verifies that the actual PlayerAgent's managedPlayer is equal to the given one. 22 | * @param managedPlayer the given managedPlayer to compare the actual PlayerAgent's managedPlayer to. 23 | * @return this assertion object. 24 | * @throws AssertionError - if the actual PlayerAgent's managedPlayer is not equal to the given one. 25 | */ 26 | public S hasManagedPlayer(Player managedPlayer) { 27 | // check that actual PlayerAgent we want to make assertions on is not null. 28 | isNotNull(); 29 | 30 | // overrides the default error message with a more explicit one 31 | String assertjErrorMessage = "\nExpecting managedPlayer of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 32 | 33 | // null safe check 34 | Player actualManagedPlayer = actual.getManagedPlayer(); 35 | if (!Objects.deepEquals(actualManagedPlayer, managedPlayer)) { 36 | failWithMessage(assertjErrorMessage, actual, managedPlayer, actualManagedPlayer); 37 | } 38 | 39 | // return the current assertion for method chaining 40 | return myself; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AbstractPlayerAgentAssert.generated.in.custom.package.expected.txt: -------------------------------------------------------------------------------- 1 | package my.assertions; 2 | 3 | import java.util.Objects; 4 | import org.assertj.assertions.generator.data.nba.PlayerAgent; 5 | import org.assertj.core.api.AbstractObjectAssert; 6 | 7 | /** 8 | * Abstract base class for {@link PlayerAgent} specific assertions - Generated by CustomAssertionGenerator. 9 | */ 10 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 11 | public abstract class AbstractPlayerAgentAssert, A extends PlayerAgent> extends AbstractObjectAssert { 12 | 13 | /** 14 | * Creates a new {@link AbstractPlayerAgentAssert} to make assertions on actual PlayerAgent. 15 | * @param actual the PlayerAgent we want to make assertions on. 16 | */ 17 | protected AbstractPlayerAgentAssert(A actual, Class selfType) { 18 | super(actual, selfType); 19 | } 20 | 21 | /** 22 | * Verifies that the actual PlayerAgent's managedPlayer is equal to the given one. 23 | * @param managedPlayer the given managedPlayer to compare the actual PlayerAgent's managedPlayer to. 24 | * @return this assertion object. 25 | * @throws AssertionError - if the actual PlayerAgent's managedPlayer is not equal to the given one. 26 | */ 27 | public S hasManagedPlayer(org.assertj.assertions.generator.data.nba.Player managedPlayer) { 28 | // check that actual PlayerAgent we want to make assertions on is not null. 29 | isNotNull(); 30 | 31 | // overrides the default error message with a more explicit one 32 | String assertjErrorMessage = "\nExpecting managedPlayer of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 33 | 34 | // null safe check 35 | org.assertj.assertions.generator.data.nba.Player actualManagedPlayer = actual.getManagedPlayer(); 36 | if (!Objects.deepEquals(actualManagedPlayer, managedPlayer)) { 37 | failWithMessage(assertjErrorMessage, actual, managedPlayer, actualManagedPlayer); 38 | } 39 | 40 | // return the current assertion for method chaining 41 | return myself; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AnnotatedClassAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link AnnotatedClass} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractAnnotatedClassAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class AnnotatedClassAssert extends AbstractAnnotatedClassAssert { 11 | 12 | /** 13 | * Creates a new {@link AnnotatedClassAssert} to make assertions on actual AnnotatedClass. 14 | * @param actual the AnnotatedClass we want to make assertions on. 15 | */ 16 | public AnnotatedClassAssert(AnnotatedClass actual) { 17 | super(actual, AnnotatedClassAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for AnnotatedClassAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myAnnotatedClass) and get specific assertion with code completion. 23 | * @param actual the AnnotatedClass we want to make assertions on. 24 | * @return a new {@link AnnotatedClassAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static AnnotatedClassAssert assertThat(AnnotatedClass actual) { 28 | return new AnnotatedClassAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/ArtWorkAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.art; 2 | 3 | /** 4 | * {@link ArtWork} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractArtWorkAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class ArtWorkAssert extends AbstractArtWorkAssert { 11 | 12 | /** 13 | * Creates a new {@link ArtWorkAssert} to make assertions on actual ArtWork. 14 | * @param actual the ArtWork we want to make assertions on. 15 | */ 16 | public ArtWorkAssert(ArtWork actual) { 17 | super(actual, ArtWorkAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for ArtWorkAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myArtWork) and get specific assertion with code completion. 23 | * @param actual the ArtWork we want to make assertions on. 24 | * @return a new {@link ArtWorkAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static ArtWorkAssert assertThat(ArtWork actual) { 28 | return new ArtWorkAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AssertionsForClassesWithSameName.expected.txt: -------------------------------------------------------------------------------- 1 | package org; 2 | 3 | /** 4 | * Entry point for assertions of different data types. Each method in this class is a static factory for the 5 | * type-specific assertion objects. 6 | */ 7 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 8 | public class Assertions { 9 | 10 | /** 11 | * Creates a new instance of {@link org.assertj.assertions.generator.data.TeamAssert}. 12 | * 13 | * @param actual the actual value. 14 | * @return the created assertion object. 15 | */ 16 | @org.assertj.core.util.CheckReturnValue 17 | public static org.assertj.assertions.generator.data.TeamAssert assertThat(org.assertj.assertions.generator.data.Team actual) { 18 | return new org.assertj.assertions.generator.data.TeamAssert(actual); 19 | } 20 | 21 | /** 22 | * Creates a new instance of {@link org.assertj.assertions.generator.data.nba.team.TeamAssert}. 23 | * 24 | * @param actual the actual value. 25 | * @return the created assertion object. 26 | */ 27 | @org.assertj.core.util.CheckReturnValue 28 | public static org.assertj.assertions.generator.data.nba.team.TeamAssert assertThat(org.assertj.assertions.generator.data.nba.team.Team actual) { 29 | return new org.assertj.assertions.generator.data.nba.team.TeamAssert(actual); 30 | } 31 | 32 | /** 33 | * Creates a new {@link Assertions}. 34 | */ 35 | protected Assertions() { 36 | // empty 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/AutoValueAnnotatedClassAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link AutoValueAnnotatedClass} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractAutoValueAnnotatedClassAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class AutoValueAnnotatedClassAssert extends AbstractAutoValueAnnotatedClassAssert { 11 | 12 | /** 13 | * Creates a new {@link AutoValueAnnotatedClassAssert} to make assertions on actual AutoValueAnnotatedClass. 14 | * @param actual the AutoValueAnnotatedClass we want to make assertions on. 15 | */ 16 | public AutoValueAnnotatedClassAssert(AutoValueAnnotatedClass actual) { 17 | super(actual, AutoValueAnnotatedClassAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for AutoValueAnnotatedClassAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myAutoValueAnnotatedClass) and get specific assertion with code completion. 23 | * @param actual the AutoValueAnnotatedClass we want to make assertions on. 24 | * @return a new {@link AutoValueAnnotatedClassAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static AutoValueAnnotatedClassAssert assertThat(AutoValueAnnotatedClass actual) { 28 | return new AutoValueAnnotatedClassAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/BlockBusterAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link BlockBuster} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractBlockBusterAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class BlockBusterAssert extends AbstractBlockBusterAssert { 11 | 12 | /** 13 | * Creates a new {@link BlockBusterAssert} to make assertions on actual BlockBuster. 14 | * @param actual the BlockBuster we want to make assertions on. 15 | */ 16 | public BlockBusterAssert(BlockBuster actual) { 17 | super(actual, BlockBusterAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for BlockBusterAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myBlockBuster) and get specific assertion with code completion. 23 | * @param actual the BlockBuster we want to make assertions on. 24 | * @return a new {@link BlockBusterAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static BlockBusterAssert assertThat(BlockBuster actual) { 28 | return new BlockBusterAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/BooleanPredicatesAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link BooleanPredicates} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractBooleanPredicatesAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class BooleanPredicatesAssert extends AbstractBooleanPredicatesAssert { 11 | 12 | /** 13 | * Creates a new {@link BooleanPredicatesAssert} to make assertions on actual BooleanPredicates. 14 | * @param actual the BooleanPredicates we want to make assertions on. 15 | */ 16 | public BooleanPredicatesAssert(BooleanPredicates actual) { 17 | super(actual, BooleanPredicatesAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for BooleanPredicatesAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myBooleanPredicates) and get specific assertion with code completion. 23 | * @param actual the BooleanPredicates we want to make assertions on. 24 | * @return a new {@link BooleanPredicatesAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static BooleanPredicatesAssert assertThat(BooleanPredicates actual) { 28 | return new BooleanPredicatesAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/CarAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.cars; 2 | 3 | import org.assertj.core.api.AbstractObjectAssert; 4 | 5 | /** 6 | * {@link Car} specific assertions - Generated by CustomAssertionGenerator. 7 | */ 8 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 9 | public class CarAssert extends AbstractObjectAssert { 10 | 11 | /** 12 | * Creates a new {@link CarAssert} to make assertions on actual Car. 13 | * @param actual the Car we want to make assertions on. 14 | */ 15 | public CarAssert(Car actual) { 16 | super(actual, CarAssert.class); 17 | } 18 | 19 | /** 20 | * An entry point for CarAssert to follow AssertJ standard assertThat() statements.
21 | * With a static import, one can write directly: assertThat(myCar) and get specific assertion with code completion. 22 | * @param actual the Car we want to make assertions on. 23 | * @return a new {@link CarAssert} 24 | */ 25 | @org.assertj.core.util.CheckReturnValue 26 | public static CarAssert assertThat(Car actual) { 27 | return new CarAssert(actual); 28 | } 29 | 30 | /** 31 | * Verifies that the actual Car's wheelsCount is equal to the given one. 32 | * @param wheelsCount the given wheelsCount to compare the actual Car's wheelsCount to. 33 | * @return this assertion object. 34 | * @throws AssertionError - if the actual Car's wheelsCount is not equal to the given one. 35 | */ 36 | public CarAssert hasWheelsCount(int wheelsCount) { 37 | // check that actual Car we want to make assertions on is not null. 38 | isNotNull(); 39 | 40 | System.out.println("Custom template for whole number"); 41 | 42 | // overrides the default error message with a more explicit one 43 | String assertjErrorMessage = "\nExpecting wheelsCount of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 44 | 45 | // check 46 | int actualWheelsCount = actual.getWheelsCount(); 47 | if (actualWheelsCount != wheelsCount) { 48 | failWithMessage(assertjErrorMessage, actual, wheelsCount, actualWheelsCount); 49 | } 50 | 51 | // return the current assertion for method chaining 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/ClassUsingDifferentClassesWithSameNameAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator; 2 | 3 | /** 4 | * {@link ClassUsingDifferentClassesWithSameName} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractClassUsingDifferentClassesWithSameNameAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class ClassUsingDifferentClassesWithSameNameAssert extends AbstractClassUsingDifferentClassesWithSameNameAssert { 11 | 12 | /** 13 | * Creates a new {@link ClassUsingDifferentClassesWithSameNameAssert} to make assertions on actual ClassUsingDifferentClassesWithSameName. 14 | * @param actual the ClassUsingDifferentClassesWithSameName we want to make assertions on. 15 | */ 16 | public ClassUsingDifferentClassesWithSameNameAssert(ClassUsingDifferentClassesWithSameName actual) { 17 | super(actual, ClassUsingDifferentClassesWithSameNameAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for ClassUsingDifferentClassesWithSameNameAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myClassUsingDifferentClassesWithSameName) and get specific assertion with code completion. 23 | * @param actual the ClassUsingDifferentClassesWithSameName we want to make assertions on. 24 | * @return a new {@link ClassUsingDifferentClassesWithSameNameAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static ClassUsingDifferentClassesWithSameNameAssert assertThat(ClassUsingDifferentClassesWithSameName actual) { 28 | return new ClassUsingDifferentClassesWithSameNameAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/Dollar$Assert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link Dollar$} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractDollar$Assert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class Dollar$Assert extends AbstractDollar$Assert { 11 | 12 | /** 13 | * Creates a new {@link Dollar$Assert} to make assertions on actual Dollar$. 14 | * @param actual the Dollar$ we want to make assertions on. 15 | */ 16 | public Dollar$Assert(Dollar$ actual) { 17 | super(actual, Dollar$Assert.class); 18 | } 19 | 20 | /** 21 | * An entry point for Dollar$Assert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myDollar$) and get specific assertion with code completion. 23 | * @param actual the Dollar$ we want to make assertions on. 24 | * @return a new {@link Dollar$Assert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static Dollar$Assert assertThat(Dollar$ actual) { 28 | return new Dollar$Assert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/Dollar$Assert.flat.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractObjectAssert; 5 | 6 | /** 7 | * {@link Dollar$} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class Dollar$Assert extends AbstractObjectAssert { 11 | 12 | /** 13 | * Creates a new {@link Dollar$Assert} to make assertions on actual Dollar$. 14 | * @param actual the Dollar$ we want to make assertions on. 15 | */ 16 | public Dollar$Assert(Dollar$ actual) { 17 | super(actual, Dollar$Assert.class); 18 | } 19 | 20 | /** 21 | * An entry point for Dollar$Assert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myDollar$) and get specific assertion with code completion. 23 | * @param actual the Dollar$ we want to make assertions on. 24 | * @return a new {@link Dollar$Assert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static Dollar$Assert assertThat(Dollar$ actual) { 28 | return new Dollar$Assert(actual); 29 | } 30 | 31 | /** 32 | * Verifies that the actual Dollar$'s test is equal to the given one. 33 | * @param test the given test to compare the actual Dollar$'s test to. 34 | * @return this assertion object. 35 | * @throws AssertionError - if the actual Dollar$'s test is not equal to the given one. 36 | */ 37 | public Dollar$Assert hasTest(String test) { 38 | // check that actual Dollar$ we want to make assertions on is not null. 39 | isNotNull(); 40 | 41 | // overrides the default error message with a more explicit one 42 | String assertjErrorMessage = "\nExpecting test of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 43 | 44 | // null safe check 45 | String actualTest = actual.test; 46 | if (!Objects.deepEquals(actualTest, test)) { 47 | failWithMessage(assertjErrorMessage, actual, test, actualTest); 48 | } 49 | 50 | // return the current assertion for method chaining 51 | return this; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/FieldPropertyClashAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link FieldPropertyClash} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractFieldPropertyClashAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class FieldPropertyClashAssert extends AbstractFieldPropertyClashAssert { 11 | 12 | /** 13 | * Creates a new {@link FieldPropertyClashAssert} to make assertions on actual FieldPropertyClash. 14 | * @param actual the FieldPropertyClash we want to make assertions on. 15 | */ 16 | public FieldPropertyClashAssert(FieldPropertyClash actual) { 17 | super(actual, FieldPropertyClashAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for FieldPropertyClashAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myFieldPropertyClash) and get specific assertion with code completion. 23 | * @param actual the FieldPropertyClash we want to make assertions on. 24 | * @return a new {@link FieldPropertyClashAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static FieldPropertyClashAssert assertThat(FieldPropertyClash actual) { 28 | return new FieldPropertyClashAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/InterferencePrimitivesAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link InterferencePrimitives} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractInterferencePrimitivesAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class InterferencePrimitivesAssert extends AbstractInterferencePrimitivesAssert { 11 | 12 | /** 13 | * Creates a new {@link InterferencePrimitivesAssert} to make assertions on actual InterferencePrimitives. 14 | * @param actual the InterferencePrimitives we want to make assertions on. 15 | */ 16 | public InterferencePrimitivesAssert(InterferencePrimitives actual) { 17 | super(actual, InterferencePrimitivesAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for InterferencePrimitivesAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myInterferencePrimitives) and get specific assertion with code completion. 23 | * @param actual the InterferencePrimitives we want to make assertions on. 24 | * @return a new {@link InterferencePrimitivesAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static InterferencePrimitivesAssert assertThat(InterferencePrimitives actual) { 28 | return new InterferencePrimitivesAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/KeywordsAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link Keywords} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractKeywordsAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class KeywordsAssert extends AbstractKeywordsAssert { 11 | 12 | /** 13 | * Creates a new {@link KeywordsAssert} to make assertions on actual Keywords. 14 | * @param actual the Keywords we want to make assertions on. 15 | */ 16 | public KeywordsAssert(Keywords actual) { 17 | super(actual, KeywordsAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for KeywordsAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myKeywords) and get specific assertion with code completion. 23 | * @param actual the Keywords we want to make assertions on. 24 | * @return a new {@link KeywordsAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static KeywordsAssert assertThat(Keywords actual) { 28 | return new KeywordsAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/MovieAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link Movie} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractMovieAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class MovieAssert extends AbstractMovieAssert { 11 | 12 | /** 13 | * Creates a new {@link MovieAssert} to make assertions on actual Movie. 14 | * @param actual the Movie we want to make assertions on. 15 | */ 16 | public MovieAssert(Movie actual) { 17 | super(actual, MovieAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for MovieAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myMovie) and get specific assertion with code completion. 23 | * @param actual the Movie we want to make assertions on. 24 | * @return a new {@link MovieAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static MovieAssert assertThat(Movie actual) { 28 | return new MovieAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/MultipleGenericsAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.generic; 2 | 3 | /** 4 | * {@link MultipleGenerics} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractMultipleGenericsAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class MultipleGenericsAssert extends AbstractMultipleGenericsAssert, MultipleGenerics, T,U,V,W> { 11 | 12 | /** 13 | * Creates a new {@link MultipleGenericsAssert} to make assertions on actual MultipleGenerics. 14 | * @param actual the MultipleGenerics we want to make assertions on. 15 | */ 16 | public MultipleGenericsAssert(MultipleGenerics actual) { 17 | super(actual, MultipleGenericsAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for MultipleGenericsAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myMultipleGenerics) and get specific assertion with code completion. 23 | * @param actual the MultipleGenerics we want to make assertions on. 24 | * @return a new {@link MultipleGenericsAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static MultipleGenericsAssert assertThat(MultipleGenerics actual) { 28 | return new MultipleGenericsAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/MyAssertions.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.lotr; 2 | 3 | /** 4 | * Entry point for assertions of different data types. Each method in this class is a static factory for the 5 | * type-specific assertion objects. 6 | */ 7 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 8 | public class MyAssertions { 9 | 10 | /** 11 | * Creates a new instance of {@link org.assertj.assertions.generator.data.lotr.RingAssert}. 12 | * 13 | * @param actual the actual value. 14 | * @return the created assertion object. 15 | */ 16 | @org.assertj.core.util.CheckReturnValue 17 | public static org.assertj.assertions.generator.data.lotr.RingAssert assertThat(org.assertj.assertions.generator.data.lotr.Ring actual) { 18 | return new org.assertj.assertions.generator.data.lotr.RingAssert(actual); 19 | } 20 | 21 | /** 22 | * Creates a new {@link MyAssertions}. 23 | */ 24 | protected MyAssertions() { 25 | // empty 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/NameAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link Name} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractNameAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class NameAssert extends AbstractNameAssert { 11 | 12 | /** 13 | * Creates a new {@link NameAssert} to make assertions on actual Name. 14 | * @param actual the Name we want to make assertions on. 15 | */ 16 | public NameAssert(Name actual) { 17 | super(actual, NameAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for NameAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myName) and get specific assertion with code completion. 23 | * @param actual the Name we want to make assertions on. 24 | * @return a new {@link NameAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static NameAssert assertThat(Name actual) { 28 | return new NameAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/NameAssert.flat.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractComparableAssert; 5 | 6 | /** 7 | * {@link Name} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class NameAssert extends AbstractComparableAssert { 11 | 12 | /** 13 | * Creates a new {@link NameAssert} to make assertions on actual Name. 14 | * @param actual the Name we want to make assertions on. 15 | */ 16 | public NameAssert(Name actual) { 17 | super(actual, NameAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for NameAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myName) and get specific assertion with code completion. 23 | * @param actual the Name we want to make assertions on. 24 | * @return a new {@link NameAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static NameAssert assertThat(Name actual) { 28 | return new NameAssert(actual); 29 | } 30 | 31 | /** 32 | * Verifies that the actual Name's first is equal to the given one. 33 | * @param first the given first to compare the actual Name's first to. 34 | * @return this assertion object. 35 | * @throws AssertionError - if the actual Name's first is not equal to the given one. 36 | */ 37 | public NameAssert hasFirst(String first) { 38 | // check that actual Name we want to make assertions on is not null. 39 | isNotNull(); 40 | 41 | // overrides the default error message with a more explicit one 42 | String assertjErrorMessage = "\nExpecting first of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 43 | 44 | // null safe check 45 | String actualFirst = actual.getFirst(); 46 | if (!Objects.deepEquals(actualFirst, first)) { 47 | failWithMessage(assertjErrorMessage, actual, first, actualFirst); 48 | } 49 | 50 | // return the current assertion for method chaining 51 | return this; 52 | } 53 | 54 | /** 55 | * Verifies that the actual Name's last is equal to the given one. 56 | * @param last the given last to compare the actual Name's last to. 57 | * @return this assertion object. 58 | * @throws AssertionError - if the actual Name's last is not equal to the given one. 59 | */ 60 | public NameAssert hasLast(String last) { 61 | // check that actual Name we want to make assertions on is not null. 62 | isNotNull(); 63 | 64 | // overrides the default error message with a more explicit one 65 | String assertjErrorMessage = "\nExpecting last of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 66 | 67 | // null safe check 68 | String actualLast = actual.getLast(); 69 | if (!Objects.deepEquals(actualLast, last)) { 70 | failWithMessage(assertjErrorMessage, actual, last, actualLast); 71 | } 72 | 73 | // return the current assertion for method chaining 74 | return this; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/NestedClassAssert.hierarchical.template.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link ${nestedClass}} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link Abstract${nestedClass}Assert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class ${nestedClass}Assert extends Abstract${nestedClass}Assert<${nestedClass}Assert, ${nestedClass}> { 11 | 12 | /** 13 | * Creates a new {@link ${nestedClass}Assert} to make assertions on actual ${nestedClass}. 14 | * @param actual the ${nestedClass} we want to make assertions on. 15 | */ 16 | public ${nestedClass}Assert(${nestedClass} actual) { 17 | super(actual, ${nestedClass}Assert.class); 18 | } 19 | 20 | /** 21 | * An entry point for ${nestedClass}Assert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(my${nestedClass}) and get specific assertion with code completion. 23 | * @param actual the ${nestedClass} we want to make assertions on. 24 | * @return a new {@link ${nestedClass}Assert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static ${nestedClass}Assert assertThat(${nestedClass} actual) { 28 | return new ${nestedClass}Assert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/NestedClassAssert.template.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractObjectAssert; 5 | 6 | /** 7 | * {@link ${nestedClass}} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class ${nestedClass}Assert extends AbstractObjectAssert<${nestedClass}Assert, ${nestedClass}> { 11 | 12 | /** 13 | * Creates a new {@link ${nestedClass}Assert} to make assertions on actual ${nestedClass}. 14 | * @param actual the ${nestedClass} we want to make assertions on. 15 | */ 16 | public ${nestedClass}Assert(${nestedClass} actual) { 17 | super(actual, ${nestedClass}Assert.class); 18 | } 19 | 20 | /** 21 | * An entry point for ${nestedClass}Assert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(my${nestedClass}) and get specific assertion with code completion. 23 | * @param actual the ${nestedClass} we want to make assertions on. 24 | * @return a new {@link ${nestedClass}Assert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static ${nestedClass}Assert assertThat(${nestedClass} actual) { 28 | return new ${nestedClass}Assert(actual); 29 | } 30 | 31 | /** 32 | * Verifies that the actual ${nestedClass}'s name is equal to the given one. 33 | * @param name the given name to compare the actual ${nestedClass}'s name to. 34 | * @return this assertion object. 35 | * @throws AssertionError - if the actual ${nestedClass}'s name is not equal to the given one. 36 | */ 37 | public ${nestedClass}Assert hasName(String name) { 38 | // check that actual ${nestedClass} we want to make assertions on is not null. 39 | isNotNull(); 40 | 41 | // overrides the default error message with a more explicit one 42 | String assertjErrorMessage = "\nExpecting name of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 43 | 44 | // null safe check 45 | String actualName = actual.getName(); 46 | if (!Objects.deepEquals(actualName, name)) { 47 | failWithMessage(assertjErrorMessage, actual, name, actualName); 48 | } 49 | 50 | // return the current assertion for method chaining 51 | return this; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/NestedClassAssert.template.generated.in.custom.package.expected.txt: -------------------------------------------------------------------------------- 1 | package my.assertions; 2 | 3 | import java.util.Objects; 4 | import ${fullyQualifiedOuterClassName}; 5 | import org.assertj.core.api.AbstractObjectAssert; 6 | 7 | /** 8 | * {@link ${nestedClass}} specific assertions - Generated by CustomAssertionGenerator. 9 | */ 10 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 11 | public class ${nestedClass}Assert extends AbstractObjectAssert<${nestedClass}Assert, ${nestedClass}> { 12 | 13 | /** 14 | * Creates a new {@link ${nestedClass}Assert} to make assertions on actual ${nestedClass}. 15 | * @param actual the ${nestedClass} we want to make assertions on. 16 | */ 17 | public ${nestedClass}Assert(${nestedClass} actual) { 18 | super(actual, ${nestedClass}Assert.class); 19 | } 20 | 21 | /** 22 | * An entry point for ${nestedClass}Assert to follow AssertJ standard assertThat() statements.
23 | * With a static import, one can write directly: assertThat(my${nestedClass}) and get specific assertion with code completion. 24 | * @param actual the ${nestedClass} we want to make assertions on. 25 | * @return a new {@link ${nestedClass}Assert} 26 | */ 27 | @org.assertj.core.util.CheckReturnValue 28 | public static ${nestedClass}Assert assertThat(${nestedClass} actual) { 29 | return new ${nestedClass}Assert(actual); 30 | } 31 | 32 | /** 33 | * Verifies that the actual ${nestedClass}'s name is equal to the given one. 34 | * @param name the given name to compare the actual ${nestedClass}'s name to. 35 | * @return this assertion object. 36 | * @throws AssertionError - if the actual ${nestedClass}'s name is not equal to the given one. 37 | */ 38 | public ${nestedClass}Assert hasName(String name) { 39 | // check that actual ${nestedClass} we want to make assertions on is not null. 40 | isNotNull(); 41 | 42 | // overrides the default error message with a more explicit one 43 | String assertjErrorMessage = "\nExpecting name of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 44 | 45 | // null safe check 46 | String actualName = actual.getName(); 47 | if (!Objects.deepEquals(actualName, name)) { 48 | failWithMessage(assertjErrorMessage, actual, name, actualName); 49 | } 50 | 51 | // return the current assertion for method chaining 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/OptionalAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package com.google.common.base; 2 | 3 | /** 4 | * {@link Optional} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractOptionalAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class OptionalAssert extends AbstractOptionalAssert { 11 | 12 | /** 13 | * Creates a new {@link OptionalAssert} to make assertions on actual Optional. 14 | * @param actual the Optional we want to make assertions on. 15 | */ 16 | public OptionalAssert(Optional actual) { 17 | super(actual, OptionalAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for OptionalAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myOptional) and get specific assertion with code completion. 23 | * @param actual the Optional we want to make assertions on. 24 | * @return a new {@link OptionalAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static OptionalAssert assertThat(Optional actual) { 28 | return new OptionalAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/OptionalAssert.flat.expected.txt: -------------------------------------------------------------------------------- 1 | package com.google.common.base; 2 | 3 | import org.assertj.core.api.AbstractObjectAssert; 4 | 5 | /** 6 | * {@link Optional} specific assertions - Generated by CustomAssertionGenerator. 7 | */ 8 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 9 | public class OptionalAssert extends AbstractObjectAssert { 10 | 11 | /** 12 | * Creates a new {@link OptionalAssert} to make assertions on actual Optional. 13 | * @param actual the Optional we want to make assertions on. 14 | */ 15 | public OptionalAssert(Optional actual) { 16 | super(actual, OptionalAssert.class); 17 | } 18 | 19 | /** 20 | * An entry point for OptionalAssert to follow AssertJ standard assertThat() statements.
21 | * With a static import, one can write directly: assertThat(myOptional) and get specific assertion with code completion. 22 | * @param actual the Optional we want to make assertions on. 23 | * @return a new {@link OptionalAssert} 24 | */ 25 | @org.assertj.core.util.CheckReturnValue 26 | public static OptionalAssert assertThat(Optional actual) { 27 | return new OptionalAssert(actual); 28 | } 29 | 30 | /** 31 | * Verifies that the actual Optional is present. 32 | * @return this assertion object. 33 | * @throws AssertionError - if the actual Optional is not present. 34 | */ 35 | public OptionalAssert isPresent() { 36 | // check that actual Optional we want to make assertions on is not null. 37 | isNotNull(); 38 | 39 | // check that property call/field access is true 40 | if (!actual.isPresent()) { 41 | failWithMessage("\nExpecting that actual Optional is present but is not."); 42 | } 43 | 44 | // return the current assertion for method chaining 45 | return this; 46 | } 47 | 48 | /** 49 | * Verifies that the actual Optional is not present. 50 | * @return this assertion object. 51 | * @throws AssertionError - if the actual Optional is present. 52 | */ 53 | public OptionalAssert isNotPresent() { 54 | // check that actual Optional we want to make assertions on is not null. 55 | isNotNull(); 56 | 57 | // check that property call/field access is false 58 | if (actual.isPresent()) { 59 | failWithMessage("\nExpecting that actual Optional is not present but is."); 60 | } 61 | 62 | // return the current assertion for method chaining 63 | return this; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/PlayerAgentAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.nba; 2 | 3 | /** 4 | * {@link PlayerAgent} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractPlayerAgentAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class PlayerAgentAssert extends AbstractPlayerAgentAssert { 11 | 12 | /** 13 | * Creates a new {@link PlayerAgentAssert} to make assertions on actual PlayerAgent. 14 | * @param actual the PlayerAgent we want to make assertions on. 15 | */ 16 | public PlayerAgentAssert(PlayerAgent actual) { 17 | super(actual, PlayerAgentAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for PlayerAgentAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myPlayerAgent) and get specific assertion with code completion. 23 | * @param actual the PlayerAgent we want to make assertions on. 24 | * @return a new {@link PlayerAgentAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static PlayerAgentAssert assertThat(PlayerAgent actual) { 28 | return new PlayerAgentAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/PlayerAgentAssert.flat.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.nba; 2 | 3 | import java.util.Objects; 4 | import org.assertj.core.api.AbstractObjectAssert; 5 | 6 | /** 7 | * {@link PlayerAgent} specific assertions - Generated by CustomAssertionGenerator. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class PlayerAgentAssert extends AbstractObjectAssert { 11 | 12 | /** 13 | * Creates a new {@link PlayerAgentAssert} to make assertions on actual PlayerAgent. 14 | * @param actual the PlayerAgent we want to make assertions on. 15 | */ 16 | public PlayerAgentAssert(PlayerAgent actual) { 17 | super(actual, PlayerAgentAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for PlayerAgentAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myPlayerAgent) and get specific assertion with code completion. 23 | * @param actual the PlayerAgent we want to make assertions on. 24 | * @return a new {@link PlayerAgentAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static PlayerAgentAssert assertThat(PlayerAgent actual) { 28 | return new PlayerAgentAssert(actual); 29 | } 30 | 31 | /** 32 | * Verifies that the actual PlayerAgent's managedPlayer is equal to the given one. 33 | * @param managedPlayer the given managedPlayer to compare the actual PlayerAgent's managedPlayer to. 34 | * @return this assertion object. 35 | * @throws AssertionError - if the actual PlayerAgent's managedPlayer is not equal to the given one. 36 | */ 37 | public PlayerAgentAssert hasManagedPlayer(Player managedPlayer) { 38 | // check that actual PlayerAgent we want to make assertions on is not null. 39 | isNotNull(); 40 | 41 | // overrides the default error message with a more explicit one 42 | String assertjErrorMessage = "\nExpecting managedPlayer of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 43 | 44 | // null safe check 45 | Player actualManagedPlayer = actual.getManagedPlayer(); 46 | if (!Objects.deepEquals(actualManagedPlayer, managedPlayer)) { 47 | failWithMessage(assertjErrorMessage, actual, managedPlayer, actualManagedPlayer); 48 | } 49 | 50 | // return the current assertion for method chaining 51 | return this; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/PlayerAgentAssert.generated.in.custom.package.expected.txt: -------------------------------------------------------------------------------- 1 | package my.assertions; 2 | 3 | import org.assertj.assertions.generator.data.nba.PlayerAgent; 4 | 5 | /** 6 | * {@link PlayerAgent} specific assertions - Generated by CustomAssertionGenerator. 7 | * 8 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 9 | * extend {@link AbstractPlayerAgentAssert} instead. 10 | */ 11 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 12 | public class PlayerAgentAssert extends AbstractPlayerAgentAssert { 13 | 14 | /** 15 | * Creates a new {@link PlayerAgentAssert} to make assertions on actual PlayerAgent. 16 | * @param actual the PlayerAgent we want to make assertions on. 17 | */ 18 | public PlayerAgentAssert(PlayerAgent actual) { 19 | super(actual, PlayerAgentAssert.class); 20 | } 21 | 22 | /** 23 | * An entry point for PlayerAgentAssert to follow AssertJ standard assertThat() statements.
24 | * With a static import, one can write directly: assertThat(myPlayerAgent) and get specific assertion with code completion. 25 | * @param actual the PlayerAgent we want to make assertions on. 26 | * @return a new {@link PlayerAgentAssert} 27 | */ 28 | @org.assertj.core.util.CheckReturnValue 29 | public static PlayerAgentAssert assertThat(PlayerAgent actual) { 30 | return new PlayerAgentAssert(actual); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/PlayerAgentAssert.generated.in.custom.package.flat.expected.txt: -------------------------------------------------------------------------------- 1 | package my.assertions; 2 | 3 | import java.util.Objects; 4 | import org.assertj.assertions.generator.data.nba.PlayerAgent; 5 | import org.assertj.core.api.AbstractObjectAssert; 6 | 7 | /** 8 | * {@link PlayerAgent} specific assertions - Generated by CustomAssertionGenerator. 9 | */ 10 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 11 | public class PlayerAgentAssert extends AbstractObjectAssert { 12 | 13 | /** 14 | * Creates a new {@link PlayerAgentAssert} to make assertions on actual PlayerAgent. 15 | * @param actual the PlayerAgent we want to make assertions on. 16 | */ 17 | public PlayerAgentAssert(PlayerAgent actual) { 18 | super(actual, PlayerAgentAssert.class); 19 | } 20 | 21 | /** 22 | * An entry point for PlayerAgentAssert to follow AssertJ standard assertThat() statements.
23 | * With a static import, one can write directly: assertThat(myPlayerAgent) and get specific assertion with code completion. 24 | * @param actual the PlayerAgent we want to make assertions on. 25 | * @return a new {@link PlayerAgentAssert} 26 | */ 27 | @org.assertj.core.util.CheckReturnValue 28 | public static PlayerAgentAssert assertThat(PlayerAgent actual) { 29 | return new PlayerAgentAssert(actual); 30 | } 31 | 32 | /** 33 | * Verifies that the actual PlayerAgent's managedPlayer is equal to the given one. 34 | * @param managedPlayer the given managedPlayer to compare the actual PlayerAgent's managedPlayer to. 35 | * @return this assertion object. 36 | * @throws AssertionError - if the actual PlayerAgent's managedPlayer is not equal to the given one. 37 | */ 38 | public PlayerAgentAssert hasManagedPlayer(org.assertj.assertions.generator.data.nba.Player managedPlayer) { 39 | // check that actual PlayerAgent we want to make assertions on is not null. 40 | isNotNull(); 41 | 42 | // overrides the default error message with a more explicit one 43 | String assertjErrorMessage = "\nExpecting managedPlayer of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 44 | 45 | // null safe check 46 | org.assertj.assertions.generator.data.nba.Player actualManagedPlayer = actual.getManagedPlayer(); 47 | if (!Objects.deepEquals(actualManagedPlayer, managedPlayer)) { 48 | failWithMessage(assertjErrorMessage, actual, managedPlayer, actualManagedPlayer); 49 | } 50 | 51 | // return the current assertion for method chaining 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/PlayerAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data.nba; 2 | 3 | /** 4 | * {@link Player} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractPlayerAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class PlayerAssert extends AbstractPlayerAssert { 11 | 12 | /** 13 | * Creates a new {@link PlayerAssert} to make assertions on actual Player. 14 | * @param actual the Player we want to make assertions on. 15 | */ 16 | public PlayerAssert(Player actual) { 17 | super(actual, PlayerAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for PlayerAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myPlayer) and get specific assertion with code completion. 23 | * @param actual the Player we want to make assertions on. 24 | * @return a new {@link PlayerAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static PlayerAssert assertThat(Player actual) { 28 | return new PlayerAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/PlayerAssert.generated.in.custom.package.expected.txt: -------------------------------------------------------------------------------- 1 | package my.assertions; 2 | 3 | import org.assertj.assertions.generator.data.nba.Player; 4 | 5 | /** 6 | * {@link Player} specific assertions - Generated by CustomAssertionGenerator. 7 | * 8 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 9 | * extend {@link AbstractPlayerAssert} instead. 10 | */ 11 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 12 | public class PlayerAssert extends AbstractPlayerAssert { 13 | 14 | /** 15 | * Creates a new {@link PlayerAssert} to make assertions on actual Player. 16 | * @param actual the Player we want to make assertions on. 17 | */ 18 | public PlayerAssert(Player actual) { 19 | super(actual, PlayerAssert.class); 20 | } 21 | 22 | /** 23 | * An entry point for PlayerAssert to follow AssertJ standard assertThat() statements.
24 | * With a static import, one can write directly: assertThat(myPlayer) and get specific assertion with code completion. 25 | * @param actual the Player we want to make assertions on. 26 | * @return a new {@link PlayerAssert} 27 | */ 28 | @org.assertj.core.util.CheckReturnValue 29 | public static PlayerAssert assertThat(Player actual) { 30 | return new PlayerAssert(actual); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/PrimitivesAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link Primitives} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractPrimitivesAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class PrimitivesAssert extends AbstractPrimitivesAssert { 11 | 12 | /** 13 | * Creates a new {@link PrimitivesAssert} to make assertions on actual Primitives. 14 | * @param actual the Primitives we want to make assertions on. 15 | */ 16 | public PrimitivesAssert(Primitives actual) { 17 | super(actual, PrimitivesAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for PrimitivesAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myPrimitives) and get specific assertion with code completion. 23 | * @param actual the Primitives we want to make assertions on. 24 | * @return a new {@link PrimitivesAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static PrimitivesAssert assertThat(Primitives actual) { 28 | return new PrimitivesAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/TeamAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link Team} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractTeamAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class TeamAssert extends AbstractTeamAssert { 11 | 12 | /** 13 | * Creates a new {@link TeamAssert} to make assertions on actual Team. 14 | * @param actual the Team we want to make assertions on. 15 | */ 16 | public TeamAssert(Team actual) { 17 | super(actual, TeamAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for TeamAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myTeam) and get specific assertion with code completion. 23 | * @param actual the Team we want to make assertions on. 24 | * @return a new {@link TeamAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static TeamAssert assertThat(Team actual) { 28 | return new TeamAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/WithPrivateFieldsAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link WithPrivateFields} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractWithPrivateFieldsAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class WithPrivateFieldsAssert extends AbstractWithPrivateFieldsAssert { 11 | 12 | /** 13 | * Creates a new {@link WithPrivateFieldsAssert} to make assertions on actual WithPrivateFields. 14 | * @param actual the WithPrivateFields we want to make assertions on. 15 | */ 16 | public WithPrivateFieldsAssert(WithPrivateFields actual) { 17 | super(actual, WithPrivateFieldsAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for WithPrivateFieldsAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myWithPrivateFields) and get specific assertion with code completion. 23 | * @param actual the WithPrivateFields we want to make assertions on. 24 | * @return a new {@link WithPrivateFieldsAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static WithPrivateFieldsAssert assertThat(WithPrivateFields actual) { 28 | return new WithPrivateFieldsAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/WithPrivateFieldsParentAssert.expected.txt: -------------------------------------------------------------------------------- 1 | package org.assertj.assertions.generator.data; 2 | 3 | /** 4 | * {@link WithPrivateFieldsParent} specific assertions - Generated by CustomAssertionGenerator. 5 | * 6 | * Although this class is not final to allow Soft assertions proxy, if you wish to extend it, 7 | * extend {@link AbstractWithPrivateFieldsParentAssert} instead. 8 | */ 9 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 10 | public class WithPrivateFieldsParentAssert extends AbstractWithPrivateFieldsParentAssert { 11 | 12 | /** 13 | * Creates a new {@link WithPrivateFieldsParentAssert} to make assertions on actual WithPrivateFieldsParent. 14 | * @param actual the WithPrivateFieldsParent we want to make assertions on. 15 | */ 16 | public WithPrivateFieldsParentAssert(WithPrivateFieldsParent actual) { 17 | super(actual, WithPrivateFieldsParentAssert.class); 18 | } 19 | 20 | /** 21 | * An entry point for WithPrivateFieldsParentAssert to follow AssertJ standard assertThat() statements.
22 | * With a static import, one can write directly: assertThat(myWithPrivateFieldsParent) and get specific assertion with code completion. 23 | * @param actual the WithPrivateFieldsParent we want to make assertions on. 24 | * @return a new {@link WithPrivateFieldsParentAssert} 25 | */ 26 | @org.assertj.core.util.CheckReturnValue 27 | public static WithPrivateFieldsParentAssert assertThat(WithPrivateFieldsParent actual) { 28 | return new WithPrivateFieldsParentAssert(actual); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/customtemplates/custom_has_assertion_template_for_whole_number.txt: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one. 4 | * @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to. 5 | * @return this assertion object. 6 | * @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc} 7 | */ 8 | public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{ 9 | // check that actual ${class_to_assert} we want to make assertions on is not null. 10 | isNotNull(); 11 | 12 | System.out.println("Custom template for whole number"); 13 | 14 | // overrides the default error message with a more explicit one 15 | String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 16 | 17 | // check 18 | ${propertyType} actual${Property} = actual.get${Property}(); 19 | if (actual${Property} != ${property_safe}) { 20 | failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property}); 21 | } 22 | 23 | // return the current assertion for method chaining 24 | return ${myself}; 25 | } -------------------------------------------------------------------------------- /assertj-generator/src/test/resources/customtemplates/my_assertion_entry_point_class.txt: -------------------------------------------------------------------------------- 1 | package ${package}; 2 | 3 | /** 4 | * Entry point for assertions of different data types. Each method in this class is a static factory for the 5 | * type-specific assertion objects. 6 | */ 7 | @javax.annotation.processing.Generated(value="assertj-assertions-generator") 8 | public class MyAssertions { 9 | ${all_assertions_entry_points} 10 | /** 11 | * Creates a new {@link MyAssertions}. 12 | */ 13 | protected MyAssertions() { 14 | // empty 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /build-assertion-generator-and-maven-plugin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo '' 3 | echo 'Build AssertJ assertion generator ...' 4 | echo '' 5 | mvn clean install 6 | 7 | echo '' 8 | echo '' 9 | echo 'Build AssertJ assertion generator maven plugin ...' 10 | echo '' 11 | cd ../assertj-assertions-generator-maven-plugin 12 | mvn clean install 13 | 14 | # go back to previous directory 15 | cd - 16 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.assertj 7 | assertj-parent 8 | 3.27.3 9 | 10 | 11 | assertj-generator-build 12 | 3.0.0-M6-SNAPSHOT 13 | pom 14 | 15 | AssertJ Generator Build 16 | 17 | 18 | assertj-generator 19 | 20 | 21 | 22 | scm:git:https://github.com/assertj/assertj-generator.git 23 | scm:git:https://github.com/assertj/assertj-generator.git 24 | https://github.com/assertj/assertj-generator 25 | HEAD 26 | 27 | 28 | GitHub 29 | https://github.com/assertj/assertj-generator/issues 30 | 31 | 32 | 33 | 34 | 35 | org.sonatype.plugins 36 | nexus-staging-maven-plugin 37 | 38 | 39 | 40 | 41 | --------------------------------------------------------------------------------