A selection of AssertJ utilities that pull in minimal dependencies
The library is available via Maven Central
e.g., to add the AssertJ library to your dependencies:
<dependency>
<groupId>io.blt</groupId>
<artifactId>blt-assertj</artifactId>
<version>1.0.2</version>
</dependency>
implementation 'io.blt:blt-assertj:1.0.2'
API docs are available for the latest release of the library.
Assertion factory methods that allow testing the annotations of various types.
Allow asserting that an annotation is present and also to perform assertions on the annotation itself:
@Test
void isAnnotatedAsTransactionalWithNoRollbackForException() {
assertHasAnnotation(NotificationPublisher.class, Transactional.class)
.extracting(Transactional::noRollbackFor)
.isEqualTo(Exception.class);
}
Similarly, for Method
:
@ParameterizedTest
@MethodSource
void isAnnotatedAsTransactionalWithNoRollbackForException(Method method) throws Exception {
assertHasAnnotation(method, Transactional.class)
.extracting(Transactional::noRollbackFor)
.isEqualTo(Exception.class);
}
Similarly, for Field
:
@ParameterizedTest
@MethodSource
void isAnnotatedAsDigitsWithTwoFractionalDigits(Field field) {
assertHasAnnotation(field, Digits.class)
.extracting(Digits::fraction)
.isEqualTo(2);
}