Skip to content

michaelcowan/blt-assertj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A selection of AssertJ utilities that pull in minimal dependencies

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages