forked from assertj/assertj
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add as(InstanceOfAssertFactory) to Assertions and WithAssertions (ass…
…ertj#1609) This improves assertion readability with methods having an InstanceOfAssertFactory parameter.
- Loading branch information
1 parent
7431b8d
commit 3cf8cf3
Showing
8 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/test/java/org/assertj/core/api/Assertions_as_with_InstanceOfAssertFactory_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.assertj.core.api; | ||
|
||
import static org.assertj.core.api.BDDAssertions.then; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Tests for <code>{@link Assertions#as(InstanceOfAssertFactory)}</code>. | ||
* | ||
* @author Stefano Cordio | ||
*/ | ||
class Assertions_as_with_InstanceOfAssertFactory_Test { | ||
|
||
@Test | ||
@SuppressWarnings("unchecked") | ||
void should_return_the_given_assert_factory() { | ||
// GIVEN | ||
InstanceOfAssertFactory<?, AbstractAssert<?, ?>> assertFactory = mock(InstanceOfAssertFactory.class); | ||
// WHEN | ||
InstanceOfAssertFactory<?, AbstractAssert<?, ?>> result = Assertions.as(assertFactory); | ||
// THEN | ||
then(result).isSameAs(assertFactory); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/org/assertj/core/api/Assertions_from_with_Function_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.assertj.core.api; | ||
|
||
import static org.assertj.core.api.BDDAssertions.then; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import java.util.function.Function; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Tests for <code>{@link Assertions#from(Function)}</code>. | ||
* | ||
* @author Stefano Cordio | ||
*/ | ||
class Assertions_from_with_Function_Test { | ||
|
||
@Test | ||
void should_return_the_given_extractor() { | ||
// GIVEN | ||
Function<?, ?> extractor = mock(Function.class); | ||
// WHEN | ||
Function<?, ?> result = Assertions.from(extractor); | ||
// THEN | ||
then(result).isSameAs(extractor); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters