Class PlantUmlArchCondition
java.lang.Object
com.tngtech.archunit.lang.ArchCondition<JavaClass>
com.tngtech.archunit.library.plantuml.rules.PlantUmlArchCondition
Allows to evaluate PlantUML Component Diagrams
as ArchUnit rules.
The general syntax to use is
There are various factory method for different input formats (file, url, ...), compare
A PlantUML diagram used with ArchUnit must abide by a certain set of rules:
The general syntax to use is
classes().should(adhereToPlantUmlDiagram(someDiagramUrl, consideringAllDependencies()));
The supported diagram syntax uses component diagram stereotypes to associate package patterns
(compare PackageMatcher) with components. An example could look like
[Some Source] <<..some.source..>>
[Some Target] <<..some.target..>>
[Some Source] --> [Some Target]
Applying such a diagram as an ArchUnit rule would demand dependencies only from ..some.source..
to ..some.target.., but forbid them vice versa.There are various factory method for different input formats (file, url, ...), compare
adhereToPlantUmlDiagram(URL, Configuration)adhereToPlantUmlDiagram(File, Configuration)adhereToPlantUmlDiagram(Path, Configuration)adhereToPlantUmlDiagram(String, Configuration)
PlantUmlArchCondition.Configuration.
Candidates are
PlantUmlArchCondition.Configuration.consideringAllDependencies()PlantUmlArchCondition.Configuration.consideringOnlyDependenciesInDiagram()PlantUmlArchCondition.Configuration.consideringOnlyDependenciesInAnyPackage(String, String...)
A PlantUML diagram used with ArchUnit must abide by a certain set of rules:
- Components must have a name
- Components must have at least one stereotype. Each stereotype in the diagram must be unique
- Components may have an optional alias
- Components may have an optional color
- Components must be defined before declaring dependencies
- Dependencies must use arrows only consisting of dashes, pointing right, e.g.
-->
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classUsed to specify which dependencies should be checked by the condition.Nested classes/interfaces inherited from class com.tngtech.archunit.lang.ArchCondition
ArchCondition.ConditionByPredicate<T extends HasDescription & HasSourceCodeLocation> -
Method Summary
Modifier and TypeMethodDescriptionstatic PlantUmlArchConditionadhereToPlantUmlDiagram(File file, PlantUmlArchCondition.Configuration configuration) static PlantUmlArchConditionadhereToPlantUmlDiagram(String fileName, PlantUmlArchCondition.Configuration configuration) static PlantUmlArchConditionadhereToPlantUmlDiagram(URL url, PlantUmlArchCondition.Configuration configuration) static PlantUmlArchConditionadhereToPlantUmlDiagram(Path path, PlantUmlArchCondition.Configuration configuration) voidcheck(JavaClass javaClass, ConditionEvents events) ignoreDependencies(DescribedPredicate<? super Dependency> ignorePredicate) Ignores alldependenciesmatching the suppliedignorePredicate.ignoreDependencies(Class<?> origin, Class<?> target) ignoreDependencies(String origin, String target) ignoreDependenciesWithOrigin(DescribedPredicate<? super JavaClass> ignorePredicate) ignoreDependenciesWithTarget(DescribedPredicate<? super JavaClass> ignorePredicate) Methods inherited from class com.tngtech.archunit.lang.ArchCondition
and, as, finish, forSubtype, from, getDescription, init, or, toString
-
Method Details
-
ignoreDependenciesWithOrigin
@PublicAPI(usage=ACCESS) public PlantUmlArchCondition ignoreDependenciesWithOrigin(DescribedPredicate<? super JavaClass> ignorePredicate) Ignores alldependenciesthat have anorigin classmatching the suppliedignorePredicate.
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates. -
ignoreDependenciesWithTarget
@PublicAPI(usage=ACCESS) public PlantUmlArchCondition ignoreDependenciesWithTarget(DescribedPredicate<? super JavaClass> ignorePredicate) Ignores alldependenciesthat have antarget classmatching the suppliedignorePredicate.
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates. -
ignoreDependencies
@PublicAPI(usage=ACCESS) public PlantUmlArchCondition ignoreDependencies(Class<?> origin, Class<?> target) -
ignoreDependencies
@PublicAPI(usage=ACCESS) public PlantUmlArchCondition ignoreDependencies(String origin, String target) -
ignoreDependencies
@PublicAPI(usage=ACCESS) public PlantUmlArchCondition ignoreDependencies(DescribedPredicate<? super Dependency> ignorePredicate) Ignores alldependenciesmatching the suppliedignorePredicate.
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingDependencycan be found withinDependency.Predicates. -
check
- Specified by:
checkin classArchCondition<JavaClass>
-
adhereToPlantUmlDiagram
@PublicAPI(usage=ACCESS) public static PlantUmlArchCondition adhereToPlantUmlDiagram(URL url, PlantUmlArchCondition.Configuration configuration) - See Also:
-
adhereToPlantUmlDiagram
@PublicAPI(usage=ACCESS) public static PlantUmlArchCondition adhereToPlantUmlDiagram(String fileName, PlantUmlArchCondition.Configuration configuration) - See Also:
-
adhereToPlantUmlDiagram
@PublicAPI(usage=ACCESS) public static PlantUmlArchCondition adhereToPlantUmlDiagram(Path path, PlantUmlArchCondition.Configuration configuration) - See Also:
-
adhereToPlantUmlDiagram
@PublicAPI(usage=ACCESS) public static PlantUmlArchCondition adhereToPlantUmlDiagram(File file, PlantUmlArchCondition.Configuration configuration) - See Also:
-