Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 2.26 KB

README.md

File metadata and controls

76 lines (57 loc) · 2.26 KB

blt-assertj

A selection of AssertJ utilities that pull in minimal dependencies

Maven Central CircleCI Codecov CodeFactor Grade

Installation

Maven

The library is available via Maven Central

e.g., to add the AssertJ library to your dependencies:

Maven

<dependency>
    <groupId>io.blt</groupId>
    <artifactId>blt-assertj</artifactId>
    <version>1.0.2</version>
</dependency>

Gradle

implementation 'io.blt:blt-assertj:1.0.2'

Documentation

API Docs

API docs are available for the latest release of the library.

Examples

AnnotationAssertions

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);
}