Skip to content

Instantly share code, notes, and snippets.

@BenjaminKlatt
Created October 12, 2020 20:59
Show Gist options
  • Save BenjaminKlatt/2deb2c08e2efa716ed194e2cc00c403e to your computer and use it in GitHub Desktop.
Save BenjaminKlatt/2deb2c08e2efa716ed194e2cc00c403e to your computer and use it in GitHub Desktop.
ArchUnit Vorgefertigte Team Regeln
package de.viadee.architecture.archunit.rules;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import org.springframework.web.bind.annotation.RestController;
import com.tngtech.archunit.lang.ArchRule;
public class TeamArchRules {
/** Architecture Rule for REST controller conventions */
public static ArchRule CONTROLLERS_SHOULD_BE_SUFFIXED_AND_LOCATED =
classes()
.that().areAnnotatedWith(RestController.class)
.should().haveSimpleNameEndingWith("Controller")
.andShould().resideInAPackage("..controller..")
.because("controllers must be easy to find and identify");
}
package de.viadee.architecture.archunit.architecture;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchRule;
import de.viadee.architecture.archunit.rules.TeamArchRules;
@AnalyzeClasses(packages = "de.viadee.architecture.archunit")
public class TeamRulesTest {
@ArchTest
private static ArchRule controllers_should_be_suffixed = TeamArchRules.CONTROLLERS_SHOULD_BE_SUFFIXED_AND_LOCATED;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment