Skip to content

Commit a44ff4e

Browse files
Javadoc improvements
1 parent 92024e4 commit a44ff4e

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

src/main/java/org/assertj/core/api/AbstractInputStreamAssert.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public SELF hasSameContentAs(InputStream expected) {
8282
/**
8383
* Verifies that the content of the actual {@code InputStream} is empty.
8484
* <p>
85+
* <b>Warning: this will consume the first byte of the {@code InputStream}.</b>
86+
* <p>
8587
* Example:
8688
* <pre><code class='java'> // assertion will pass
8789
* assertThat(new ByteArrayInputStream(new byte[] {})).isEmpty());
@@ -103,6 +105,8 @@ public SELF isEmpty() {
103105
/**
104106
* Verifies that the content of the actual {@code InputStream} is not empty.
105107
* <p>
108+
* <b>Warning: this will consume the first byte of the {@code InputStream}.</b>
109+
* <p>
106110
* Example:
107111
* <pre><code class='java'> // assertion will pass
108112
* assertThat(new ByteArrayInputStream(new byte[] {0xa})).isNotEmpty());

src/main/java/org/assertj/core/api/AbstractIterableAssert.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ private ELEMENT_ASSERT internalElement(int index) {
28882888
* // InstanceOfAssertFactories.STRING is an AssertFactory for String assertions
28892889
* assertThat(babySimpsons, InstanceOfAssertFactories.STRING).singleElement()
28902890
* .startsWith("Mag");
2891-
* // better readability with static import InstanceOfAssertFactories.STRING and Assertions.as
2891+
* // better readability with import static InstanceOfAssertFactories.STRING and Assertions.as
28922892
* assertThat(babySimpsons, as(STRING)).singleElement()
28932893
* .startsWith("Mag");
28942894
*
@@ -2916,9 +2916,9 @@ public ELEMENT_ASSERT singleElement() {
29162916
* This is a shorthand for <code>hasSize(1).first(assertFactory)</code>.
29172917
* <p>
29182918
* Example: use of {@code String} assertions after {@code singleElement(as(STRING)}
2919-
* <pre><code class='java'> static import org.assertj.core.api.InstanceOfAssertFactories.STRING;
2920-
* static import org.assertj.core.api.InstanceOfAssertFactories.INTEGER;
2921-
* static import org.assertj.core.api.Assertions.as; // syntactic sugar
2919+
* <pre><code class='java'> import static org.assertj.core.api.InstanceOfAssertFactories.STRING;
2920+
* import static org.assertj.core.api.InstanceOfAssertFactories.INTEGER;
2921+
* import static org.assertj.core.api.Assertions.as; // syntactic sugar
29222922
*
29232923
* List&lt;String&gt; babySimpsons = list("Maggie");
29242924
*

src/main/java/org/assertj/core/api/AbstractSoftAssertions.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,30 @@ public AbstractSoftAssertions() {
3737
* <p>
3838
* Example:
3939
* <pre><code class='java'> SoftAssertions softly = new SoftAssertions();
40-
*
40+
* StringBuilder reportBuilder = new StringBuilder(format("Assertions report:%n"));
41+
4142
* // register our callback
42-
* softly.setAfterAssertionErrorCollected(error -&gt; System.out.println(error));
43+
* softly.setAfterAssertionErrorCollected(error -&gt; reportBuilder.append(String.format("------------------%n%s%n", error.getMessage())));
4344
*
44-
* // the AssertionError corresponding to this failing assertion is printed to the console.
45-
* softly.assertThat("The Beatles").isEqualTo("The Rolling Stones");</code></pre>
45+
* // the AssertionError corresponding to the failing assertions are registered in the report
46+
* softly.assertThat("The Beatles").isEqualTo("The Rolling Stones");
47+
* softly.assertThat(123).isEqualTo(123)
48+
* .isEqualTo(456);</code></pre>
49+
* <p>
50+
* resulting {@code reportBuilder}:
51+
* <pre><code class='java'> Assertions report:
52+
* ------------------
53+
* Expecting:
54+
* &lt;"The Beatles"&gt;
55+
* to be equal to:
56+
* &lt;"The Rolling Stones"&gt;
57+
* but was not.
58+
* ------------------
59+
* Expecting:
60+
* &lt;123&gt;
61+
* to be equal to:
62+
* &lt;456&gt;
63+
* but was not.</code></pre>
4664
* <p>
4765
* Alternatively, if you have defined your own SoftAssertions subclass and inherited from {@link AbstractSoftAssertions},
4866
* the only thing you have to do is to override {@link AfterAssertionErrorCollected#onAssertionErrorCollected(AssertionError)}.

src/main/java/org/assertj/core/api/Assertions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ public static <T extends Throwable> ThrowableTypeAssert<T> assertThatExceptionOf
13721372
* Entry point to check that no exception of any type is thrown by a given {@code throwingCallable}.
13731373
* <p>
13741374
* Example:
1375-
* <pre><code class='java'>assertThatNoException().isThrownBy(() -&gt; { System.out.println("OK"); });</code></pre>
1375+
* <pre><code class='java'>assertThatNoException().isThrownBy(() -&gt; System.out.println("OK"));</code></pre>
13761376
*
13771377
* This method is more or less the same of {@code assertThatCode(...).doesNotThrowAnyException();} but in a more natural way.
13781378
*

0 commit comments

Comments
 (0)