Skip to content

Commit

Permalink
Add assertions for java.lang.reflect. Fix assertj#3130
Browse files Browse the repository at this point in the history
This changes adds assertions for classes:
* Field
* Method
* Constructor

Improve javadoc.
  • Loading branch information
William Bakker committed Jul 31, 2023
1 parent 82bddaf commit da690d4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void assertIsPackagePrivate() {
* Verifies that the actual {@code Field} is final (has {@code final} modifier).
* <p>
* Example:
* <pre><code field='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(Math.class.getDeclaredField("PI")).isFinal();
*
* // this assertion fails:
Expand All @@ -106,7 +106,7 @@ private void assertIsFinal() {
* Verifies that the actual {@code Field} is not final (does not have {@code final} modifier).
* <p>
* Example:
* <pre><code field='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(AtomicLong.class.getDeclaredField("value")).isNotFinal();
*
* // this assertion fails:
Expand All @@ -130,7 +130,7 @@ private void assertIsNotFinal() {
* Verifies that the actual {@code Field} is static (has {@code static} modifier).
* <p>
* Example:
* <pre><code field='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(Math.class.getDeclaredField("PI")).isStatic();
*
* // this assertion fails:
Expand All @@ -155,7 +155,7 @@ private void assertIsStatic() {
* Verifies that the actual {@code Field} is not static (does not have {@code static} modifier).
* <p>
* Example:
* <pre><code field='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(AtomicLong.class.getDeclaredField("value")).isNotStatic();
*
* // this assertion fails:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected AbstractMethodAssert(Method actual, Class<?> selfType) {
* Verifies that the actual {@code Method} is abstract (has {@code abstract} modifier).
* <p>
* Example:
* <pre><code method='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(Number.class.getDeclaredMethod("intValue")).isAbstract();
*
* // this assertion fails:
Expand All @@ -67,7 +67,7 @@ private void assertIsAbstract() {
* Verifies that the actual {@code Method} is final (has {@code final} modifier).
* <p>
* Example:
* <pre><code method='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(AtomicLong.class.getDeclaredMethod("get")).isFinal();
*
* // this assertion fails:
Expand All @@ -91,7 +91,7 @@ private void assertIsFinal() {
* Verifies that the actual {@code Method} is not final (does not have {@code final} modifier).
* <p>
* Example:
* <pre><code method='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(Math.class.getDeclaredMethod("abs", long.class)).isNotFinal();
*
* // this assertion fails:
Expand All @@ -115,7 +115,7 @@ private void assertIsNotFinal() {
* Verifies that the actual {@code Method} is static (has {@code static} modifier).
* <p>
* Example:
* <pre><code method='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(Math.class.getDeclaredMethod("abs", long.class)).isStatic();
*
* // this assertion fails:
Expand All @@ -140,7 +140,7 @@ private void assertIsStatic() {
* Verifies that the actual {@code Method} is not static (does not have {@code static} modifier).
* <p>
* Example:
* <pre><code method='java'> // this assertion succeeds:
* <pre><code class='java'> // this assertion succeeds:
* assertThat(AtomicLong.class.getDeclaredMethod("get")).isNotStatic();
*
* // this assertion fails:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public static MatcherAssert assertThat(Matcher actual) {
* Creates a new instance of <code>{@link ConstructorAssert}</code> from the given {@link java.lang.reflect.Constructor}.
*
* Example:
* <pre><code class='java'> Constructor<?> constructor = Object.class.getDeclaredConstructor();
* <pre><code class='java'> Constructor constructor = Object.class.getDeclaredConstructor();
* assertThat(constructor).isPublic(); </code></pre>
*
* @param actual the constructor to test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3823,7 +3823,7 @@ public static AbstractFieldAssert<?> then(Field actual) {
* Creates a new instance of <code>{@link ConstructorAssert}</code> from the given {@link java.lang.reflect.Constructor}.
*
* Example:
* <pre><code class='java'> Constructor<?> constructor = Object.class.getDeclaredConstructor();
* <pre><code class='java'> Constructor constructor = Object.class.getDeclaredConstructor();
* then(constructor).isPublic(); </code></pre>
*
* @param actual the constructor to test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface MemberAssert<SELF extends MemberAssert<SELF, ACTUAL>, ACTUAL ex
* Verifies that the actual {@code Member} is public (has {@code public} modifier).
* <p>
* Example:
* <pre><code field='java'> class Container {
* <pre><code class='java'> class Container {
* public void publicMethod() {};
* protected void protectedMethod() {};
* void packagePrivateMethod() {};
Expand All @@ -49,7 +49,7 @@ public interface MemberAssert<SELF extends MemberAssert<SELF, ACTUAL>, ACTUAL ex
* Verifies that the actual {@code Method} is protected (has {@code protected} modifier).
* <p>
* Example:
* <pre><code field='java'> class Container {
* <pre><code class='java'> class Container {
* public void publicMethod() {};
* protected void protectedMethod() {};
* void packagePrivateMethod() {};
Expand All @@ -74,7 +74,7 @@ public interface MemberAssert<SELF extends MemberAssert<SELF, ACTUAL>, ACTUAL ex
* Verifies that the actual {@code Method} is package-private (has no modifier).
* <p>
* Example:
* <pre><code field='java'> class Container {
* <pre><code class='java'> class Container {
* public void publicMethod() {};
* protected void protectedMethod() {};
* void packagePrivateMethod() {};
Expand Down

0 comments on commit da690d4

Please sign in to comment.