rweisleder / archunit-spring

Library providing predefined ArchUnit rules for Spring applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArchUnit Spring Integration

The ArchUnit Spring Integration provides predefined ArchUnit rules for Spring applications.

badge javadoc archunit spring

Usage

<dependency>
    <groupId>de.rweisleder</groupId>
    <artifactId>archunit-spring</artifactId>
    <version>1.0.0</version>
    <scope>test</scope>
</dependency>

The library expects that the required dependencies for Spring and ArchUnit are already declared.

Examples

Given the following class:

@RestController
class DemoRestController {

    @GetMapping("/hello")
    String hello() {
        return "Hello World";
    }
}

You can write architecture rules like this:

import static de.rweisleder.archunit.spring.SpringAnnotationPredicates.springAnnotatedWith;

methods()
    // "that are annotated with @RequestMapping" (or @GetMapping, @PostMapping etc.)
    .that(are(springAnnotatedWith(RequestMapping.class)))
    // "should be declared in classes that are annotated with @Controller" (or @RestController etc.)
    .should().beDeclaredInClassesThat(are(springAnnotatedWith(Controller.class)));

User Guide

Please refer to the complete documentation here for detailed information.

About

Library providing predefined ArchUnit rules for Spring applications

License:Apache License 2.0


Languages

Language:Java 100.0%