Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = 1.0
# Note that if --release is added then -target and -source are ignored.
javacRelease = 8

assertjVersion = 3.27.6
assertjVersion = 3.27.7
assertjJodaTimeVersion = 2.2.0
assertjDbVersion = 2.0.2
ota4jVersion = 1.2.0
Expand Down
25 changes: 13 additions & 12 deletions src/docs/asciidoc/link-attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
:assertj-core-javadoc-root: https://www.javadoc.io/doc/org.assertj/assertj-core/latest/
:assertj-guava-javadoc-root: https://www.javadoc.io/doc/org.assertj/assertj-guava/latest/
:assertj-joda-time-javadoc-root: https://www.javadoc.io/doc/org.assertj/assertj-joda-time/latest/
:assertj-core-javadoc: https://www.javadoc.io/doc/org.assertj/assertj-core/{assertj-version}
:assertj-guava-javadoc: https://www.javadoc.io/doc/org.assertj/assertj-guava/{assertj-version}
:assertj-joda-time-javadoc: https://www.javadoc.io/doc/org.assertj/assertj-joda-time/{assertj-joda-time-version}
//
:assertj-core-repo: https://github.com/assertj/assertj
:assertj-examples-repo: https://github.com/assertj/assertj-examples
:assertj-examples-base-package: https://github.com/assertj/assertj-examples/blob/main/assertions-examples/src/test/java/org/assertj/examples/
:assertj-guava-repo: https://github.com/assertj/assertj
:assertj-swing-repo: https://github.com/assertj/assertj-swing
:release-branch: main
:current-branch: {assertj-core-repo}/tree/{release-branch}
:assertj-core-github: https://github.com/assertj/assertj
:assertj-doc-github: https://github.com/assertj/doc
:assertj-examples-github: https://github.com/assertj/assertj-examples
:assertj-examples-base-package: https://github.com/assertj/assertj-examples/blob/main/assertions-examples/src/test/java/org/assertj/examples
:assertj-guava-github: https://github.com/assertj/assertj
:assertj-swing-github: https://github.com/assertj/assertj-swing
:release-branch: main
:current-branch: {assertj-core-github}/tree/{release-branch}
//
:AssertJ: https://assertj.github.io/doc/[AssertJ]
:StackOverflow: https://stackoverflow.com/questions/tagged/assertj[Stack Overflow]
:AssertJ: https://assertj.github.io/doc/[AssertJ]
:StackOverflow: https://stackoverflow.com/questions/tagged/assertj[Stack Overflow]
40 changes: 20 additions & 20 deletions src/docs/asciidoc/user-guide/assertj-core-assertions-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This section describes the assertions provided by AssertJ Core and other useful features to get the best of it.

AssertJ Core http://www.javadoc.io/doc/org.assertj/assertj-core/[Javadoc] explains each assertion, most of them with code examples so be sure to check it if you want to know what a specific assertion does.
AssertJ Core {assertj-core-javadoc}[Javadoc] explains each assertion, most of them with code examples so be sure to check it if you want to know what a specific assertion does.

[[assertj-core-simple-example]]
==== A simple example
Expand Down Expand Up @@ -758,19 +758,19 @@ expected: JEDI [name=Luke, age=23]
[[assertj-core-common-assertions]]
==== Common assertions

This section describes the assertions common to all types, the Javadoc for common assertions methods is available https://www.javadoc.io/static/org.assertj/assertj-core/{assertj-version}/org/assertj/core/api/AbstractAssert.html#method.summary[here].
This section describes the assertions common to all types, the Javadoc for common assertions methods is available {assertj-core-javadoc}/org/assertj/core/api/AbstractAssert.html#method.summary[here].

[[assertj-core-object-assertions]]
==== Object assertions

The Javadoc for `Object` assertions is available https://www.javadoc.io/static/org.assertj/assertj-core/{assertj-version}/org/assertj/core/api/AbstractObjectAssert.html#method.summary[here].
The Javadoc for `Object` assertions is available {assertj-core-javadoc}/org/assertj/core/api/AbstractObjectAssert.html#method.summary[here].

[[assertj-string-object-assertions]]
==== String/CharSequence assertions

This section describes all the available assertions for `CharSequence` (including `String`, `StringBuilder`, `StringBuffer`, ...):

The Javadoc for `CharSequence` assertions is available https://www.javadoc.io/static/org.assertj/assertj-core/{assertj-version}/org/assertj/core/api/AbstractCharSequenceAssert.html#method.summary[here].
The Javadoc for `CharSequence` assertions is available {assertj-core-javadoc}/org/assertj/core/api/AbstractCharSequenceAssert.html#method.summary[here].


[[assertj-core-group-assertions]]
Expand All @@ -781,8 +781,8 @@ The Javadoc for `CharSequence` assertions is available https://www.javadoc.io/st

All the available assertions are described in:

* iterables: {assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#method.summary
* arrays: {assertj-core-javadoc-root}org/assertj/core/api/AbstractObjectArrayAssert.html#method.summary
* iterables: {assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#method.summary
* arrays: {assertj-core-javadoc}/org/assertj/core/api/AbstractObjectArrayAssert.html#method.summary

The next sections focus on some features worth knowing to get the best of AssertJ, notably:

Expand All @@ -802,28 +802,28 @@ There are different flavors of `contains` assertion, here's a table to help choo
|===
|Assertion |Description

|{assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#contains(ELEMENT...)[`contains`]
|{assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#contains(ELEMENT...)[`contains`]
|Verifies that the actual iterable/array contains the given values in any order

|{assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#containsOnly(ELEMENT...)[`containsOnly`]
|{assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#containsOnly(ELEMENT...)[`containsOnly`]
|Verifies that the actual group contains only the given values and nothing else in any order and ignoring duplicates (i.e. once a value is found, its duplicates are also considered found)

|{assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#containsExactly(ELEMENT...)[`containsExactly`]
|{assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#containsExactly(ELEMENT...)[`containsExactly`]
|Verifies that the actual iterable/array contains exactly the given values and nothing else **in order**

|{assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#containsExactlyInAnyOrder(ELEMENT...)[`containsExactlyInAnyOrder`]
|{assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#containsExactlyInAnyOrder(ELEMENT...)[`containsExactlyInAnyOrder`]
|Verifies that the actual iterable/array contains exactly the given values and nothing else **in any order**

|{assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#containsSequence(ELEMENT...)[`containsSequence`]
|{assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#containsSequence(ELEMENT...)[`containsSequence`]
|Verifies that the actual group contains the given sequence in the correct order and **without extra values between the sequence values**

|{assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#containsSubsequence(ELEMENT...)[`containsSubsequence`]
|{assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#containsSubsequence(ELEMENT...)[`containsSubsequence`]
|Verifies that the actual group contains the given subsequence in the correct order **possibly with other values between them**

|{assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#containsOnlyOnce(ELEMENT...)[`containsOnlyOnce`]
|{assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#containsOnlyOnce(ELEMENT...)[`containsOnlyOnce`]
|Verifies that the actual iterable/array contains the given values only once

|{assertj-core-javadoc-root}org/assertj/core/api/AbstractIterableAssert.html#containsAnyOf(ELEMENT...)[`containsAnyOf`]
|{assertj-core-javadoc}/org/assertj/core/api/AbstractIterableAssert.html#containsAnyOf(ELEMENT...)[`containsAnyOf`]
|Verifies that the actual iterable/array contains at least one of the given values (like an `or` operator on the given values)

|===
Expand Down Expand Up @@ -954,7 +954,7 @@ Filtering is handy to target assertions on some specific elements, the filter cr
* an element link:#filtering-elements-matching-given-assertions[matching some assertions]
* an element matching a link:#filtering-with-a-condition[Condition]

Let's explore these options in some examples taken from {assertj-examples-repo}/tree/main/assertions-examples/src/test/java/org/assertj/examples/FilterExamples.java#L47[FilterExamples] from the {assertj-examples-repo}[assertions-examples] project.
Let's explore these options in some examples taken from {assertj-examples-github}/tree/main/assertions-examples/src/test/java/org/assertj/examples/FilterExamples.java#L47[FilterExamples] from the {assertj-examples-github}[assertions-examples] project.

====== Filtering with a Predicate

Expand Down Expand Up @@ -1148,7 +1148,7 @@ assertThat(fellowshipOfTheRing).extracting("name", String.class)

====== Extracting multiple values

You can extract several values from the elements under test and check them using {assertj-core-javadoc-root}org/assertj/core/api/Assertions.html#tuple(java.lang.Object...)[tuples].
You can extract several values from the elements under test and check them using {assertj-core-javadoc}/org/assertj/core/api/Assertions.html#tuple(java.lang.Object...)[tuples].

As an example, let's check the name, age and race's name of each TolkienCharacter element:

Expand All @@ -1174,7 +1174,7 @@ assertThat(fellowshipOfTheRing).extracting(TolkienCharacter::getName,

The extracted name, age and race's name values of the current element are grouped in a tuple, thus you need to use tuples for specifying the expected values.

More examples are available in link:{assertj-examples-base-package}IterableAssertionsExamples.java#L210[IterableAssertionsExamples.java] of the link:{assertj-examples-repo}[assertj-examples] project.
More examples are available in link:{assertj-examples-base-package}/IterableAssertionsExamples.java#L210[IterableAssertionsExamples.java] of the link:{assertj-examples-github}[assertj-examples] project.

[[group-flat-extracting]]
====== Extracting and flattening multiple values per element
Expand Down Expand Up @@ -1248,7 +1248,7 @@ This chapter answers the question: how to assert that an exception has been thro
[[assertj-core-exception-assertions-reference]]
===== Reference

All the available assertions are described in the link:{assertj-core-javadoc-root}org/assertj/core/api/AbstractThrowableAssert.html#method.summary[AbstractThrowableAssert javadoc].
All the available assertions are described in the link:{assertj-core-javadoc}/org/assertj/core/api/AbstractThrowableAssert.html#method.summary[`AbstractThrowableAssert` Javadoc].

In this chapter the term `exception` is used interchangeably with `throwable`.

Expand All @@ -1269,7 +1269,7 @@ If you use java 7, check the link:#assertj-core-exception-assertions-java-7[Java

There are various ways for checking the exception message content, you can check the exact message, what it contains, its start, its end, if it matches a regex.

Most of the assertions expecting a `String` can use the https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true#format-java.lang.String-java.lang.Object...-[String.format] syntax.
Most of the assertions expecting a `String` can use the https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true#format-java.lang.String-java.lang.Object\...-[String.format] syntax.

Examples:
[source,java]
Expand Down Expand Up @@ -2750,4 +2750,4 @@ include::{testDir}/example/core/AssumptionsDemo.java[tags=assumption_met]
[[assertj-core-javadoc]]
==== Javadoc

http://www.javadoc.io/doc/org.assertj/assertj-core/ is the latest version of AssertJ Core Javadoc, each assertion is explained, most of them with code examples so be sure to check it if you want to know what a specific assertion does.
{assertj-core-javadoc} is the latest version of AssertJ Core Javadoc, each assertion is explained, most of them with code examples so be sure to check it if you want to know what a specific assertion does.
20 changes: 10 additions & 10 deletions src/docs/asciidoc/user-guide/assertj-core-extension.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AssertJ can be extends by Condition or writing your own assertions class.
[[assertj-core-conditions]]
==== Conditions

Assertions can be extended by using conditions, to create a condition you just have to implement https://www.javadoc.io/doc/org.assertj/assertj-core/latest/org/assertj/core/api/Condition.html[`org.assertj.assertions.core.Condition`] and its unique method matches.
Assertions can be extended by using conditions, to create a condition you just have to implement {assertj-core-javadoc}/org/assertj/core/api/Condition.html[`org.assertj.assertions.core.Condition`] and its unique method matches.

Once your Condition is created, you can use it with methods: `is(myCondition)` or `has(myCondition)`, both verifying that the condition is met (hint: pick the one that makes your code more readable).

Expand All @@ -32,7 +32,7 @@ You can verify that a Condition is met on elements of a collection, with the fol

Moreover all Condition related methods have their negation counterpart, `is`/`isNot`, `have`/`doesNotHave`, `are`/`areNot`, ...

The examples below are from https://github.com/assertj/assertj-examples/[assertj-examples] and more specifically https://github.com/assertj/assertj-examples/blob/main/assertions-examples/src/test/java/org/assertj/examples/condition/UsingConditionExamples.java[UsingConditionExamples.java].
The examples below are from {assertj-examples-github}[assertj-examples] and more specifically {assertj-examples-base-package}/condition/UsingConditionExamples.java[`UsingConditionExamples`].

[[assertj-core-condition-creation]]
===== Creating a Condition
Expand All @@ -46,7 +46,7 @@ import static org.assertj.core.util.Sets.newLinkedHashSet;
static Set<String> JEDIS = newLinkedHashSet("Luke", "Yoda", "Obiwan");

// implementation with Java 8 lambda
Condition<String> jediPower = new Condition<>(JEDIS::contains, "jedi power");
Condition<String> jediPower = new Condition<>(JEDIS::contains, "jedi power");

// implementation with Java 7
Condition<String> jedi = new Condition<String>("jedi") {
Expand Down Expand Up @@ -115,7 +115,7 @@ Let's define a sith condition:
[source,java]
----
List<String> SITHS = list("Sidious", "Vader", "Plagueis");
Condition<String> sith = new Condition<>(SITHS::contains, "sith");
Condition<String> sith = new Condition<>(SITHS::contains, "sith");
----

We can write these assertions:
Expand Down Expand Up @@ -147,7 +147,7 @@ Sections:

Let's see how to do that with an example!

The example is taken from https://github.com/assertj/assertj-examples/[assertj-examples] and more specifically https://github.com/assertj/assertj-examples/blob/main/assertions-examples/src/test/java/org/assertj/examples/custom/TolkienCharacterAssert.java[TolkienCharacterAssert.java].
The example is taken from {assertj-examples}/[assertj-examples] and more specifically {assertj-examples-base-package}/custom/TolkienCharacterAssert.java[TolkienCharacterAssert.java].

We want to have assertion for the `TolkienCharacter` domain model class shown below:
[source,java]
Expand Down Expand Up @@ -210,7 +210,7 @@ public class TolkienCharacterAssert extends AbstractAssert<TolkienCharacterAsser
To use our custom assertion class, simply call the `assertThat` factory method with the object to test:
[source,java]
----
// use assertThat from TolkienCharacterAssert to check TolkienCharacter
// use assertThat from TolkienCharacterAssert to check TolkienCharacter
TolkienCharacterAssert.assertThat(frodo).hasName("Frodo");

// code is more elegant when TolkienCharacterAssert.assertThat is imported statically :
Expand All @@ -222,19 +222,19 @@ Well, that was not too difficult, but having to add a static import for each `as
[[assertj-core-custom-assertions-entry-point]]
===== Providing an entry point for all custom assertions

Now that you have a bunch of custom assertions classes, you want to access them easily. Just create a `CustomAssertions` class providing static `assertThat` methods for each of your assertions classes.
Now that you have a bunch of custom assertions classes, you want to access them easily. Just create a `CustomAssertions` class providing static `assertThat` methods for each of your assertions classes.

Example:
[source,java]
----
public class MyProjectAssertions {

// give access to TolkienCharacter assertion
// give access to TolkienCharacter assertion
public static TolkienCharacterAssert assertThat(TolkienCharacter actual) {
return new TolkienCharacterAssert(actual);
}

// give access to TolkienCharacter Race assertion
// give access to TolkienCharacter Race assertion
public static RaceAssert assertThat(Race actual) {
return new RaceAssert(actual);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ import static my.project.MyOtherAssertions.assertThat;
@Test
public void ambiguous_assertThat_resolution() {
// ERROR: assertThat(String) is ambiguous!
// assertThat(String) is available from MyAssertions AND MyOtherAssertions
// assertThat(String) is available from MyAssertions AND MyOtherAssertions
// (it is defined in Assertions the class both MyAssertions and MyOtherAssertions inherits from)
assertThat("frodo").contains("do");
}
Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/user-guide/assertj-core-migration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ If the `*Test.java` file pattern does not suit you, just specify another as an a
After executing it, you will need to :

* Optimize imports with your IDE to remove unused imports.
* If you were using `assertEquals` with a delta to compare numbers, you will need to statically import `org.assertj.core.api.Assertions.within` which is how you express deltas in AssertJ (see the {assertj-examples-repo}/blob/main/assertions-examples/src/test/java/org/assertj/examples/NumberAssertionsExamples.java[number_assertions_with_offset_examples()] test at the end of `NumberAssertionsExamples`).
* If you were using `assertEquals` with a delta to compare numbers, you will need to statically import `org.assertj.core.api.Assertions.within` which is how you express deltas in AssertJ (see the {assertj-examples-github}/blob/main/assertions-examples/src/test/java/org/assertj/examples/NumberAssertionsExamples.java[number_assertions_with_offset_examples()] test at the end of `NumberAssertionsExamples`).

===== Script output

Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/user-guide/assertj-core-quickstart.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ image::ide-completion.png[]
[[assertj-core-javadoc-quickstart]]
==== Javadoc

http://www.javadoc.io/doc/org.assertj/assertj-core/ is the latest version of AssertJ Core Javadoc, each assertion is explained, most of them with code examples so be sure to check it if you want to know what a specific assertion does.
{assertj-core-javadoc} is the latest version of AssertJ Core Javadoc, each assertion is explained, most of them with code examples so be sure to check it if you want to know what a specific assertion does.
Loading