Skip to content

Commit

Permalink
Javadoc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-costigliola committed Jan 23, 2021
1 parent bb13aac commit 52c6a28
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public SELF hasFieldOrPropertyWithValue(String name, Object value) {
* // assertion succeeds:
* assertThat(frodo).hasOnlyFields("name", "age");
*
* // assertions fail :
* // assertions fail:
* assertThat(frodo).hasOnlyFields("name");
* assertThat(frodo).hasOnlyFields("not_exists");
* assertThat(frodo).hasOnlyFields(null);</code></pre>
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/org/assertj/core/api/Descriptable.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ public interface Descriptable<SELF> {
* <p>
* Example :
* <pre><code class='java'> try {
* // set a bad age to Mr Frodo which is really 33 years old.
* // set an incorrect age to Mr Frodo which is really 33 years old.
* frodo.setAge(50);
* // specify a test description (call as() before the assertion !), it supports String format syntax.
* assertThat(frodo.getAge()).as(&quot;check %s's age&quot;, frodo.getName()).isEqualTo(33);
* } catch (AssertionError e) {
* assertThat(e).hasMessage(&quot;[check Frodo's age] expected:&lt;[33]&gt; but was:&lt;[50]&gt;&quot;);
* assertThat(e).hasMessage(&quot;[check Frodo's age]\n
* expected: 33\n
* but was : 50&quot;);
* }</code></pre>
*
* @param description the new description to set.
Expand All @@ -65,20 +67,22 @@ default SELF as(String description, Object... args) {
* the chained call by throwing an AssertionError.
* <p>
* Example :
* <pre><code class='java'> // set a bad age to Mr Frodo which we all know is 33 years old.
* <pre><code class='java'> // set an incorrect age to Mr Frodo which we all know is 33 years old.
* frodo.setAge(50);
*
* // the lazy test description supplier is <b>not</b> evaluated as the assertion succeeds
* // the lazy test description is <b>not</b> evaluated as the assertion succeeds
* assertThat(frodo.getAge()).as(() -&gt; &quot;check Frodo's age&quot;).isEqualTo(50);
*
* try
* {
* // the lazy test description supplier is evaluated as the assertion fails
* // the lazy test description is evaluated as the assertion fails
* assertThat(frodo.getAge()).as(() -&gt; &quot;check Frodo's age&quot;).isEqualTo(33);
* }
* catch (AssertionError e)
* {
* assertThat(e).hasMessage(&quot;[check Frodo's age] expected:&lt;[33]&gt; but was:&lt;[50]&gt;&quot;);
* assertThat(e).hasMessage(&quot;[check Frodo's age]\n
* expected: 33\n
* but was : 50&quot;);
* }</code></pre>
*
* @param descriptionSupplier the description {@link Supplier}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
* Verifies that each element satisfies the requirements corresponding to its index, so the first element must satisfy the
* first requirements, the second element the second requirements etc...
* <p>
* Each requirements is expressed as a {@link Consumer}, there must be as many requirements as there are iterable elements.
* Each requirements are expressed as a {@link Consumer}, there must be as many requirements as there are iterable elements.
* <p>
* Example:
* <pre><code class='java'> Iterable&lt;TolkienCharater&gt; characters = list(frodo, aragorn, legolas);
Expand Down Expand Up @@ -1309,7 +1309,7 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
*
* @param allRequirements the requirements to meet.
* @return {@code this} to chain assertions.
* @throws NullPointerException if given requirements is null.
* @throws NullPointerException if given requirements are null.
* @throws AssertionError if any element does not satisfy the requirements at the same index
* @throws AssertionError if there are not as many requirements as there are iterable elements.
* @since 3.19.0
Expand Down

0 comments on commit 52c6a28

Please sign in to comment.