diff --git a/archunit-example/archunit-example/example-plain/src/test/resources/frozen/6f3a1e55-3673-4950-a3be-857751b3d515 b/archunit-example/archunit-example/example-plain/src/test/resources/frozen/6f3a1e55-3673-4950-a3be-857751b3d515 deleted file mode 100644 index 63cbcd27e9..0000000000 --- a/archunit-example/archunit-example/example-plain/src/test/resources/frozen/6f3a1e55-3673-4950-a3be-857751b3d515 +++ /dev/null @@ -1,11 +0,0 @@ -Class implements interface in (ServiceViolatingDaoRules.java:0) -Field has type in (SomeJpa.java:0) -Field has type in (OtherJpa.java:0) -Field has type in (ServiceViolatingDaoRules.java:0) -Method calls method in (SomeJpa.java:20) -Method has return type in (OtherDao.java:0) -Method calls method in (OtherJpa.java:19) -Method has return type in (OtherJpa.java:0) -Method calls method in (OtherJpa.java:24) -Method calls method in (ServiceViolatingDaoRules.java:27) -Method calls method in (ServiceViolatingDaoRules.java:26) \ No newline at end of file diff --git a/archunit-example/archunit-example/example-plain/src/test/resources/frozen/d8e3c650-e214-402f-8cfa-33a8607785d3 b/archunit-example/archunit-example/example-plain/src/test/resources/frozen/d8e3c650-e214-402f-8cfa-33a8607785d3 deleted file mode 100644 index c83d262226..0000000000 --- a/archunit-example/archunit-example/example-plain/src/test/resources/frozen/d8e3c650-e214-402f-8cfa-33a8607785d3 +++ /dev/null @@ -1,17 +0,0 @@ -Class implements interface in (DaoCallingService.java:0) -Class implements interface in (ServiceImplementation.java:0) -Constructor (com.tngtech.archunit.example.service.ServiceViolatingLayerRules)> has parameter of type in (SomeMediator.java:0) -Field has type in (SomeMediator.java:0) -Field has type in (SomeController.java:0) -Field has type in (SomeController.java:0) -Field has type in (DaoCallingService.java:0) -Field has type in (ServiceViolatingDaoRules.java:0) -Method calls method in (SomeMediator.java:15) -Method calls method in (SomeController.java:11) -Method calls method in (SomeController.java:15) -Method calls constructor ()> in (SomeGuiController.java:7) -Method calls constructor (java.lang.String)> in (SomeGuiController.java:8) -Method gets field in (SomeGuiController.java:10) -Method gets field in (SomeGuiController.java:11) -Method calls method in (DaoCallingService.java:14) -Method calls method in (ServiceViolatingDaoRules.java:27) \ No newline at end of file diff --git a/archunit-example/archunit-example/example-plain/src/test/resources/frozen/stored.rules b/archunit-example/archunit-example/example-plain/src/test/resources/frozen/stored.rules deleted file mode 100644 index 8d664a0f69..0000000000 --- a/archunit-example/archunit-example/example-plain/src/test/resources/frozen/stored.rules +++ /dev/null @@ -1,4 +0,0 @@ -# -#Sun Jun 09 01:50:44 ICT 2019 -no\ classes\ should\ depend\ on\ classes\ that\ reside\ in\ a\ package\ '..service..'=d8e3c650-e214-402f-8cfa-33a8607785d3 -no\ classes\ should\ depend\ on\ classes\ that\ are\ assignable\ to\ javax.persistence.EntityManager=6f3a1e55-3673-4950-a3be-857751b3d515 diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/CodingRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/CodingRulesTest.java index 298ccdf1d1..985bff2f3f 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/CodingRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/CodingRulesTest.java @@ -1,7 +1,8 @@ package com.tngtech.archunit.exampletest.junit4; +import java.util.logging.Logger; + import com.tngtech.archunit.core.domain.JavaClasses; -import com.tngtech.archunit.core.domain.JavaModifier; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -10,8 +11,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; -import java.util.logging.Logger; - import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; import static com.tngtech.archunit.library.GeneralCodingRules.ACCESS_STANDARD_STREAMS; @@ -22,7 +21,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class CodingRulesTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ControllerRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ControllerRulesTest.java index ae082d1691..e9b9e6f9a8 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ControllerRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ControllerRulesTest.java @@ -4,7 +4,7 @@ import com.tngtech.archunit.base.PackageMatchers; import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaMember; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.security.Secured; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -20,7 +20,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class ControllerRulesTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/CyclicDependencyRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/CyclicDependencyRulesTest.java index 341d25af4c..f8bc7ebba6 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/CyclicDependencyRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/CyclicDependencyRulesTest.java @@ -2,8 +2,8 @@ import com.tngtech.archunit.base.DescribedPredicate; import com.tngtech.archunit.core.domain.JavaClass; -import com.tngtech.archunit.example.cycle.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; -import com.tngtech.archunit.example.cycle.complexcycles.slice3.ClassCallingConstructorInSliceFive; +import com.tngtech.archunit.example.cycles.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; +import com.tngtech.archunit.example.cycles.complexcycles.slice3.ClassCallingConstructorInSliceFive; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -18,7 +18,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example.cycle") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.cycles") public class CyclicDependencyRulesTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/DaoRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/DaoRulesTest.java index 0e0171df38..e271ad2b96 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/DaoRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/DaoRulesTest.java @@ -18,7 +18,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class DaoRulesTest { @ArchTest public static final ArchRule DAOs_must_reside_in_a_dao_package = diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/FrozenRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/FrozenRulesTest.java index 20babb490d..7cb252b0d6 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/FrozenRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/FrozenRulesTest.java @@ -28,7 +28,7 @@ */ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class FrozenRulesTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/InterfaceRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/InterfaceRulesTest.java index 723394bf2c..aefcf281b7 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/InterfaceRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/InterfaceRulesTest.java @@ -5,9 +5,9 @@ import com.tngtech.archunit.core.importer.Location; import com.tngtech.archunit.core.importer.Locations; -import com.tngtech.archunit.example.SomeBusinessInterface; -import com.tngtech.archunit.example.persistence.first.dao.SomeDao; -import com.tngtech.archunit.example.service.impl.SomeInterfacePlacedInTheWrongPackage; +import com.tngtech.archunit.example.layers.SomeBusinessInterface; +import com.tngtech.archunit.example.layers.persistence.first.dao.SomeDao; +import com.tngtech.archunit.example.layers.service.impl.SomeInterfacePlacedInTheWrongPackage; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/LayerDependencyRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/LayerDependencyRulesTest.java index 5191ae2c21..2056c6fa51 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/LayerDependencyRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/LayerDependencyRulesTest.java @@ -12,7 +12,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class LayerDependencyRulesTest { // 'access' catches only violations by real accesses, i.e. accessing a field, calling a method; compare 'dependOn' further down diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/LayeredArchitectureTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/LayeredArchitectureTest.java index ad24d1dc96..2ad94527e3 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/LayeredArchitectureTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/LayeredArchitectureTest.java @@ -1,7 +1,7 @@ package com.tngtech.archunit.exampletest.junit4; -import com.tngtech.archunit.example.SomeMediator; -import com.tngtech.archunit.example.service.ServiceViolatingLayerRules; +import com.tngtech.archunit.example.layers.SomeMediator; +import com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -13,14 +13,14 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class LayeredArchitectureTest { @ArchTest public static final ArchRule layer_dependencies_are_respected = layeredArchitecture() - .layer("Controllers").definedBy("com.tngtech.archunit.example.controller..") - .layer("Services").definedBy("com.tngtech.archunit.example.service..") - .layer("Persistence").definedBy("com.tngtech.archunit.example.persistence..") + .layer("Controllers").definedBy("com.tngtech.archunit.example.layers.controller..") + .layer("Services").definedBy("com.tngtech.archunit.example.layers.service..") + .layer("Persistence").definedBy("com.tngtech.archunit.example.layers.persistence..") .whereLayer("Controllers").mayNotBeAccessedByAnyLayer() .whereLayer("Services").mayOnlyBeAccessedByLayers("Controllers") @@ -29,9 +29,9 @@ public class LayeredArchitectureTest { @ArchTest public static final ArchRule layer_dependencies_are_respected_with_exception = layeredArchitecture() - .layer("Controllers").definedBy("com.tngtech.archunit.example.controller..") - .layer("Services").definedBy("com.tngtech.archunit.example.service..") - .layer("Persistence").definedBy("com.tngtech.archunit.example.persistence..") + .layer("Controllers").definedBy("com.tngtech.archunit.example.layers.controller..") + .layer("Services").definedBy("com.tngtech.archunit.example.layers.service..") + .layer("Persistence").definedBy("com.tngtech.archunit.example.layers.persistence..") .whereLayer("Controllers").mayNotBeAccessedByAnyLayer() .whereLayer("Services").mayOnlyBeAccessedByLayers("Controllers") diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/MethodsTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/MethodsTest.java index 912627fd9b..7d0d402dab 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/MethodsTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/MethodsTest.java @@ -1,7 +1,7 @@ package com.tngtech.archunit.exampletest.junit4; -import com.tngtech.archunit.example.anticorruption.WrappedResult; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.anticorruption.WrappedResult; +import com.tngtech.archunit.example.layers.security.Secured; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -14,7 +14,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class MethodsTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/NamingConventionTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/NamingConventionTest.java index eb2fb339c2..6f7b31ae8a 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/NamingConventionTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/NamingConventionTest.java @@ -1,8 +1,8 @@ package com.tngtech.archunit.exampletest.junit4; -import com.tngtech.archunit.example.AbstractController; -import com.tngtech.archunit.example.MyController; -import com.tngtech.archunit.example.MyService; +import com.tngtech.archunit.example.layers.AbstractController; +import com.tngtech.archunit.example.layers.MyController; +import com.tngtech.archunit.example.layers.MyService; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -14,7 +14,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class NamingConventionTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/OnionArchitectureTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/OnionArchitectureTest.java new file mode 100644 index 0000000000..51b898da32 --- /dev/null +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/OnionArchitectureTest.java @@ -0,0 +1,25 @@ +package com.tngtech.archunit.exampletest.junit4; + +import com.tngtech.archunit.junit.AnalyzeClasses; +import com.tngtech.archunit.junit.ArchTest; +import com.tngtech.archunit.junit.ArchUnitRunner; +import com.tngtech.archunit.lang.ArchRule; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import static com.tngtech.archunit.library.Architectures.onionArchitecture; + +@Category(Example.class) +@RunWith(ArchUnitRunner.class) +@AnalyzeClasses(packages = "com.tngtech.archunit.example.onionarchitecture") +public class OnionArchitectureTest { + + @ArchTest + static final ArchRule onion_architecture_is_respected = onionArchitecture() + .domainModels("..domain.model..") + .domainServices("..domain.service..") + .applicationServices("..application..") + .adapter("cli", "..adapter.cli..") + .adapter("persistence", "..adapter.persistence..") + .adapter("rest", "..adapter.rest.."); +} diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/PlantUmlArchitectureTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/PlantUmlArchitectureTest.java index e81b3cbc37..24f9916e1a 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/PlantUmlArchitectureTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/PlantUmlArchitectureTest.java @@ -3,9 +3,9 @@ import java.net.URL; import com.tngtech.archunit.base.PackageMatchers; -import com.tngtech.archunit.example.shopping.catalog.ProductCatalog; -import com.tngtech.archunit.example.shopping.order.Order; -import com.tngtech.archunit.example.shopping.product.Product; +import com.tngtech.archunit.example.plantuml.catalog.ProductCatalog; +import com.tngtech.archunit.example.plantuml.order.Order; +import com.tngtech.archunit.example.plantuml.product.Product; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -24,7 +24,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example.shopping") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.plantuml") public class PlantUmlArchitectureTest { private static final URL plantUmlDiagram = PlantUmlArchitectureTest.class.getResource("shopping_example.puml"); diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RestrictNumberOfClassesWithACertainPropertyTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RestrictNumberOfClassesWithACertainPropertyTest.java index 0fb4bb47f7..9b0aa1ff2f 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RestrictNumberOfClassesWithACertainPropertyTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RestrictNumberOfClassesWithACertainPropertyTest.java @@ -1,7 +1,7 @@ package com.tngtech.archunit.exampletest.junit4; -import com.tngtech.archunit.example.SomeBusinessInterface; -import com.tngtech.archunit.example.SomeOtherBusinessInterface; +import com.tngtech.archunit.example.layers.SomeBusinessInterface; +import com.tngtech.archunit.example.layers.SomeOtherBusinessInterface; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -14,7 +14,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class RestrictNumberOfClassesWithACertainPropertyTest { @ArchTest public static final ArchRule no_new_classes_should_implement_SomeBusinessInterface = diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RuleLibraryTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RuleLibraryTest.java index 5aadd22a85..de1f973247 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RuleLibraryTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RuleLibraryTest.java @@ -9,7 +9,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class RuleLibraryTest { @ArchTest public static final ArchRules LIBRARY = ArchRules.in(RuleSetsTest.class); diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RuleSetsTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RuleSetsTest.java index 2a8afb0485..78c4bb8065 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RuleSetsTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/RuleSetsTest.java @@ -9,11 +9,11 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class RuleSetsTest { @ArchTest private final ArchRules CODING_RULES = ArchRules.in(CodingRulesTest.class); @ArchTest - private final ArchRules CYCLIC_DEPENDENCY_RULES = ArchRules.in(CyclicDependencyRulesTest.class); + private final ArchRules NAMING_CONVENTION_RULES = ArchRules.in(NamingConventionTest.class); } diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SessionBeanRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SessionBeanRulesTest.java index ad13fd7911..bf95c83497 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SessionBeanRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SessionBeanRulesTest.java @@ -35,7 +35,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class SessionBeanRulesTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SingleClassTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SingleClassTest.java index 4cc782ae6b..5c8551477d 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SingleClassTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SingleClassTest.java @@ -1,9 +1,9 @@ package com.tngtech.archunit.exampletest.junit4; -import com.tngtech.archunit.example.SomeOtherBusinessInterface; -import com.tngtech.archunit.example.core.CoreSatellite; -import com.tngtech.archunit.example.core.HighSecurity; -import com.tngtech.archunit.example.core.VeryCentralCore; +import com.tngtech.archunit.example.layers.SomeOtherBusinessInterface; +import com.tngtech.archunit.example.layers.core.CoreSatellite; +import com.tngtech.archunit.example.layers.core.HighSecurity; +import com.tngtech.archunit.example.layers.core.VeryCentralCore; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -17,7 +17,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class SingleClassTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SlicesIsolationTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SlicesIsolationTest.java index 3f4c3f9957..cc919bf021 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SlicesIsolationTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SlicesIsolationTest.java @@ -2,8 +2,8 @@ import com.tngtech.archunit.base.DescribedPredicate; import com.tngtech.archunit.core.domain.JavaClass; -import com.tngtech.archunit.example.controller.one.UseCaseOneTwoController; -import com.tngtech.archunit.example.controller.two.UseCaseTwoController; +import com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController; +import com.tngtech.archunit.example.layers.controller.two.UseCaseTwoController; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -17,7 +17,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class SlicesIsolationTest { @ArchTest public static final ArchRule controllers_should_only_use_their_own_slice = diff --git a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ThirdPartyRulesTest.java b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ThirdPartyRulesTest.java index 54707e455c..a1811b3b02 100644 --- a/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ThirdPartyRulesTest.java +++ b/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ThirdPartyRulesTest.java @@ -3,8 +3,8 @@ import com.tngtech.archunit.base.DescribedPredicate; import com.tngtech.archunit.core.domain.JavaCall; import com.tngtech.archunit.core.domain.JavaClass; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWithProblem; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWorkaroundFactory; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWithProblem; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWorkaroundFactory; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -27,7 +27,7 @@ @Category(Example.class) @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class ThirdPartyRulesTest { @ArchTest diff --git a/archunit-example/example-junit4/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 b/archunit-example/example-junit4/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 index 5da26125d6..0d923cc037 100644 --- a/archunit-example/example-junit4/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 +++ b/archunit-example/example-junit4/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 @@ -1,15 +1,15 @@ -Class implements interface in (DaoCallingService.java:0) -Class implements interface in (ServiceImplementation.java:0) -Constructor (com.tngtech.archunit.example.service.ServiceViolatingLayerRules)> has parameter of type in (SomeMediator.java:0) -Field has type in (SomeMediator.java:0) -Field has type in (SomeController.java:0) -Field has type in (SomeController.java:0) -Field has type in (DaoCallingService.java:0) -Field has type in (ServiceViolatingDaoRules.java:0) -Method calls method in (SomeMediator.java:15) -Method calls constructor ()> in (SomeGuiController.java:7) -Method calls constructor (java.lang.String)> in (SomeGuiController.java:8) -Method gets field in (SomeGuiController.java:10) -Method gets field in (SomeGuiController.java:11) -Method calls method in (DaoCallingService.java:14) -Method calls method in (ServiceViolatingDaoRules.java:27) \ No newline at end of file +Class implements interface in (DaoCallingService.java:0) +Class implements interface in (ServiceImplementation.java:0) +Constructor (com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules)> has parameter of type in (SomeMediator.java:0) +Field has type in (SomeMediator.java:0) +Field has type in (SomeController.java:0) +Field has type in (SomeController.java:0) +Field has type in (DaoCallingService.java:0) +Field has type in (ServiceViolatingDaoRules.java:0) +Method calls method in (SomeMediator.java:15) +Method calls constructor ()> in (SomeGuiController.java:7) +Method calls constructor (java.lang.String)> in (SomeGuiController.java:8) +Method gets field in (SomeGuiController.java:10) +Method gets field in (SomeGuiController.java:11) +Method calls method in (DaoCallingService.java:14) +Method calls method in (ServiceViolatingDaoRules.java:27) \ No newline at end of file diff --git a/archunit-example/example-junit4/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 b/archunit-example/example-junit4/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 index 6e464ed232..8b8178ae7f 100644 --- a/archunit-example/example-junit4/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 +++ b/archunit-example/example-junit4/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 @@ -1,9 +1,9 @@ -Class implements interface in (ServiceViolatingDaoRules.java:0) -Field has type in (SomeJpa.java:0) -Field has type in (OtherJpa.java:0) -Field has type in (ServiceViolatingDaoRules.java:0) -Method calls method in (SomeJpa.java:20) -Method has return type in (OtherDao.java:0) -Method calls method in (OtherJpa.java:19) -Method has return type in (OtherJpa.java:0) -Method calls method in (OtherJpa.java:24) \ No newline at end of file +Class implements interface in (ServiceViolatingDaoRules.java:0) +Field has type in (SomeJpa.java:0) +Field has type in (OtherJpa.java:0) +Field has type in (ServiceViolatingDaoRules.java:0) +Method calls method in (SomeJpa.java:20) +Method has return type in (OtherDao.java:0) +Method calls method in (OtherJpa.java:19) +Method has return type in (OtherJpa.java:0) +Method calls method in (OtherJpa.java:24) \ No newline at end of file diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/CodingRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/CodingRulesTest.java index 88e37d9d98..54e4560576 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/CodingRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/CodingRulesTest.java @@ -1,15 +1,14 @@ package com.tngtech.archunit.exampletest.junit5; +import java.util.logging.Logger; + import com.tngtech.archunit.core.domain.JavaClasses; -import com.tngtech.archunit.core.domain.JavaModifier; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import com.tngtech.archunit.lang.CompositeArchRule; -import java.util.logging.Logger; - import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; import static com.tngtech.archunit.library.GeneralCodingRules.ACCESS_STANDARD_STREAMS; @@ -19,7 +18,7 @@ import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_USE_JODATIME; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class CodingRulesTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ControllerRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ControllerRulesTest.java index 31d4835499..0164e9de67 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ControllerRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ControllerRulesTest.java @@ -4,7 +4,7 @@ import com.tngtech.archunit.base.PackageMatchers; import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaMember; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.security.Secured; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -17,7 +17,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class ControllerRulesTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/CyclicDependencyRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/CyclicDependencyRulesTest.java index fcfe312b27..07182d1629 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/CyclicDependencyRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/CyclicDependencyRulesTest.java @@ -1,8 +1,8 @@ package com.tngtech.archunit.exampletest.junit5; import com.tngtech.archunit.core.domain.JavaClass; -import com.tngtech.archunit.example.cycle.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; -import com.tngtech.archunit.example.cycle.complexcycles.slice3.ClassCallingConstructorInSliceFive; +import com.tngtech.archunit.example.cycles.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; +import com.tngtech.archunit.example.cycles.complexcycles.slice3.ClassCallingConstructorInSliceFive; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -15,7 +15,7 @@ import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example.cycle") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.cycles") public class CyclicDependencyRulesTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/DaoRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/DaoRulesTest.java index 649493d324..e4f73c7302 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/DaoRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/DaoRulesTest.java @@ -15,7 +15,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noMethods; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class DaoRulesTest { @ArchTest static final ArchRule DAOs_must_reside_in_a_dao_package = diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/FrozenRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/FrozenRulesTest.java index 8d5e9454f0..d666bf847b 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/FrozenRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/FrozenRulesTest.java @@ -25,7 +25,7 @@ * i.e. if you only change the line numbers of frozen violations, the test will still pass. */ @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class FrozenRulesTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/InterfaceRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/InterfaceRulesTest.java index a0dd9aba37..5b7dc871ce 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/InterfaceRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/InterfaceRulesTest.java @@ -5,9 +5,9 @@ import com.tngtech.archunit.core.importer.Location; import com.tngtech.archunit.core.importer.Locations; -import com.tngtech.archunit.example.SomeBusinessInterface; -import com.tngtech.archunit.example.persistence.first.dao.SomeDao; -import com.tngtech.archunit.example.service.impl.SomeInterfacePlacedInTheWrongPackage; +import com.tngtech.archunit.example.layers.SomeBusinessInterface; +import com.tngtech.archunit.example.layers.persistence.first.dao.SomeDao; +import com.tngtech.archunit.example.layers.service.impl.SomeInterfacePlacedInTheWrongPackage; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/LayerDependencyRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/LayerDependencyRulesTest.java index f65213e48d..645b6186d1 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/LayerDependencyRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/LayerDependencyRulesTest.java @@ -9,7 +9,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class LayerDependencyRulesTest { // 'access' catches only violations by real accesses, i.e. accessing a field, calling a method; compare 'dependOn' further down diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/LayeredArchitectureTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/LayeredArchitectureTest.java index 6a719d07eb..8d3d774b02 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/LayeredArchitectureTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/LayeredArchitectureTest.java @@ -1,7 +1,7 @@ package com.tngtech.archunit.exampletest.junit5; -import com.tngtech.archunit.example.SomeMediator; -import com.tngtech.archunit.example.service.ServiceViolatingLayerRules; +import com.tngtech.archunit.example.layers.SomeMediator; +import com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -10,14 +10,14 @@ import static com.tngtech.archunit.library.Architectures.layeredArchitecture; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class LayeredArchitectureTest { @ArchTest static final ArchRule layer_dependencies_are_respected = layeredArchitecture() - .layer("Controllers").definedBy("com.tngtech.archunit.example.controller..") - .layer("Services").definedBy("com.tngtech.archunit.example.service..") - .layer("Persistence").definedBy("com.tngtech.archunit.example.persistence..") + .layer("Controllers").definedBy("com.tngtech.archunit.example.layers.controller..") + .layer("Services").definedBy("com.tngtech.archunit.example.layers.service..") + .layer("Persistence").definedBy("com.tngtech.archunit.example.layers.persistence..") .whereLayer("Controllers").mayNotBeAccessedByAnyLayer() .whereLayer("Services").mayOnlyBeAccessedByLayers("Controllers") @@ -26,9 +26,9 @@ public class LayeredArchitectureTest { @ArchTest static final ArchRule layer_dependencies_are_respected_with_exception = layeredArchitecture() - .layer("Controllers").definedBy("com.tngtech.archunit.example.controller..") - .layer("Services").definedBy("com.tngtech.archunit.example.service..") - .layer("Persistence").definedBy("com.tngtech.archunit.example.persistence..") + .layer("Controllers").definedBy("com.tngtech.archunit.example.layers.controller..") + .layer("Services").definedBy("com.tngtech.archunit.example.layers.service..") + .layer("Persistence").definedBy("com.tngtech.archunit.example.layers.persistence..") .whereLayer("Controllers").mayNotBeAccessedByAnyLayer() .whereLayer("Services").mayOnlyBeAccessedByLayers("Controllers") diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/MethodsTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/MethodsTest.java index 72c37bd8b9..be270848bb 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/MethodsTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/MethodsTest.java @@ -1,7 +1,7 @@ package com.tngtech.archunit.exampletest.junit5; -import com.tngtech.archunit.example.anticorruption.WrappedResult; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.anticorruption.WrappedResult; +import com.tngtech.archunit.example.layers.security.Secured; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -11,7 +11,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noCodeUnits; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class MethodsTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/NamingConventionTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/NamingConventionTest.java index 5bef89eaeb..7db3457cb1 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/NamingConventionTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/NamingConventionTest.java @@ -1,8 +1,8 @@ package com.tngtech.archunit.exampletest.junit5; -import com.tngtech.archunit.example.AbstractController; -import com.tngtech.archunit.example.MyController; -import com.tngtech.archunit.example.MyService; +import com.tngtech.archunit.example.layers.AbstractController; +import com.tngtech.archunit.example.layers.MyController; +import com.tngtech.archunit.example.layers.MyService; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -11,7 +11,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class NamingConventionTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/OnionArchitectureTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/OnionArchitectureTest.java new file mode 100644 index 0000000000..a3fefd678c --- /dev/null +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/OnionArchitectureTest.java @@ -0,0 +1,22 @@ +package com.tngtech.archunit.exampletest.junit5; + +import com.tngtech.archunit.junit.AnalyzeClasses; +import com.tngtech.archunit.junit.ArchTag; +import com.tngtech.archunit.junit.ArchTest; +import com.tngtech.archunit.lang.ArchRule; + +import static com.tngtech.archunit.library.Architectures.onionArchitecture; + +@ArchTag("example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.onionarchitecture") +public class OnionArchitectureTest { + + @ArchTest + static final ArchRule onion_architecture_is_respected = onionArchitecture() + .domainModels("..domain.model..") + .domainServices("..domain.service..") + .applicationServices("..application..") + .adapter("cli", "..adapter.cli..") + .adapter("persistence", "..adapter.persistence..") + .adapter("rest", "..adapter.rest.."); +} diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/PlantUmlArchitectureTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/PlantUmlArchitectureTest.java index 82f043f09e..e53194fdf0 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/PlantUmlArchitectureTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/PlantUmlArchitectureTest.java @@ -3,9 +3,9 @@ import java.net.URL; import com.tngtech.archunit.base.PackageMatchers; -import com.tngtech.archunit.example.shopping.catalog.ProductCatalog; -import com.tngtech.archunit.example.shopping.order.Order; -import com.tngtech.archunit.example.shopping.product.Product; +import com.tngtech.archunit.example.plantuml.catalog.ProductCatalog; +import com.tngtech.archunit.example.plantuml.order.Order; +import com.tngtech.archunit.example.plantuml.product.Product; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -21,7 +21,7 @@ import static com.tngtech.archunit.library.plantuml.PlantUmlArchCondition.adhereToPlantUmlDiagram; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example.shopping") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.plantuml") public class PlantUmlArchitectureTest { private static final URL plantUmlDiagram = PlantUmlArchitectureTest.class.getResource("shopping_example.puml"); diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RestrictNumberOfClassesWithACertainPropertyTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RestrictNumberOfClassesWithACertainPropertyTest.java index c8fdbfc832..82bc82cfa5 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RestrictNumberOfClassesWithACertainPropertyTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RestrictNumberOfClassesWithACertainPropertyTest.java @@ -1,7 +1,7 @@ package com.tngtech.archunit.exampletest.junit5; -import com.tngtech.archunit.example.SomeBusinessInterface; -import com.tngtech.archunit.example.SomeOtherBusinessInterface; +import com.tngtech.archunit.example.layers.SomeBusinessInterface; +import com.tngtech.archunit.example.layers.SomeOtherBusinessInterface; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -11,7 +11,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class RestrictNumberOfClassesWithACertainPropertyTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RuleLibraryTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RuleLibraryTest.java index 555c1bdb0d..dd72686513 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RuleLibraryTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RuleLibraryTest.java @@ -6,7 +6,7 @@ import com.tngtech.archunit.junit.ArchTest; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") class RuleLibraryTest { @ArchTest static final ArchRules LIBRARY = ArchRules.in(RuleSetsTest.class); diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RuleSetsTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RuleSetsTest.java index 14e38b1b66..540660dcb7 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RuleSetsTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/RuleSetsTest.java @@ -6,11 +6,11 @@ import com.tngtech.archunit.junit.ArchTest; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") class RuleSetsTest { @ArchTest private final ArchRules CODING_RULES = ArchRules.in(CodingRulesTest.class); @ArchTest - private final ArchRules CYCLIC_DEPENDENCY_RULES = ArchRules.in(CyclicDependencyRulesTest.class); + private final ArchRules NAMING_CONVENTION_RULES = ArchRules.in(NamingConventionTest.class); } diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SessionBeanRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SessionBeanRulesTest.java index 43639bd6c5..a8b1095d55 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SessionBeanRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SessionBeanRulesTest.java @@ -32,7 +32,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class SessionBeanRulesTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SingleClassTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SingleClassTest.java index 5476208008..f1e6366357 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SingleClassTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SingleClassTest.java @@ -1,9 +1,9 @@ package com.tngtech.archunit.exampletest.junit5; -import com.tngtech.archunit.example.SomeOtherBusinessInterface; -import com.tngtech.archunit.example.core.CoreSatellite; -import com.tngtech.archunit.example.core.HighSecurity; -import com.tngtech.archunit.example.core.VeryCentralCore; +import com.tngtech.archunit.example.layers.SomeOtherBusinessInterface; +import com.tngtech.archunit.example.layers.core.CoreSatellite; +import com.tngtech.archunit.example.layers.core.HighSecurity; +import com.tngtech.archunit.example.layers.core.VeryCentralCore; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -14,7 +14,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.theClass; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class SingleClassTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SlicesIsolationTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SlicesIsolationTest.java index 5912b13305..5bbfa607c0 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SlicesIsolationTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SlicesIsolationTest.java @@ -1,8 +1,8 @@ package com.tngtech.archunit.exampletest.junit5; import com.tngtech.archunit.base.DescribedPredicate; -import com.tngtech.archunit.example.controller.one.UseCaseOneTwoController; -import com.tngtech.archunit.example.controller.two.UseCaseTwoController; +import com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController; +import com.tngtech.archunit.example.layers.controller.two.UseCaseTwoController; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -14,7 +14,7 @@ import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class SlicesIsolationTest { @ArchTest static final ArchRule controllers_should_only_use_their_own_slice = diff --git a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ThirdPartyRulesTest.java b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ThirdPartyRulesTest.java index f625d3df2b..5394969f59 100644 --- a/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ThirdPartyRulesTest.java +++ b/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ThirdPartyRulesTest.java @@ -3,8 +3,8 @@ import com.tngtech.archunit.base.DescribedPredicate; import com.tngtech.archunit.core.domain.JavaCall; import com.tngtech.archunit.core.domain.JavaClass; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWithProblem; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWorkaroundFactory; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWithProblem; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWorkaroundFactory; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTag; import com.tngtech.archunit.junit.ArchTest; @@ -24,7 +24,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; @ArchTag("example") -@AnalyzeClasses(packages = "com.tngtech.archunit.example") +@AnalyzeClasses(packages = "com.tngtech.archunit.example.layers") public class ThirdPartyRulesTest { @ArchTest diff --git a/archunit-example/example-junit5/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 b/archunit-example/example-junit5/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 index 5da26125d6..0d923cc037 100644 --- a/archunit-example/example-junit5/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 +++ b/archunit-example/example-junit5/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 @@ -1,15 +1,15 @@ -Class implements interface in (DaoCallingService.java:0) -Class implements interface in (ServiceImplementation.java:0) -Constructor (com.tngtech.archunit.example.service.ServiceViolatingLayerRules)> has parameter of type in (SomeMediator.java:0) -Field has type in (SomeMediator.java:0) -Field has type in (SomeController.java:0) -Field has type in (SomeController.java:0) -Field has type in (DaoCallingService.java:0) -Field has type in (ServiceViolatingDaoRules.java:0) -Method calls method in (SomeMediator.java:15) -Method calls constructor ()> in (SomeGuiController.java:7) -Method calls constructor (java.lang.String)> in (SomeGuiController.java:8) -Method gets field in (SomeGuiController.java:10) -Method gets field in (SomeGuiController.java:11) -Method calls method in (DaoCallingService.java:14) -Method calls method in (ServiceViolatingDaoRules.java:27) \ No newline at end of file +Class implements interface in (DaoCallingService.java:0) +Class implements interface in (ServiceImplementation.java:0) +Constructor (com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules)> has parameter of type in (SomeMediator.java:0) +Field has type in (SomeMediator.java:0) +Field has type in (SomeController.java:0) +Field has type in (SomeController.java:0) +Field has type in (DaoCallingService.java:0) +Field has type in (ServiceViolatingDaoRules.java:0) +Method calls method in (SomeMediator.java:15) +Method calls constructor ()> in (SomeGuiController.java:7) +Method calls constructor (java.lang.String)> in (SomeGuiController.java:8) +Method gets field in (SomeGuiController.java:10) +Method gets field in (SomeGuiController.java:11) +Method calls method in (DaoCallingService.java:14) +Method calls method in (ServiceViolatingDaoRules.java:27) \ No newline at end of file diff --git a/archunit-example/example-junit5/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 b/archunit-example/example-junit5/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 index 6e464ed232..8b8178ae7f 100644 --- a/archunit-example/example-junit5/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 +++ b/archunit-example/example-junit5/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 @@ -1,9 +1,9 @@ -Class implements interface in (ServiceViolatingDaoRules.java:0) -Field has type in (SomeJpa.java:0) -Field has type in (OtherJpa.java:0) -Field has type in (ServiceViolatingDaoRules.java:0) -Method calls method in (SomeJpa.java:20) -Method has return type in (OtherDao.java:0) -Method calls method in (OtherJpa.java:19) -Method has return type in (OtherJpa.java:0) -Method calls method in (OtherJpa.java:24) \ No newline at end of file +Class implements interface in (ServiceViolatingDaoRules.java:0) +Field has type in (SomeJpa.java:0) +Field has type in (OtherJpa.java:0) +Field has type in (ServiceViolatingDaoRules.java:0) +Method calls method in (SomeJpa.java:20) +Method has return type in (OtherDao.java:0) +Method calls method in (OtherJpa.java:19) +Method has return type in (OtherJpa.java:0) +Method calls method in (OtherJpa.java:24) \ No newline at end of file diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeBusinessInterface.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeBusinessInterface.java deleted file mode 100644 index 1d694d415f..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeBusinessInterface.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example; - -public interface SomeBusinessInterface { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/InternalUtility.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/InternalUtility.java deleted file mode 100644 index 2dc6135da6..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/InternalUtility.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.tngtech.archunit.example.anticorruption; - -import com.tngtech.archunit.example.anticorruption.internal.InternalType; - -class InternalUtility { - InternalType okaySinceTheVisibilityIsNonPublic() { - return new InternalType(); - } -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WrappedResult.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WrappedResult.java deleted file mode 100644 index 682dba5af5..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WrappedResult.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.anticorruption; - -public class WrappedResult { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/internal/InternalType.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/internal/InternalType.java deleted file mode 100644 index b773628fa0..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/internal/InternalType.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.anticorruption.internal; - -public class InternalType { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeUtility.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeUtility.java deleted file mode 100644 index 674ad658c4..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeUtility.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.controller; - -public class SomeUtility { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/WronglyAnnotated.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/WronglyAnnotated.java deleted file mode 100644 index 9f40bd66d0..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/WronglyAnnotated.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.tngtech.archunit.example.controller; - -import com.tngtech.archunit.example.MyController; -import com.tngtech.archunit.example.core.HighSecurity; - -@HighSecurity -@MyController -public class WronglyAnnotated { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/CoreSatellite.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/CoreSatellite.java deleted file mode 100644 index cacd8331f4..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/CoreSatellite.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.core; - -public interface CoreSatellite { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/Cycles.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/Cycles.java deleted file mode 100644 index eb3f4de9cd..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/Cycles.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.cycle; - -public interface Cycles { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/InstantiatedClassInSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/InstantiatedClassInSliceTwo.java deleted file mode 100644 index 9aa666f4a0..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/InstantiatedClassInSliceTwo.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice2; - -public class InstantiatedClassInSliceTwo { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/SliceTwoInheritingFromSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/SliceTwoInheritingFromSliceOne.java deleted file mode 100644 index adf56d38d7..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/SliceTwoInheritingFromSliceOne.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice2; - -import com.tngtech.archunit.example.cycle.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; - -public class SliceTwoInheritingFromSliceOne extends SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour.java deleted file mode 100644 index adef6be607..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice2; - -import com.tngtech.archunit.example.cycle.complexcycles.slice3.InheritedClassInSliceThree; -import com.tngtech.archunit.example.cycle.complexcycles.slice4.ClassWithAccessedFieldCallingMethodInSliceOne; - -public class SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour extends InheritedClassInSliceThree { - void accessSliceFour() { - new ClassWithAccessedFieldCallingMethodInSliceOne().accessedField = "accessed"; - } -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice3/ClassCallingConstructorInSliceFive.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice3/ClassCallingConstructorInSliceFive.java deleted file mode 100644 index dc8a10eab1..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice3/ClassCallingConstructorInSliceFive.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice3; - -import com.tngtech.archunit.example.cycle.complexcycles.slice5.InstantiatedClassInSliceFive; - -public class ClassCallingConstructorInSliceFive { - public void callSliceFive() { - new InstantiatedClassInSliceFive(); - } -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice3/InheritedClassInSliceThree.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice3/InheritedClassInSliceThree.java deleted file mode 100644 index 9bc7cc1dac..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice3/InheritedClassInSliceThree.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice3; - -public class InheritedClassInSliceThree { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice5/InstantiatedClassInSliceFive.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice5/InstantiatedClassInSliceFive.java deleted file mode 100644 index 8c0b488186..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice5/InstantiatedClassInSliceFive.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice5; - -import com.tngtech.archunit.example.cycle.complexcycles.slice1.ClassBeingCalledInSliceOne; - -public class InstantiatedClassInSliceFive { - void callSliceOne() { - new ClassBeingCalledInSliceOne().doSomethingInSliceOne(); - } -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice6/UnproblematicClassInSliceSix.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice6/UnproblematicClassInSliceSix.java deleted file mode 100644 index 82834d8901..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice6/UnproblematicClassInSliceSix.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice6; - -import com.tngtech.archunit.example.cycle.complexcycles.slice1.ClassBeingCalledInSliceOne; -import com.tngtech.archunit.example.cycle.complexcycles.slice2.InstantiatedClassInSliceTwo; -import com.tngtech.archunit.example.cycle.complexcycles.slice4.ClassWithAccessedFieldCallingMethodInSliceOne; - -public class UnproblematicClassInSliceSix { - void callSliceOneTwoAndFour() { - new ClassBeingCalledInSliceOne(); - new InstantiatedClassInSliceTwo(); - new ClassWithAccessedFieldCallingMethodInSliceOne().accessedField = "accessed"; - } -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice1/SliceOneCallingConstructorInSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice1/SliceOneCallingConstructorInSliceTwo.java deleted file mode 100644 index 520969b534..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice1/SliceOneCallingConstructorInSliceTwo.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.tngtech.archunit.example.cycle.constructorcycle.slice1; - -import com.tngtech.archunit.example.cycle.constructorcycle.slice2.SliceTwoCallingConstructorInSliceOne; - -public class SliceOneCallingConstructorInSliceTwo { - void callSliceTwo() { - new SliceTwoCallingConstructorInSliceOne(); - } -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice1/SomeClassWithCalledConstructor.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice1/SomeClassWithCalledConstructor.java deleted file mode 100644 index ef3338fad6..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice1/SomeClassWithCalledConstructor.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.cycle.constructorcycle.slice1; - -public class SomeClassWithCalledConstructor { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatCallSliceThree.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatCallSliceThree.java deleted file mode 100644 index 19212ca1d8..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatCallSliceThree.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.tngtech.archunit.example.cycle.inheritancecycle.slice1; - -import com.tngtech.archunit.example.cycle.inheritancecycle.slice3.ClassThatImplementsInterfaceFromSliceOne; - -public class ClassThatCallSliceThree { - public ClassThatCallSliceThree() { - new ClassThatImplementsInterfaceFromSliceOne(); - } -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatInheritsFromSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatInheritsFromSliceTwo.java deleted file mode 100644 index bd8d26a58c..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatInheritsFromSliceTwo.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.tngtech.archunit.example.cycle.inheritancecycle.slice1; - -import com.tngtech.archunit.example.cycle.inheritancecycle.slice2.ClassThatInheritsFromSliceOne; - -public class ClassThatInheritsFromSliceTwo extends ClassThatInheritsFromSliceOne { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatIsInheritedFromSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatIsInheritedFromSliceTwo.java deleted file mode 100644 index 4cedbfd03b..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/ClassThatIsInheritedFromSliceTwo.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.cycle.inheritancecycle.slice1; - -public class ClassThatIsInheritedFromSliceTwo { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/InterfaceInSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/InterfaceInSliceOne.java deleted file mode 100644 index 18ce34206e..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice1/InterfaceInSliceOne.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.cycle.inheritancecycle.slice1; - -public interface InterfaceInSliceOne { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice2/ClassThatInheritsFromSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice2/ClassThatInheritsFromSliceOne.java deleted file mode 100644 index baadd605d3..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice2/ClassThatInheritsFromSliceOne.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.tngtech.archunit.example.cycle.inheritancecycle.slice2; - -import com.tngtech.archunit.example.cycle.inheritancecycle.slice1.ClassThatIsInheritedFromSliceTwo; - -public class ClassThatInheritsFromSliceOne extends ClassThatIsInheritedFromSliceTwo { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice3/ClassThatImplementsInterfaceFromSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice3/ClassThatImplementsInterfaceFromSliceOne.java deleted file mode 100644 index bac03c3423..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/inheritancecycle/slice3/ClassThatImplementsInterfaceFromSliceOne.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.tngtech.archunit.example.cycle.inheritancecycle.slice3; - -import com.tngtech.archunit.example.cycle.inheritancecycle.slice1.InterfaceInSliceOne; - -public class ClassThatImplementsInterfaceFromSliceOne implements InterfaceInSliceOne { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice1/SliceOneWithFieldTypeInSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice1/SliceOneWithFieldTypeInSliceTwo.java deleted file mode 100644 index 380f739a02..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice1/SliceOneWithFieldTypeInSliceTwo.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.tngtech.archunit.example.cycle.membercycle.slice1; - -import com.tngtech.archunit.example.cycle.membercycle.slice2.SliceTwoWithMethodParameterTypeInSliceThree; - -public class SliceOneWithFieldTypeInSliceTwo { - public SliceTwoWithMethodParameterTypeInSliceThree classInSliceTwo; -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/Cycles.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/Cycles.java new file mode 100644 index 0000000000..424c6671c8 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/Cycles.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.cycles; + +public interface Cycles { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/ClassBeingCalledInSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/ClassBeingCalledInSliceOne.java similarity index 58% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/ClassBeingCalledInSliceOne.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/ClassBeingCalledInSliceOne.java index 0228f7221c..7e8ee04a39 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/ClassBeingCalledInSliceOne.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/ClassBeingCalledInSliceOne.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice1; +package com.tngtech.archunit.example.cycles.complexcycles.slice1; public class ClassBeingCalledInSliceOne { public void doSomethingInSliceOne() { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/ClassOfMinimalCycleCallingSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/ClassOfMinimalCycleCallingSliceTwo.java similarity index 54% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/ClassOfMinimalCycleCallingSliceTwo.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/ClassOfMinimalCycleCallingSliceTwo.java index 3f2c571e5a..9f26402dbe 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/ClassOfMinimalCycleCallingSliceTwo.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/ClassOfMinimalCycleCallingSliceTwo.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice1; +package com.tngtech.archunit.example.cycles.complexcycles.slice1; -import com.tngtech.archunit.example.cycle.complexcycles.slice2.ClassOfMinimalCycleCallingSliceOne; +import com.tngtech.archunit.example.cycles.complexcycles.slice2.ClassOfMinimalCycleCallingSliceOne; public class ClassOfMinimalCycleCallingSliceTwo { private ClassOfMinimalCycleCallingSliceOne classInSliceTwo; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree.java similarity index 53% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree.java index b97a3daa7b..20ca9a6712 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree.java @@ -1,7 +1,7 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice1; +package com.tngtech.archunit.example.cycles.complexcycles.slice1; -import com.tngtech.archunit.example.cycle.complexcycles.slice2.InstantiatedClassInSliceTwo; -import com.tngtech.archunit.example.cycle.complexcycles.slice3.ClassCallingConstructorInSliceFive; +import com.tngtech.archunit.example.cycles.complexcycles.slice2.InstantiatedClassInSliceTwo; +import com.tngtech.archunit.example.cycles.complexcycles.slice3.ClassCallingConstructorInSliceFive; public class SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree { private ClassCallingConstructorInSliceFive classInSliceThree; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/UnrelatedEnum.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/UnrelatedEnum.java similarity index 85% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/UnrelatedEnum.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/UnrelatedEnum.java index 20023892c6..dc167cb9a0 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice1/UnrelatedEnum.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice1/UnrelatedEnum.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice1; +package com.tngtech.archunit.example.cycles.complexcycles.slice1; // This was just added for the integration tests since it creates some synthetic byte code @SuppressWarnings("SwitchStatementWithTooFewBranches") diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/ClassOfMinimalCycleCallingSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/ClassOfMinimalCycleCallingSliceOne.java similarity index 54% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/ClassOfMinimalCycleCallingSliceOne.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/ClassOfMinimalCycleCallingSliceOne.java index 5f9db6cf8f..616e1ae2d6 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice2/ClassOfMinimalCycleCallingSliceOne.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/ClassOfMinimalCycleCallingSliceOne.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice2; +package com.tngtech.archunit.example.cycles.complexcycles.slice2; -import com.tngtech.archunit.example.cycle.complexcycles.slice1.ClassOfMinimalCycleCallingSliceTwo; +import com.tngtech.archunit.example.cycles.complexcycles.slice1.ClassOfMinimalCycleCallingSliceTwo; public class ClassOfMinimalCycleCallingSliceOne { private ClassOfMinimalCycleCallingSliceTwo classInSliceOne; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/InstantiatedClassInSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/InstantiatedClassInSliceTwo.java new file mode 100644 index 0000000000..a279921fbf --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/InstantiatedClassInSliceTwo.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.cycles.complexcycles.slice2; + +public class InstantiatedClassInSliceTwo { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/SliceTwoInheritingFromSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/SliceTwoInheritingFromSliceOne.java new file mode 100644 index 0000000000..af0b3587c2 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/SliceTwoInheritingFromSliceOne.java @@ -0,0 +1,6 @@ +package com.tngtech.archunit.example.cycles.complexcycles.slice2; + +import com.tngtech.archunit.example.cycles.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; + +public class SliceTwoInheritingFromSliceOne extends SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour.java new file mode 100644 index 0000000000..469194af7a --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice2/SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour.java @@ -0,0 +1,10 @@ +package com.tngtech.archunit.example.cycles.complexcycles.slice2; + +import com.tngtech.archunit.example.cycles.complexcycles.slice3.InheritedClassInSliceThree; +import com.tngtech.archunit.example.cycles.complexcycles.slice4.ClassWithAccessedFieldCallingMethodInSliceOne; + +public class SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour extends InheritedClassInSliceThree { + void accessSliceFour() { + new ClassWithAccessedFieldCallingMethodInSliceOne().accessedField = "accessed"; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice3/ClassCallingConstructorInSliceFive.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice3/ClassCallingConstructorInSliceFive.java new file mode 100644 index 0000000000..adcf5a46a1 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice3/ClassCallingConstructorInSliceFive.java @@ -0,0 +1,9 @@ +package com.tngtech.archunit.example.cycles.complexcycles.slice3; + +import com.tngtech.archunit.example.cycles.complexcycles.slice5.InstantiatedClassInSliceFive; + +public class ClassCallingConstructorInSliceFive { + public void callSliceFive() { + new InstantiatedClassInSliceFive(); + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice3/InheritedClassInSliceThree.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice3/InheritedClassInSliceThree.java new file mode 100644 index 0000000000..abf0c78ade --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice3/InheritedClassInSliceThree.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.cycles.complexcycles.slice3; + +public class InheritedClassInSliceThree { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice4/ClassWithAccessedFieldCallingMethodInSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice4/ClassWithAccessedFieldCallingMethodInSliceOne.java similarity index 59% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice4/ClassWithAccessedFieldCallingMethodInSliceOne.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice4/ClassWithAccessedFieldCallingMethodInSliceOne.java index bc1d650da2..56a56b3ddc 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/complexcycles/slice4/ClassWithAccessedFieldCallingMethodInSliceOne.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice4/ClassWithAccessedFieldCallingMethodInSliceOne.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.complexcycles.slice4; +package com.tngtech.archunit.example.cycles.complexcycles.slice4; -import com.tngtech.archunit.example.cycle.complexcycles.slice1.ClassBeingCalledInSliceOne; +import com.tngtech.archunit.example.cycles.complexcycles.slice1.ClassBeingCalledInSliceOne; public class ClassWithAccessedFieldCallingMethodInSliceOne { private ClassBeingCalledInSliceOne classInSliceOne; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice5/InstantiatedClassInSliceFive.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice5/InstantiatedClassInSliceFive.java new file mode 100644 index 0000000000..15d0759525 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice5/InstantiatedClassInSliceFive.java @@ -0,0 +1,9 @@ +package com.tngtech.archunit.example.cycles.complexcycles.slice5; + +import com.tngtech.archunit.example.cycles.complexcycles.slice1.ClassBeingCalledInSliceOne; + +public class InstantiatedClassInSliceFive { + void callSliceOne() { + new ClassBeingCalledInSliceOne().doSomethingInSliceOne(); + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice6/UnproblematicClassInSliceSix.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice6/UnproblematicClassInSliceSix.java new file mode 100644 index 0000000000..2c6e9d0ab1 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/complexcycles/slice6/UnproblematicClassInSliceSix.java @@ -0,0 +1,13 @@ +package com.tngtech.archunit.example.cycles.complexcycles.slice6; + +import com.tngtech.archunit.example.cycles.complexcycles.slice1.ClassBeingCalledInSliceOne; +import com.tngtech.archunit.example.cycles.complexcycles.slice2.InstantiatedClassInSliceTwo; +import com.tngtech.archunit.example.cycles.complexcycles.slice4.ClassWithAccessedFieldCallingMethodInSliceOne; + +public class UnproblematicClassInSliceSix { + void callSliceOneTwoAndFour() { + new ClassBeingCalledInSliceOne(); + new InstantiatedClassInSliceTwo(); + new ClassWithAccessedFieldCallingMethodInSliceOne().accessedField = "accessed"; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice1/SliceOneCallingConstructorInSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice1/SliceOneCallingConstructorInSliceTwo.java new file mode 100644 index 0000000000..f2b4b7cdd1 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice1/SliceOneCallingConstructorInSliceTwo.java @@ -0,0 +1,9 @@ +package com.tngtech.archunit.example.cycles.constructorcycle.slice1; + +import com.tngtech.archunit.example.cycles.constructorcycle.slice2.SliceTwoCallingConstructorInSliceOne; + +public class SliceOneCallingConstructorInSliceTwo { + void callSliceTwo() { + new SliceTwoCallingConstructorInSliceOne(); + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice1/SomeClassWithCalledConstructor.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice1/SomeClassWithCalledConstructor.java new file mode 100644 index 0000000000..5456b4faf2 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice1/SomeClassWithCalledConstructor.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.cycles.constructorcycle.slice1; + +public class SomeClassWithCalledConstructor { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice2/SliceTwoCallingConstructorInSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice2/SliceTwoCallingConstructorInSliceOne.java similarity index 51% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice2/SliceTwoCallingConstructorInSliceOne.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice2/SliceTwoCallingConstructorInSliceOne.java index 70552c6fb9..45e4a34ba4 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/constructorcycle/slice2/SliceTwoCallingConstructorInSliceOne.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/constructorcycle/slice2/SliceTwoCallingConstructorInSliceOne.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.constructorcycle.slice2; +package com.tngtech.archunit.example.cycles.constructorcycle.slice2; -import com.tngtech.archunit.example.cycle.constructorcycle.slice1.SomeClassWithCalledConstructor; +import com.tngtech.archunit.example.cycles.constructorcycle.slice1.SomeClassWithCalledConstructor; public class SliceTwoCallingConstructorInSliceOne { void callSliceOne() { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice1/ClassInSliceOneWithAccessedField.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice1/ClassInSliceOneWithAccessedField.java similarity index 54% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice1/ClassInSliceOneWithAccessedField.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice1/ClassInSliceOneWithAccessedField.java index 12ffca4193..a974890f13 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice1/ClassInSliceOneWithAccessedField.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice1/ClassInSliceOneWithAccessedField.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.cycle.fieldaccesscycle.slice1; +package com.tngtech.archunit.example.cycles.fieldaccesscycle.slice1; public class ClassInSliceOneWithAccessedField { public String accessedField; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice1/SliceOneAccessingFieldInSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice1/SliceOneAccessingFieldInSliceTwo.java similarity index 54% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice1/SliceOneAccessingFieldInSliceTwo.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice1/SliceOneAccessingFieldInSliceTwo.java index b572ca5f29..36461786fb 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice1/SliceOneAccessingFieldInSliceTwo.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice1/SliceOneAccessingFieldInSliceTwo.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.fieldaccesscycle.slice1; +package com.tngtech.archunit.example.cycles.fieldaccesscycle.slice1; -import com.tngtech.archunit.example.cycle.fieldaccesscycle.slice2.SliceTwoAccessingFieldInSliceOne; +import com.tngtech.archunit.example.cycles.fieldaccesscycle.slice2.SliceTwoAccessingFieldInSliceOne; public class SliceOneAccessingFieldInSliceTwo { private SliceTwoAccessingFieldInSliceOne classInSliceTwo; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice2/SliceTwoAccessingFieldInSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice2/SliceTwoAccessingFieldInSliceOne.java similarity index 57% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice2/SliceTwoAccessingFieldInSliceOne.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice2/SliceTwoAccessingFieldInSliceOne.java index ea9f88de76..1c41170e37 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/fieldaccesscycle/slice2/SliceTwoAccessingFieldInSliceOne.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/fieldaccesscycle/slice2/SliceTwoAccessingFieldInSliceOne.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.fieldaccesscycle.slice2; +package com.tngtech.archunit.example.cycles.fieldaccesscycle.slice2; -import com.tngtech.archunit.example.cycle.fieldaccesscycle.slice1.ClassInSliceOneWithAccessedField; +import com.tngtech.archunit.example.cycles.fieldaccesscycle.slice1.ClassInSliceOneWithAccessedField; public class SliceTwoAccessingFieldInSliceOne { private ClassInSliceOneWithAccessedField classInSliceOne; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatCallSliceThree.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatCallSliceThree.java new file mode 100644 index 0000000000..4416adeb2c --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatCallSliceThree.java @@ -0,0 +1,9 @@ +package com.tngtech.archunit.example.cycles.inheritancecycle.slice1; + +import com.tngtech.archunit.example.cycles.inheritancecycle.slice3.ClassThatImplementsInterfaceFromSliceOne; + +public class ClassThatCallSliceThree { + public ClassThatCallSliceThree() { + new ClassThatImplementsInterfaceFromSliceOne(); + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatInheritsFromSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatInheritsFromSliceTwo.java new file mode 100644 index 0000000000..5422196d54 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatInheritsFromSliceTwo.java @@ -0,0 +1,6 @@ +package com.tngtech.archunit.example.cycles.inheritancecycle.slice1; + +import com.tngtech.archunit.example.cycles.inheritancecycle.slice2.ClassThatInheritsFromSliceOne; + +public class ClassThatInheritsFromSliceTwo extends ClassThatInheritsFromSliceOne { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatIsInheritedFromSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatIsInheritedFromSliceTwo.java new file mode 100644 index 0000000000..d3140cb7a4 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/ClassThatIsInheritedFromSliceTwo.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.cycles.inheritancecycle.slice1; + +public class ClassThatIsInheritedFromSliceTwo { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/InterfaceInSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/InterfaceInSliceOne.java new file mode 100644 index 0000000000..61e75b35d8 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice1/InterfaceInSliceOne.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.cycles.inheritancecycle.slice1; + +public interface InterfaceInSliceOne { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice2/ClassThatInheritsFromSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice2/ClassThatInheritsFromSliceOne.java new file mode 100644 index 0000000000..961bdf613b --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice2/ClassThatInheritsFromSliceOne.java @@ -0,0 +1,6 @@ +package com.tngtech.archunit.example.cycles.inheritancecycle.slice2; + +import com.tngtech.archunit.example.cycles.inheritancecycle.slice1.ClassThatIsInheritedFromSliceTwo; + +public class ClassThatInheritsFromSliceOne extends ClassThatIsInheritedFromSliceTwo { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice3/ClassThatImplementsInterfaceFromSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice3/ClassThatImplementsInterfaceFromSliceOne.java new file mode 100644 index 0000000000..559f01f19a --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/inheritancecycle/slice3/ClassThatImplementsInterfaceFromSliceOne.java @@ -0,0 +1,6 @@ +package com.tngtech.archunit.example.cycles.inheritancecycle.slice3; + +import com.tngtech.archunit.example.cycles.inheritancecycle.slice1.InterfaceInSliceOne; + +public class ClassThatImplementsInterfaceFromSliceOne implements InterfaceInSliceOne { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice1/SliceOneWithFieldTypeInSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice1/SliceOneWithFieldTypeInSliceTwo.java new file mode 100644 index 0000000000..7856f37ac7 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice1/SliceOneWithFieldTypeInSliceTwo.java @@ -0,0 +1,7 @@ +package com.tngtech.archunit.example.cycles.membercycle.slice1; + +import com.tngtech.archunit.example.cycles.membercycle.slice2.SliceTwoWithMethodParameterTypeInSliceThree; + +public class SliceOneWithFieldTypeInSliceTwo { + public SliceTwoWithMethodParameterTypeInSliceThree classInSliceTwo; +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice2/SliceTwoWithMethodParameterTypeInSliceThree.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice2/SliceTwoWithMethodParameterTypeInSliceThree.java similarity index 51% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice2/SliceTwoWithMethodParameterTypeInSliceThree.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice2/SliceTwoWithMethodParameterTypeInSliceThree.java index 605ce5a5d6..f14b417d51 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice2/SliceTwoWithMethodParameterTypeInSliceThree.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice2/SliceTwoWithMethodParameterTypeInSliceThree.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.membercycle.slice2; +package com.tngtech.archunit.example.cycles.membercycle.slice2; -import com.tngtech.archunit.example.cycle.membercycle.slice3.SliceThreeWithMethodReturnTypeInSliceFour; +import com.tngtech.archunit.example.cycles.membercycle.slice3.SliceThreeWithMethodReturnTypeInSliceFour; public class SliceTwoWithMethodParameterTypeInSliceThree { public void methodWithParameterInSliceThree(SliceThreeWithMethodReturnTypeInSliceFour methodParameter) { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice3/SliceThreeWithMethodReturnTypeInSliceFour.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice3/SliceThreeWithMethodReturnTypeInSliceFour.java similarity index 51% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice3/SliceThreeWithMethodReturnTypeInSliceFour.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice3/SliceThreeWithMethodReturnTypeInSliceFour.java index 2b97bdb77e..111ce68825 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice3/SliceThreeWithMethodReturnTypeInSliceFour.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice3/SliceThreeWithMethodReturnTypeInSliceFour.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.membercycle.slice3; +package com.tngtech.archunit.example.cycles.membercycle.slice3; -import com.tngtech.archunit.example.cycle.membercycle.slice4.SliceFourWithConstructorParameterInSliceOne; +import com.tngtech.archunit.example.cycles.membercycle.slice4.SliceFourWithConstructorParameterInSliceOne; public class SliceThreeWithMethodReturnTypeInSliceFour { public SliceFourWithConstructorParameterInSliceOne methodWithReturnTypeInSliceFour() { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice4/SliceFourWithConstructorParameterInSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice4/SliceFourWithConstructorParameterInSliceOne.java similarity index 52% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice4/SliceFourWithConstructorParameterInSliceOne.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice4/SliceFourWithConstructorParameterInSliceOne.java index 8f2c4e2157..1ee706d0fb 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/membercycle/slice4/SliceFourWithConstructorParameterInSliceOne.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/membercycle/slice4/SliceFourWithConstructorParameterInSliceOne.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.membercycle.slice4; +package com.tngtech.archunit.example.cycles.membercycle.slice4; -import com.tngtech.archunit.example.cycle.membercycle.slice1.SliceOneWithFieldTypeInSliceTwo; +import com.tngtech.archunit.example.cycles.membercycle.slice1.SliceOneWithFieldTypeInSliceTwo; public class SliceFourWithConstructorParameterInSliceOne { public SliceFourWithConstructorParameterInSliceOne(SliceOneWithFieldTypeInSliceTwo fieldInSliceTwo) { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice1/SliceOneCallingMethodInSliceTwo.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice1/SliceOneCallingMethodInSliceTwo.java similarity index 60% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice1/SliceOneCallingMethodInSliceTwo.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice1/SliceOneCallingMethodInSliceTwo.java index 5186122ec7..f27f361487 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice1/SliceOneCallingMethodInSliceTwo.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice1/SliceOneCallingMethodInSliceTwo.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.simplecycle.slice1; +package com.tngtech.archunit.example.cycles.simplecycle.slice1; -import com.tngtech.archunit.example.cycle.simplecycle.slice2.SliceTwoCallingMethodOfSliceThree; +import com.tngtech.archunit.example.cycles.simplecycle.slice2.SliceTwoCallingMethodOfSliceThree; public class SliceOneCallingMethodInSliceTwo { private SliceTwoCallingMethodOfSliceThree classInSliceTwo; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice1/SomeClassBeingCalledInSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice1/SomeClassBeingCalledInSliceOne.java similarity index 60% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice1/SomeClassBeingCalledInSliceOne.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice1/SomeClassBeingCalledInSliceOne.java index 32ce6dc08b..7d7763b4ac 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice1/SomeClassBeingCalledInSliceOne.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice1/SomeClassBeingCalledInSliceOne.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.cycle.simplecycle.slice1; +package com.tngtech.archunit.example.cycles.simplecycle.slice1; public class SomeClassBeingCalledInSliceOne { public void doSomethingInSliceOne() { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice2/SliceTwoCallingMethodOfSliceThree.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice2/SliceTwoCallingMethodOfSliceThree.java similarity index 61% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice2/SliceTwoCallingMethodOfSliceThree.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice2/SliceTwoCallingMethodOfSliceThree.java index e39fb42b1d..73dbcf0e30 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice2/SliceTwoCallingMethodOfSliceThree.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice2/SliceTwoCallingMethodOfSliceThree.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.simplecycle.slice2; +package com.tngtech.archunit.example.cycles.simplecycle.slice2; -import com.tngtech.archunit.example.cycle.simplecycle.slice3.SliceThreeCallingMethodOfSliceOne; +import com.tngtech.archunit.example.cycles.simplecycle.slice3.SliceThreeCallingMethodOfSliceOne; public class SliceTwoCallingMethodOfSliceThree { private SliceThreeCallingMethodOfSliceOne classInSliceThree; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice3/SliceThreeCallingMethodOfSliceOne.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice3/SliceThreeCallingMethodOfSliceOne.java similarity index 61% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice3/SliceThreeCallingMethodOfSliceOne.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice3/SliceThreeCallingMethodOfSliceOne.java index b1cc552036..b1998a07d8 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplecycle/slice3/SliceThreeCallingMethodOfSliceOne.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplecycle/slice3/SliceThreeCallingMethodOfSliceOne.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.simplecycle.slice3; +package com.tngtech.archunit.example.cycles.simplecycle.slice3; -import com.tngtech.archunit.example.cycle.simplecycle.slice1.SomeClassBeingCalledInSliceOne; +import com.tngtech.archunit.example.cycles.simplecycle.slice1.SomeClassBeingCalledInSliceOne; public class SliceThreeCallingMethodOfSliceOne { private SomeClassBeingCalledInSliceOne someClassInSliceOne; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/administration/AdministrationService.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/administration/AdministrationService.java similarity index 67% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/administration/AdministrationService.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/administration/AdministrationService.java index 77d971442c..502f2c1eb5 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/administration/AdministrationService.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/administration/AdministrationService.java @@ -1,9 +1,9 @@ -package com.tngtech.archunit.example.cycle.simplescenario.administration; +package com.tngtech.archunit.example.cycles.simplescenario.administration; import java.util.UUID; -import com.tngtech.archunit.example.cycle.simplescenario.report.Report; -import com.tngtech.archunit.example.cycle.simplescenario.report.ReportService; +import com.tngtech.archunit.example.cycles.simplescenario.report.Report; +import com.tngtech.archunit.example.cycles.simplescenario.report.ReportService; public class AdministrationService { private ReportService reportService; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/administration/Invoice.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/administration/Invoice.java similarity index 53% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/administration/Invoice.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/administration/Invoice.java index 859eefe8be..607d8e9749 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/administration/Invoice.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/administration/Invoice.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.cycle.simplescenario.administration; +package com.tngtech.archunit.example.cycles.simplescenario.administration; public class Invoice { public String getCustomer() { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/importer/ImportService.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/importer/ImportService.java similarity index 68% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/importer/ImportService.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/importer/ImportService.java index 9b2f6f0ba2..08bf866086 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/importer/ImportService.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/importer/ImportService.java @@ -1,8 +1,8 @@ -package com.tngtech.archunit.example.cycle.simplescenario.importer; +package com.tngtech.archunit.example.cycles.simplescenario.importer; import java.util.UUID; -import com.tngtech.archunit.example.cycle.simplescenario.administration.AdministrationService; +import com.tngtech.archunit.example.cycles.simplescenario.administration.AdministrationService; public class ImportService { private AdministrationService administrationService; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/report/Report.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/Report.java similarity index 55% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/report/Report.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/Report.java index d51733140d..44ddc175bd 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/report/Report.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/Report.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.cycle.simplescenario.report; +package com.tngtech.archunit.example.cycles.simplescenario.report; public class Report { public boolean isEmpty() { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/report/ReportService.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/ReportService.java similarity index 68% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/report/ReportService.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/ReportService.java index a0695e8a13..bfdc81139d 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycle/simplescenario/report/ReportService.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/ReportService.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.cycle.simplescenario.report; +package com.tngtech.archunit.example.cycles.simplescenario.report; -import com.tngtech.archunit.example.cycle.simplescenario.importer.ImportService; +import com.tngtech.archunit.example.cycles.simplescenario.importer.ImportService; public class ReportService { private ImportService importService; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/AbstractController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/AbstractController.java similarity index 50% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/AbstractController.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/AbstractController.java index 8ee8252de0..4c50e1367b 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/AbstractController.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/AbstractController.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; -import com.tngtech.archunit.example.web.InheritedControllerImpl; +import com.tngtech.archunit.example.layers.web.InheritedControllerImpl; /** * For demo purpose only, see {@link InheritedControllerImpl} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingCodingRules.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingCodingRules.java similarity index 97% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingCodingRules.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingCodingRules.java index a135821ba1..a5b2bf5a90 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingCodingRules.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingCodingRules.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; import java.io.FileNotFoundException; import java.io.PrintStream; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingSessionBeanRules.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingSessionBeanRules.java similarity index 95% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingSessionBeanRules.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingSessionBeanRules.java index cb08a64c07..60eff5d29d 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingSessionBeanRules.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingSessionBeanRules.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; import javax.annotation.PostConstruct; import javax.ejb.Local; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingThirdPartyRules.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingThirdPartyRules.java similarity index 66% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingThirdPartyRules.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingThirdPartyRules.java index 20bde04115..36cb21c5bb 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/ClassViolatingThirdPartyRules.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/ClassViolatingThirdPartyRules.java @@ -1,8 +1,8 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWithProblem; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWorkaroundFactory; -import com.tngtech.archunit.example.thirdparty.ThirdPartySubClassWithProblem; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWithProblem; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWorkaroundFactory; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartySubClassWithProblem; public class ClassViolatingThirdPartyRules { ThirdPartyClassWithProblem illegallyInstantiateThirdPartyClass() { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/EvilCoreAccessor.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/EvilCoreAccessor.java similarity index 57% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/EvilCoreAccessor.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/EvilCoreAccessor.java index 62b66603c0..831c7a6d15 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/EvilCoreAccessor.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/EvilCoreAccessor.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; -import com.tngtech.archunit.example.core.VeryCentralCore; +import com.tngtech.archunit.example.layers.core.VeryCentralCore; @SuppressWarnings("unused") public class EvilCoreAccessor { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/MyController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/MyController.java similarity index 77% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/MyController.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/MyController.java index 9aa156fd3e..71a5ab2c46 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/MyController.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/MyController.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; import java.lang.annotation.Retention; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/MyService.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/MyService.java similarity index 77% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/MyService.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/MyService.java index b1adcdfffc..3c4db6e91c 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/MyService.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/MyService.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; import java.lang.annotation.Retention; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/OtherClassViolatingSessionBeanRules.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/OtherClassViolatingSessionBeanRules.java similarity index 88% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/OtherClassViolatingSessionBeanRules.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/OtherClassViolatingSessionBeanRules.java index 94ad9310e2..199d7ff3d4 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/OtherClassViolatingSessionBeanRules.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/OtherClassViolatingSessionBeanRules.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; public class OtherClassViolatingSessionBeanRules { public static final String init = "init"; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SecondBeanImplementingSomeBusinessInterface.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SecondBeanImplementingSomeBusinessInterface.java similarity index 81% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SecondBeanImplementingSomeBusinessInterface.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SecondBeanImplementingSomeBusinessInterface.java index ea77085555..dc0f0f65d6 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SecondBeanImplementingSomeBusinessInterface.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SecondBeanImplementingSomeBusinessInterface.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; import javax.ejb.Local; import javax.ejb.Stateless; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeBusinessInterface.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeBusinessInterface.java new file mode 100644 index 0000000000..7167b7a587 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeBusinessInterface.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.layers; + +public interface SomeBusinessInterface { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeCustomException.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeCustomException.java similarity index 58% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeCustomException.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeCustomException.java index c89a280f06..3ab4b2d5ce 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeCustomException.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeCustomException.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; public class SomeCustomException extends RuntimeException { } diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeMediator.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeMediator.java similarity index 74% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeMediator.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeMediator.java index beb7e64ff8..3f9bb76885 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeMediator.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeMediator.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; -import com.tngtech.archunit.example.service.ServiceViolatingLayerRules; +import com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules; public class SomeMediator { public static final String violateLayerRulesIndirectly = "violateLayerRulesIndirectly"; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeOtherBusinessInterface.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeOtherBusinessInterface.java similarity index 52% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeOtherBusinessInterface.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeOtherBusinessInterface.java index bb20e33ea3..12419fb165 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/SomeOtherBusinessInterface.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/SomeOtherBusinessInterface.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example; +package com.tngtech.archunit.example.layers; public interface SomeOtherBusinessInterface { } diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/InternalUtility.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/InternalUtility.java new file mode 100644 index 0000000000..7ba252a563 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/InternalUtility.java @@ -0,0 +1,9 @@ +package com.tngtech.archunit.example.layers.anticorruption; + +import com.tngtech.archunit.example.layers.anticorruption.internal.InternalType; + +class InternalUtility { + InternalType okaySinceTheVisibilityIsNonPublic() { + return new InternalType(); + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WellBehaved.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WellBehaved.java similarity index 64% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WellBehaved.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WellBehaved.java index 81f84c4f95..5d82920d4a 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WellBehaved.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WellBehaved.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.anticorruption; +package com.tngtech.archunit.example.layers.anticorruption; public interface WellBehaved { WrappedResult someMethod(); diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WithIllegalReturnType.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WithIllegalReturnType.java similarity index 67% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WithIllegalReturnType.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WithIllegalReturnType.java index e70aec572b..5e258e1e5f 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/anticorruption/WithIllegalReturnType.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WithIllegalReturnType.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.anticorruption; +package com.tngtech.archunit.example.layers.anticorruption; -import com.tngtech.archunit.example.anticorruption.internal.InternalType; +import com.tngtech.archunit.example.layers.anticorruption.internal.InternalType; /** * We want classes in this layer to only return type {@link WrappedResult}, thus this interface here diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WrappedResult.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WrappedResult.java new file mode 100644 index 0000000000..d9f46e67df --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/WrappedResult.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.layers.anticorruption; + +public class WrappedResult { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/internal/InternalType.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/internal/InternalType.java new file mode 100644 index 0000000000..be38f58e88 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/anticorruption/internal/InternalType.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.layers.anticorruption.internal; + +public class InternalType { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeController.java similarity index 57% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeController.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeController.java index 382283753d..b305c6f69d 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeController.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeController.java @@ -1,7 +1,7 @@ -package com.tngtech.archunit.example.controller; +package com.tngtech.archunit.example.layers.controller; -import com.tngtech.archunit.example.service.ServiceViolatingDaoRules; -import com.tngtech.archunit.example.service.ServiceViolatingLayerRules; +import com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules; +import com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules; public class SomeController { private ServiceViolatingDaoRules service; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeGuiController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeGuiController.java similarity index 70% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeGuiController.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeGuiController.java index c6530d9334..4b8322819e 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/SomeGuiController.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeGuiController.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.controller; +package com.tngtech.archunit.example.layers.controller; -import com.tngtech.archunit.example.service.ServiceHelper; +import com.tngtech.archunit.example.layers.service.ServiceHelper; public class SomeGuiController { void callServiceLayer() { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeUtility.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeUtility.java new file mode 100644 index 0000000000..d89a8a5332 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/SomeUtility.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.layers.controller; + +public class SomeUtility { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/WronglyAnnotated.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/WronglyAnnotated.java new file mode 100644 index 0000000000..1db7a1f14d --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/WronglyAnnotated.java @@ -0,0 +1,9 @@ +package com.tngtech.archunit.example.layers.controller; + +import com.tngtech.archunit.example.layers.MyController; +import com.tngtech.archunit.example.layers.core.HighSecurity; + +@HighSecurity +@MyController +public class WronglyAnnotated { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/SomeEnum.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/SomeEnum.java similarity index 50% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/SomeEnum.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/SomeEnum.java index 5291042cab..09b05234a5 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/SomeEnum.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/SomeEnum.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.controller.one; +package com.tngtech.archunit.example.layers.controller.one; public enum SomeEnum { DISPATCH, diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/UseCaseOneThreeController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/UseCaseOneThreeController.java similarity index 78% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/UseCaseOneThreeController.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/UseCaseOneThreeController.java index 8f29cb55e5..2d71386ce2 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/UseCaseOneThreeController.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/UseCaseOneThreeController.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.controller.one; +package com.tngtech.archunit.example.layers.controller.one; -import com.tngtech.archunit.example.controller.three.UseCaseThreeController; +import com.tngtech.archunit.example.layers.controller.three.UseCaseThreeController; @SuppressWarnings("unused") public class UseCaseOneThreeController { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/UseCaseOneTwoController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/UseCaseOneTwoController.java similarity index 64% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/UseCaseOneTwoController.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/UseCaseOneTwoController.java index 3af1d90446..0596b5e911 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/one/UseCaseOneTwoController.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/one/UseCaseOneTwoController.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.controller.one; +package com.tngtech.archunit.example.layers.controller.one; -import com.tngtech.archunit.example.controller.two.UseCaseTwoController; +import com.tngtech.archunit.example.layers.controller.two.UseCaseTwoController; public class UseCaseOneTwoController { public static final String doSomethingOne = "doSomethingOne"; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/three/UseCaseThreeController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/three/UseCaseThreeController.java similarity index 59% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/three/UseCaseThreeController.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/three/UseCaseThreeController.java index e1e2fe59dc..4a854bdecd 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/three/UseCaseThreeController.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/three/UseCaseThreeController.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.controller.three; +package com.tngtech.archunit.example.layers.controller.three; -import com.tngtech.archunit.example.controller.one.UseCaseOneTwoController; +import com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController; public class UseCaseThreeController { public static final String doSomethingThree = "doSomethingThree"; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/two/UseCaseTwoController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/two/UseCaseTwoController.java similarity index 52% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/two/UseCaseTwoController.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/two/UseCaseTwoController.java index 724b730d7c..c31797bd4f 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/controller/two/UseCaseTwoController.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/controller/two/UseCaseTwoController.java @@ -1,7 +1,7 @@ -package com.tngtech.archunit.example.controller.two; +package com.tngtech.archunit.example.layers.controller.two; -import com.tngtech.archunit.example.AbstractController; -import com.tngtech.archunit.example.controller.one.UseCaseOneTwoController; +import com.tngtech.archunit.example.layers.AbstractController; +import com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController; public class UseCaseTwoController extends AbstractController { public static final String doSomethingTwo = "doSomethingTwo"; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/AnotherGoodCoreSatellite.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/AnotherGoodCoreSatellite.java similarity index 80% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/AnotherGoodCoreSatellite.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/AnotherGoodCoreSatellite.java index 648a09a8be..71b857b284 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/AnotherGoodCoreSatellite.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/AnotherGoodCoreSatellite.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.core; +package com.tngtech.archunit.example.layers.core; @SuppressWarnings("unused") public class AnotherGoodCoreSatellite implements CoreSatellite { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/CoreSatellite.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/CoreSatellite.java new file mode 100644 index 0000000000..334327b438 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/CoreSatellite.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.layers.core; + +public interface CoreSatellite { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/GoodCoreSatellite.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/GoodCoreSatellite.java similarity index 79% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/GoodCoreSatellite.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/GoodCoreSatellite.java index 5f57cbabae..21c910ba83 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/GoodCoreSatellite.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/GoodCoreSatellite.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.core; +package com.tngtech.archunit.example.layers.core; @SuppressWarnings("unused") public class GoodCoreSatellite implements CoreSatellite { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/HighSecurity.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/HighSecurity.java similarity index 75% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/HighSecurity.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/HighSecurity.java index 29393ba130..539146d1bb 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/HighSecurity.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/HighSecurity.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.core; +package com.tngtech.archunit.example.layers.core; import java.lang.annotation.Retention; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/VeryCentralCore.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/VeryCentralCore.java similarity index 61% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/VeryCentralCore.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/VeryCentralCore.java index 132afed07a..0aa2c9b417 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/core/VeryCentralCore.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/core/VeryCentralCore.java @@ -1,7 +1,7 @@ -package com.tngtech.archunit.example.core; +package com.tngtech.archunit.example.layers.core; -import com.tngtech.archunit.example.SomeOtherBusinessInterface; -import com.tngtech.archunit.example.web.AnnotatedController; +import com.tngtech.archunit.example.layers.SomeOtherBusinessInterface; +import com.tngtech.archunit.example.layers.web.AnnotatedController; @HighSecurity @SuppressWarnings("unused") diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/WrongSecurityCheck.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/WrongSecurityCheck.java similarity index 92% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/WrongSecurityCheck.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/WrongSecurityCheck.java index b1f918c019..22d87d1da0 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/WrongSecurityCheck.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/WrongSecurityCheck.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.persistence; +package com.tngtech.archunit.example.layers.persistence; import java.io.File; import java.io.FileInputStream; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/InWrongPackageDao.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/InWrongPackageDao.java new file mode 100644 index 0000000000..18172df5de --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/InWrongPackageDao.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.layers.persistence.first; + +public class InWrongPackageDao { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/EntityInWrongPackage.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/EntityInWrongPackage.java similarity index 82% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/EntityInWrongPackage.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/EntityInWrongPackage.java index edae3ca64a..c3d34104e5 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/EntityInWrongPackage.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/EntityInWrongPackage.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.persistence.first.dao; +package com.tngtech.archunit.example.layers.persistence.first.dao; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/SomeDao.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/SomeDao.java new file mode 100644 index 0000000000..6779beb8f1 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/SomeDao.java @@ -0,0 +1,7 @@ +package com.tngtech.archunit.example.layers.persistence.first.dao; + +import com.tngtech.archunit.example.layers.persistence.first.dao.domain.PersistentObject; + +public interface SomeDao { + PersistentObject findById(long id); +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/domain/PersistentObject.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/domain/PersistentObject.java similarity index 90% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/domain/PersistentObject.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/domain/PersistentObject.java index 701fbce718..56dc774674 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/domain/PersistentObject.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/domain/PersistentObject.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.persistence.first.dao.domain; +package com.tngtech.archunit.example.layers.persistence.first.dao.domain; import java.util.Objects; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/jpa/SomeJpa.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/jpa/SomeJpa.java similarity index 55% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/jpa/SomeJpa.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/jpa/SomeJpa.java index a6323189ce..088fd33023 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/jpa/SomeJpa.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/first/dao/jpa/SomeJpa.java @@ -1,11 +1,11 @@ -package com.tngtech.archunit.example.persistence.first.dao.jpa; +package com.tngtech.archunit.example.layers.persistence.first.dao.jpa; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import com.tngtech.archunit.example.persistence.first.dao.SomeDao; -import com.tngtech.archunit.example.persistence.first.dao.domain.PersistentObject; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.persistence.first.dao.SomeDao; +import com.tngtech.archunit.example.layers.persistence.first.dao.domain.PersistentObject; +import com.tngtech.archunit.example.layers.security.Secured; public class SomeJpa implements SomeDao { @PersistenceContext diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/layerviolation/DaoCallingService.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/layerviolation/DaoCallingService.java similarity index 61% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/layerviolation/DaoCallingService.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/layerviolation/DaoCallingService.java index 817ce1977e..0d6704f32a 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/layerviolation/DaoCallingService.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/layerviolation/DaoCallingService.java @@ -1,8 +1,8 @@ -package com.tngtech.archunit.example.persistence.layerviolation; +package com.tngtech.archunit.example.layers.persistence.layerviolation; -import com.tngtech.archunit.example.SomeMediator; -import com.tngtech.archunit.example.service.ServiceInterface; -import com.tngtech.archunit.example.service.ServiceViolatingLayerRules; +import com.tngtech.archunit.example.layers.SomeMediator; +import com.tngtech.archunit.example.layers.service.ServiceInterface; +import com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules; public class DaoCallingService implements ServiceInterface { public static final String violateLayerRules = "violateLayerRules"; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/OtherDao.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/OtherDao.java similarity index 59% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/OtherDao.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/OtherDao.java index 5a6ea9442b..84cf3b4945 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/OtherDao.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/OtherDao.java @@ -1,10 +1,10 @@ -package com.tngtech.archunit.example.persistence.second.dao; +package com.tngtech.archunit.example.layers.persistence.second.dao; -import javax.persistence.EntityManager; +import java.sql.SQLException; -import com.tngtech.archunit.example.persistence.second.dao.domain.OtherPersistentObject; +import javax.persistence.EntityManager; -import java.sql.SQLException; +import com.tngtech.archunit.example.layers.persistence.second.dao.domain.OtherPersistentObject; public interface OtherDao { OtherPersistentObject findById(long id); diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/domain/OtherPersistentObject.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/domain/OtherPersistentObject.java similarity index 91% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/domain/OtherPersistentObject.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/domain/OtherPersistentObject.java index 0fb623f925..6f989f1c00 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/domain/OtherPersistentObject.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/domain/OtherPersistentObject.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.persistence.second.dao.domain; +package com.tngtech.archunit.example.layers.persistence.second.dao.domain; import java.util.Objects; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/jpa/OtherJpa.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/jpa/OtherJpa.java similarity index 69% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/jpa/OtherJpa.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/jpa/OtherJpa.java index e9f3388be8..443c838092 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/second/dao/jpa/OtherJpa.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/persistence/second/dao/jpa/OtherJpa.java @@ -1,14 +1,14 @@ -package com.tngtech.archunit.example.persistence.second.dao.jpa; +package com.tngtech.archunit.example.layers.persistence.second.dao.jpa; + +import java.sql.Connection; +import java.sql.SQLException; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import com.tngtech.archunit.example.persistence.second.dao.OtherDao; -import com.tngtech.archunit.example.persistence.second.dao.domain.OtherPersistentObject; -import com.tngtech.archunit.example.security.Secured; - -import java.sql.Connection; -import java.sql.SQLException; +import com.tngtech.archunit.example.layers.persistence.second.dao.OtherDao; +import com.tngtech.archunit.example.layers.persistence.second.dao.domain.OtherPersistentObject; +import com.tngtech.archunit.example.layers.security.Secured; public class OtherJpa implements OtherDao { @PersistenceContext diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/security/AdditionalSecurityChecks.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/security/AdditionalSecurityChecks.java similarity index 84% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/security/AdditionalSecurityChecks.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/security/AdditionalSecurityChecks.java index 776028ec1b..3bff12744c 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/security/AdditionalSecurityChecks.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/security/AdditionalSecurityChecks.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.security; +package com.tngtech.archunit.example.layers.security; import java.security.cert.X509Certificate; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/security/Secured.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/security/Secured.java similarity index 73% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/security/Secured.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/security/Secured.java index 1cc3168f7c..3b1718c0f0 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/security/Secured.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/security/Secured.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.security; +package com.tngtech.archunit.example.layers.security; import java.lang.annotation.Retention; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceHelper.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceHelper.java similarity index 73% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceHelper.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceHelper.java index 13c14e16bf..1210abe8a4 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceHelper.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceHelper.java @@ -1,6 +1,6 @@ -package com.tngtech.archunit.example.service; +package com.tngtech.archunit.example.layers.service; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.security.Secured; /** * Well modelled code always has lots of 'helpers' ;-) diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceInterface.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceInterface.java new file mode 100644 index 0000000000..4cca280eb4 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceInterface.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.layers.service; + +public interface ServiceInterface { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceViolatingDaoRules.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceViolatingDaoRules.java similarity index 68% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceViolatingDaoRules.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceViolatingDaoRules.java index 6b9f95e6bb..72a8bf0c81 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceViolatingDaoRules.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceViolatingDaoRules.java @@ -1,13 +1,13 @@ -package com.tngtech.archunit.example.service; +package com.tngtech.archunit.example.layers.service; import javax.ejb.EJB; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import com.tngtech.archunit.example.MyService; -import com.tngtech.archunit.example.persistence.first.dao.SomeDao; -import com.tngtech.archunit.example.persistence.second.dao.OtherDao; -import com.tngtech.archunit.example.persistence.second.dao.domain.OtherPersistentObject; +import com.tngtech.archunit.example.layers.MyService; +import com.tngtech.archunit.example.layers.persistence.first.dao.SomeDao; +import com.tngtech.archunit.example.layers.persistence.second.dao.OtherDao; +import com.tngtech.archunit.example.layers.persistence.second.dao.domain.OtherPersistentObject; @MyService public class ServiceViolatingDaoRules { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceViolatingLayerRules.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceViolatingLayerRules.java similarity index 64% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceViolatingLayerRules.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceViolatingLayerRules.java index 62b90d9582..dec5cc9910 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceViolatingLayerRules.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/ServiceViolatingLayerRules.java @@ -1,10 +1,10 @@ -package com.tngtech.archunit.example.service; +package com.tngtech.archunit.example.layers.service; -import com.tngtech.archunit.example.MyService; -import com.tngtech.archunit.example.controller.SomeGuiController; -import com.tngtech.archunit.example.controller.one.UseCaseOneTwoController; -import com.tngtech.archunit.example.controller.two.UseCaseTwoController; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.MyService; +import com.tngtech.archunit.example.layers.controller.SomeGuiController; +import com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController; +import com.tngtech.archunit.example.layers.controller.two.UseCaseTwoController; +import com.tngtech.archunit.example.layers.security.Secured; @MyService public class ServiceViolatingLayerRules { diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/ServiceImplementation.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/ServiceImplementation.java new file mode 100644 index 0000000000..6bd187230e --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/ServiceImplementation.java @@ -0,0 +1,8 @@ +package com.tngtech.archunit.example.layers.service.impl; + +import com.tngtech.archunit.example.layers.MyService; +import com.tngtech.archunit.example.layers.service.ServiceInterface; + +@MyService +public class ServiceImplementation implements ServiceInterface { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/SomeInterfacePlacedInTheWrongPackage.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/SomeInterfacePlacedInTheWrongPackage.java similarity index 50% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/SomeInterfacePlacedInTheWrongPackage.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/SomeInterfacePlacedInTheWrongPackage.java index b25044be69..8a53f852a2 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/SomeInterfacePlacedInTheWrongPackage.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/SomeInterfacePlacedInTheWrongPackage.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.service.impl; +package com.tngtech.archunit.example.layers.service.impl; public interface SomeInterfacePlacedInTheWrongPackage { } diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/WronglyNamedSvc.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/WronglyNamedSvc.java new file mode 100644 index 0000000000..a9ada8d04e --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/service/impl/WronglyNamedSvc.java @@ -0,0 +1,7 @@ +package com.tngtech.archunit.example.layers.service.impl; + +import com.tngtech.archunit.example.layers.MyService; + +@MyService +public class WronglyNamedSvc { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartyClassWithProblem.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartyClassWithProblem.java similarity index 83% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartyClassWithProblem.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartyClassWithProblem.java index cd36e3a8ed..7480456f01 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartyClassWithProblem.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartyClassWithProblem.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.thirdparty; +package com.tngtech.archunit.example.layers.thirdparty; /** * This class simulates a problem with a third party class, where we can't influence the original code base. diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartyClassWorkaroundFactory.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartyClassWorkaroundFactory.java similarity index 89% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartyClassWorkaroundFactory.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartyClassWorkaroundFactory.java index 2f87fcbbd5..5a123cec06 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartyClassWorkaroundFactory.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartyClassWorkaroundFactory.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.thirdparty; +package com.tngtech.archunit.example.layers.thirdparty; /** * Assuming creation via this factory would provide some workaround for correct initialization in the given context. diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartySubClassWithProblem.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartySubClassWithProblem.java similarity index 59% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartySubClassWithProblem.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartySubClassWithProblem.java index d870ed3dfc..435b517a0a 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/thirdparty/ThirdPartySubClassWithProblem.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/thirdparty/ThirdPartySubClassWithProblem.java @@ -1,4 +1,4 @@ -package com.tngtech.archunit.example.thirdparty; +package com.tngtech.archunit.example.layers.thirdparty; public class ThirdPartySubClassWithProblem extends ThirdPartyClassWithProblem { } diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/web/AnnotatedController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/web/AnnotatedController.java new file mode 100644 index 0000000000..d0377c7f9b --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/web/AnnotatedController.java @@ -0,0 +1,7 @@ +package com.tngtech.archunit.example.layers.web; + +import com.tngtech.archunit.example.layers.MyController; + +@MyController +public class AnnotatedController { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/web/InheritedControllerImpl.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/web/InheritedControllerImpl.java new file mode 100644 index 0000000000..da248b4eec --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/layers/web/InheritedControllerImpl.java @@ -0,0 +1,6 @@ +package com.tngtech.archunit.example.layers.web; + +import com.tngtech.archunit.example.layers.AbstractController; + +public class InheritedControllerImpl extends AbstractController { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/cli/AdministrationCLI.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/cli/AdministrationCLI.java new file mode 100644 index 0000000000..c6d161d7f8 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/cli/AdministrationCLI.java @@ -0,0 +1,20 @@ +package com.tngtech.archunit.example.onionarchitecture.adapter.cli; + +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ProductRepository; +import com.tngtech.archunit.example.onionarchitecture.application.AdministrationPort; +import com.tngtech.archunit.example.onionarchitecture.application.ShoppingApplication; + +@SuppressWarnings("unused") +public class AdministrationCLI { + public static void main(String[] args) { + AdministrationPort port = ShoppingApplication.openAdministrationPort(); + handle(args, port); + } + + private static void handle(String[] args, AdministrationPort port) { + // violates the pairwise independence of adapters + ProductRepository repository = port.getInstanceOf(ProductRepository.class); + long count = repository.getTotalCount(); + // parse arguments and re-configure application according to count through port + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductId.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductId.java new file mode 100644 index 0000000000..e55c7abaf3 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductId.java @@ -0,0 +1,20 @@ +package com.tngtech.archunit.example.onionarchitecture.adapter.persistence; + +import java.util.UUID; + +@SuppressWarnings("unused") +public class ProductId { + private final UUID id; + + public ProductId(UUID id) { + if (id == null) { + throw new IllegalArgumentException("ID must not be null"); + } + this.id = id; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{id=" + id + '}'; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductJpaRepository.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductJpaRepository.java new file mode 100644 index 0000000000..456a147f6a --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductJpaRepository.java @@ -0,0 +1,17 @@ +package com.tngtech.archunit.example.onionarchitecture.adapter.persistence; + +import com.tngtech.archunit.example.onionarchitecture.domain.model.Product; +import com.tngtech.archunit.example.onionarchitecture.domain.service.ProductName; + +@SuppressWarnings("unused") +public class ProductJpaRepository implements ProductRepository { + @Override + public Product read(ProductId id) { + return new Product(id, new ProductName("would normally be read")); + } + + @Override + public long getTotalCount() { + return 0; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductRepository.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductRepository.java new file mode 100644 index 0000000000..62a3aa54e8 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductRepository.java @@ -0,0 +1,10 @@ +package com.tngtech.archunit.example.onionarchitecture.adapter.persistence; + +import com.tngtech.archunit.example.onionarchitecture.domain.model.Product; + +// Violates the architecture because Domain must be the owner of the interfaces, not the persistence adapter +public interface ProductRepository { + Product read(ProductId id); + + long getTotalCount(); +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartId.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartId.java new file mode 100644 index 0000000000..7239a90326 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartId.java @@ -0,0 +1,19 @@ +package com.tngtech.archunit.example.onionarchitecture.adapter.persistence; + +import java.util.UUID; + +public class ShoppingCartId { + private final UUID id; + + public ShoppingCartId(UUID id) { + if (id == null) { + throw new IllegalArgumentException("ID must not be null"); + } + this.id = id; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{id=" + id + '}'; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartJpaRepository.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartJpaRepository.java new file mode 100644 index 0000000000..1db45c8057 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartJpaRepository.java @@ -0,0 +1,17 @@ +package com.tngtech.archunit.example.onionarchitecture.adapter.persistence; + +import com.tngtech.archunit.example.onionarchitecture.domain.model.ShoppingCart; + +@SuppressWarnings("unused") +public class ShoppingCartJpaRepository implements ShoppingCartRepository { + @Override + public ShoppingCart read(ShoppingCartId id) { + // would normally load fully initialized shopping cart + return new ShoppingCart(id); + } + + @Override + public void save(ShoppingCart shoppingCart) { + // store shopping cart via JPA + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartRepository.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartRepository.java new file mode 100644 index 0000000000..d019599804 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartRepository.java @@ -0,0 +1,10 @@ +package com.tngtech.archunit.example.onionarchitecture.adapter.persistence; + +import com.tngtech.archunit.example.onionarchitecture.domain.model.ShoppingCart; + +// Violates the architecture because Domain must be the owner of the interfaces, not the persistence adapter +public interface ShoppingCartRepository { + ShoppingCart read(ShoppingCartId id); + + void save(ShoppingCart shoppingCart); +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/rest/ShoppingController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/rest/ShoppingController.java new file mode 100644 index 0000000000..8854cb7ee8 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/rest/ShoppingController.java @@ -0,0 +1,22 @@ +package com.tngtech.archunit.example.onionarchitecture.adapter.rest; + +import java.util.UUID; + +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ProductId; +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ShoppingCartId; +import com.tngtech.archunit.example.onionarchitecture.domain.service.OrderQuantity; +import com.tngtech.archunit.example.onionarchitecture.domain.service.ShoppingService; + +@SuppressWarnings("unused") +public class ShoppingController { + private final ShoppingService shoppingService; + + public ShoppingController(ShoppingService shoppingService) { + this.shoppingService = shoppingService; + } + + // @POST or similar + public void addToShoppingCart(UUID shoppingCartId, UUID productId, int quantity) { + shoppingService.addToShoppingCart(new ShoppingCartId(shoppingCartId), new ProductId(productId), new OrderQuantity(quantity)); + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/AdministrationPort.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/AdministrationPort.java new file mode 100644 index 0000000000..39bd9cfebf --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/AdministrationPort.java @@ -0,0 +1,5 @@ +package com.tngtech.archunit.example.onionarchitecture.application; + +public interface AdministrationPort { + T getInstanceOf(Class type); +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/ShoppingApplication.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/ShoppingApplication.java new file mode 100644 index 0000000000..f033c2f868 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/ShoppingApplication.java @@ -0,0 +1,16 @@ +package com.tngtech.archunit.example.onionarchitecture.application; + +public class ShoppingApplication { + public static void main(String[] args) { + // start the whole application / provide IOC features + } + + public static AdministrationPort openAdministrationPort() { + return new AdministrationPort() { + @Override + public T getInstanceOf(Class type) { + throw new UnsupportedOperationException("Not yet implemented"); + } + }; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/OrderItem.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/OrderItem.java new file mode 100644 index 0000000000..2b5f95f8fd --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/OrderItem.java @@ -0,0 +1,24 @@ +package com.tngtech.archunit.example.onionarchitecture.domain.model; + +import com.tngtech.archunit.example.onionarchitecture.domain.service.OrderQuantity; + +public class OrderItem { + private final Product product; + private final OrderQuantity quantity; + + public OrderItem(Product product, OrderQuantity quantity) { + if (product == null) { + throw new IllegalArgumentException("Product must not be null"); + } + if (quantity == null) { + throw new IllegalArgumentException("Quantity not be null"); + } + this.product = product; + this.quantity = quantity; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{product=" + product + ", quantity=" + quantity + '}'; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/PaymentMethod.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/PaymentMethod.java new file mode 100644 index 0000000000..1d08e9a1f9 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/PaymentMethod.java @@ -0,0 +1,5 @@ +package com.tngtech.archunit.example.onionarchitecture.domain.model; + +@SuppressWarnings("WeakerAccess") +public class PaymentMethod { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/Product.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/Product.java new file mode 100644 index 0000000000..cc488ee98e --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/Product.java @@ -0,0 +1,27 @@ +package com.tngtech.archunit.example.onionarchitecture.domain.model; + +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ProductId; +import com.tngtech.archunit.example.onionarchitecture.domain.service.ProductName; + +public class Product { + // Dependency on ProductId violates the architecture, since ProductId resides with persistence adapter + private final ProductId id; + // Dependency on ProductName violates the architecture, since ProductName is located in the DomainService layer + private final ProductName name; + + public Product(ProductId id, ProductName name) { + if (id == null) { + throw new IllegalArgumentException("Product id must not be null"); + } + if (name == null) { + throw new IllegalArgumentException("Product name must not be null"); + } + this.id = id; + this.name = name; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{id=" + id + ", name=" + name + '}'; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/ShoppingCart.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/ShoppingCart.java new file mode 100644 index 0000000000..3c23dd10e5 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/ShoppingCart.java @@ -0,0 +1,29 @@ +package com.tngtech.archunit.example.onionarchitecture.domain.model; + +import java.util.HashSet; +import java.util.Set; + +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ShoppingCartId; + +@SuppressWarnings("unused") +public class ShoppingCart { + private final ShoppingCartId id; + private final Set orderItems = new HashSet<>(); + + public ShoppingCart(ShoppingCartId id) { + this.id = id; + } + + public void add(OrderItem orderItem) { + orderItems.add(orderItem); + } + + public void executeOrder(PaymentMethod method) { + // complete financial transaction and initiate shipping process + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{id=" + id + ", orderItems=" + orderItems + '}'; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/OrderQuantity.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/OrderQuantity.java new file mode 100644 index 0000000000..f75fb0984c --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/OrderQuantity.java @@ -0,0 +1,18 @@ +package com.tngtech.archunit.example.onionarchitecture.domain.service; + +@SuppressWarnings("unused") +public class OrderQuantity { + private final int quantity; + + public OrderQuantity(int quantity) { + if (quantity <= 0) { + throw new IllegalArgumentException("Quantity must be positive"); + } + this.quantity = quantity; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{quantity=" + quantity + '}'; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/ProductName.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/ProductName.java new file mode 100644 index 0000000000..3ab56e6ea3 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/ProductName.java @@ -0,0 +1,18 @@ +package com.tngtech.archunit.example.onionarchitecture.domain.service; + +@SuppressWarnings("unused") +public class ProductName { + private final String name; + + public ProductName(String name) { + if (name == null || name.isEmpty()) { + throw new IllegalArgumentException("Name must not be empty"); + } + this.name = name; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{name='" + name + '\'' + '}'; + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/ShoppingService.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/ShoppingService.java new file mode 100644 index 0000000000..f5660cccc9 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/service/ShoppingService.java @@ -0,0 +1,27 @@ +package com.tngtech.archunit.example.onionarchitecture.domain.service; + +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ProductId; +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ProductRepository; +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ShoppingCartId; +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ShoppingCartRepository; +import com.tngtech.archunit.example.onionarchitecture.domain.model.OrderItem; +import com.tngtech.archunit.example.onionarchitecture.domain.model.Product; +import com.tngtech.archunit.example.onionarchitecture.domain.model.ShoppingCart; + +public class ShoppingService { + private final ShoppingCartRepository shoppingCartRepository; + private final ProductRepository productRepository; + + public ShoppingService(ShoppingCartRepository shoppingCartRepository, ProductRepository productRepository) { + this.shoppingCartRepository = shoppingCartRepository; + this.productRepository = productRepository; + } + + public void addToShoppingCart(ShoppingCartId shoppingCartId, ProductId productId, OrderQuantity quantity) { + ShoppingCart shoppingCart = shoppingCartRepository.read(shoppingCartId); + Product product = productRepository.read(productId); + OrderItem newItem = new OrderItem(product, quantity); + shoppingCart.add(newItem); + shoppingCartRepository.save(shoppingCart); + } +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/InWrongPackageDao.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/InWrongPackageDao.java deleted file mode 100644 index adbf9ca21f..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/InWrongPackageDao.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.persistence.first; - -public class InWrongPackageDao { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/SomeDao.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/SomeDao.java deleted file mode 100644 index 8aff9c0b76..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/persistence/first/dao/SomeDao.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.tngtech.archunit.example.persistence.first.dao; - -import com.tngtech.archunit.example.persistence.first.dao.domain.PersistentObject; - -public interface SomeDao { - PersistentObject findById(long id); -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/address/Address.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/address/Address.java new file mode 100644 index 0000000000..0ffe9c0c8b --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/address/Address.java @@ -0,0 +1,7 @@ +package com.tngtech.archunit.example.plantuml.address; + +import com.tngtech.archunit.example.plantuml.catalog.ProductCatalog; + +public class Address { + private ProductCatalog productCatalog; +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/catalog/ProductCatalog.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/catalog/ProductCatalog.java similarity index 63% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/catalog/ProductCatalog.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/catalog/ProductCatalog.java index d8c29f81cf..342e383f7b 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/catalog/ProductCatalog.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/catalog/ProductCatalog.java @@ -1,9 +1,9 @@ -package com.tngtech.archunit.example.shopping.catalog; +package com.tngtech.archunit.example.plantuml.catalog; import java.util.Set; -import com.tngtech.archunit.example.shopping.order.Order; -import com.tngtech.archunit.example.shopping.product.Product; +import com.tngtech.archunit.example.plantuml.order.Order; +import com.tngtech.archunit.example.plantuml.product.Product; public class ProductCatalog { private Set allProducts; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/customer/Customer.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/customer/Customer.java similarity index 57% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/customer/Customer.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/customer/Customer.java index bb620f43e9..d8524dfee8 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/customer/Customer.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/customer/Customer.java @@ -1,7 +1,7 @@ -package com.tngtech.archunit.example.shopping.customer; +package com.tngtech.archunit.example.plantuml.customer; -import com.tngtech.archunit.example.shopping.address.Address; -import com.tngtech.archunit.example.shopping.order.Order; +import com.tngtech.archunit.example.plantuml.address.Address; +import com.tngtech.archunit.example.plantuml.order.Order; public class Customer { private Address address; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/importer/ProductImport.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/importer/ProductImport.java similarity index 55% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/importer/ProductImport.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/importer/ProductImport.java index 891e909bf4..5862864668 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/importer/ProductImport.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/importer/ProductImport.java @@ -1,9 +1,9 @@ -package com.tngtech.archunit.example.shopping.importer; +package com.tngtech.archunit.example.plantuml.importer; -import com.tngtech.archunit.example.shopping.catalog.ProductCatalog; -import com.tngtech.archunit.example.shopping.customer.Customer; -import com.tngtech.archunit.example.shopping.xml.processor.XmlProcessor; -import com.tngtech.archunit.example.shopping.xml.types.XmlTypes; +import com.tngtech.archunit.example.plantuml.catalog.ProductCatalog; +import com.tngtech.archunit.example.plantuml.customer.Customer; +import com.tngtech.archunit.example.plantuml.xml.processor.XmlProcessor; +import com.tngtech.archunit.example.plantuml.xml.types.XmlTypes; public class ProductImport { public ProductCatalog productCatalog; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/order/Order.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/order/Order.java similarity index 63% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/order/Order.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/order/Order.java index a43494ba1c..cf7b5f756d 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/order/Order.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/order/Order.java @@ -1,10 +1,10 @@ -package com.tngtech.archunit.example.shopping.order; +package com.tngtech.archunit.example.plantuml.order; import java.util.Set; -import com.tngtech.archunit.example.shopping.address.Address; -import com.tngtech.archunit.example.shopping.customer.Customer; -import com.tngtech.archunit.example.shopping.product.Product; +import com.tngtech.archunit.example.plantuml.address.Address; +import com.tngtech.archunit.example.plantuml.customer.Customer; +import com.tngtech.archunit.example.plantuml.product.Product; public class Order { public Customer customer; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/product/Product.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/product/Product.java similarity index 56% rename from archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/product/Product.java rename to archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/product/Product.java index 0fe1bd8fb2..14f1d4ca4b 100644 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/product/Product.java +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/product/Product.java @@ -1,7 +1,7 @@ -package com.tngtech.archunit.example.shopping.product; +package com.tngtech.archunit.example.plantuml.product; -import com.tngtech.archunit.example.shopping.customer.Customer; -import com.tngtech.archunit.example.shopping.order.Order; +import com.tngtech.archunit.example.plantuml.customer.Customer; +import com.tngtech.archunit.example.plantuml.order.Order; public class Product { public Customer customer; diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/processor/XmlProcessor.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/processor/XmlProcessor.java new file mode 100644 index 0000000000..57f2a1d50c --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/processor/XmlProcessor.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.plantuml.xml.processor; + +public class XmlProcessor { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/types/XmlTypes.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/types/XmlTypes.java new file mode 100644 index 0000000000..1ba7ad07e3 --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/types/XmlTypes.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.plantuml.xml.types; + +public class XmlTypes { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/utils/XmlUtils.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/utils/XmlUtils.java new file mode 100644 index 0000000000..8674a9c93f --- /dev/null +++ b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/xml/utils/XmlUtils.java @@ -0,0 +1,4 @@ +package com.tngtech.archunit.example.plantuml.xml.utils; + +public class XmlUtils { +} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceInterface.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceInterface.java deleted file mode 100644 index ddf6061b79..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/ServiceInterface.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.service; - -public interface ServiceInterface { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/ServiceImplementation.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/ServiceImplementation.java deleted file mode 100644 index 7bb4e972bd..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/ServiceImplementation.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.tngtech.archunit.example.service.impl; - -import com.tngtech.archunit.example.MyService; -import com.tngtech.archunit.example.service.ServiceInterface; - -@MyService -public class ServiceImplementation implements ServiceInterface { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/WronglyNamedSvc.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/WronglyNamedSvc.java deleted file mode 100644 index 70dbf443b6..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/service/impl/WronglyNamedSvc.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.tngtech.archunit.example.service.impl; - -import com.tngtech.archunit.example.MyService; - -@MyService -public class WronglyNamedSvc { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/address/Address.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/address/Address.java deleted file mode 100644 index 60c4acc24f..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/address/Address.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.tngtech.archunit.example.shopping.address; - -import com.tngtech.archunit.example.shopping.catalog.ProductCatalog; - -public class Address { - private ProductCatalog productCatalog; -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/processor/XmlProcessor.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/processor/XmlProcessor.java deleted file mode 100644 index f78e525aea..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/processor/XmlProcessor.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.shopping.xml.processor; - -public class XmlProcessor { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/types/XmlTypes.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/types/XmlTypes.java deleted file mode 100644 index 5569db3057..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/types/XmlTypes.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.shopping.xml.types; - -public class XmlTypes { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/utils/XmlUtils.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/utils/XmlUtils.java deleted file mode 100644 index 20f9aa2cdd..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/shopping/xml/utils/XmlUtils.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.tngtech.archunit.example.shopping.xml.utils; - -public class XmlUtils { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/web/AnnotatedController.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/web/AnnotatedController.java deleted file mode 100644 index edac107060..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/web/AnnotatedController.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.tngtech.archunit.example.web; - -import com.tngtech.archunit.example.MyController; - -@MyController -public class AnnotatedController { -} diff --git a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/web/InheritedControllerImpl.java b/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/web/InheritedControllerImpl.java deleted file mode 100644 index 761e14b25b..0000000000 --- a/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/web/InheritedControllerImpl.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.tngtech.archunit.example.web; - -import com.tngtech.archunit.example.AbstractController; - -public class InheritedControllerImpl extends AbstractController { -} diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/CodingRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/CodingRulesTest.java index 7b349e4c2e..95bc6eae92 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/CodingRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/CodingRulesTest.java @@ -1,15 +1,14 @@ package com.tngtech.archunit.exampletest; +import java.util.logging.Logger; + import com.tngtech.archunit.core.domain.JavaClasses; -import com.tngtech.archunit.core.domain.JavaModifier; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.ClassViolatingCodingRules; +import com.tngtech.archunit.example.layers.ClassViolatingCodingRules; import com.tngtech.archunit.lang.CompositeArchRule; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.logging.Logger; - import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; import static com.tngtech.archunit.library.GeneralCodingRules.ACCESS_STANDARD_STREAMS; diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/ControllerRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/ControllerRulesTest.java index 9fb47ef486..6a0ec56301 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/ControllerRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/ControllerRulesTest.java @@ -6,7 +6,7 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.domain.JavaMember; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.security.Secured; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -19,7 +19,7 @@ @Category(Example.class) public class ControllerRulesTest { - private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example"); + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.layers"); @Test public void controllers_should_only_call_secured_methods() { diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/CyclicDependencyRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/CyclicDependencyRulesTest.java index 7fe9a12312..48f2597f2e 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/CyclicDependencyRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/CyclicDependencyRulesTest.java @@ -3,8 +3,8 @@ import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.cycle.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; -import com.tngtech.archunit.example.cycle.complexcycles.slice3.ClassCallingConstructorInSliceFive; +import com.tngtech.archunit.example.cycles.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; +import com.tngtech.archunit.example.cycles.complexcycles.slice3.ClassCallingConstructorInSliceFive; import com.tngtech.archunit.library.dependencies.SliceAssignment; import com.tngtech.archunit.library.dependencies.SliceIdentifier; import org.junit.Test; @@ -17,7 +17,7 @@ @Category(Example.class) public class CyclicDependencyRulesTest { - private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.cycle"); + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.cycles"); @Test public void no_cycles_by_method_calls_between_slices() { diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/DaoRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/DaoRulesTest.java index 3ad4cc4853..740b98a003 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/DaoRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/DaoRulesTest.java @@ -7,9 +7,9 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.persistence.first.InWrongPackageDao; -import com.tngtech.archunit.example.persistence.second.dao.OtherDao; -import com.tngtech.archunit.example.service.ServiceViolatingDaoRules; +import com.tngtech.archunit.example.layers.persistence.first.InWrongPackageDao; +import com.tngtech.archunit.example.layers.persistence.second.dao.OtherDao; +import com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/FrozenRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/FrozenRulesTest.java index 65a7f594f9..8329e0ed1c 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/FrozenRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/FrozenRulesTest.java @@ -5,7 +5,7 @@ import com.tngtech.archunit.ArchConfiguration; import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.ClassViolatingCodingRules; +import com.tngtech.archunit.example.layers.ClassViolatingCodingRules; import com.tngtech.archunit.library.freeze.FreezingArchRule; import com.tngtech.archunit.library.freeze.ViolationLineMatcher; import com.tngtech.archunit.library.freeze.ViolationStore; diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/InterfaceRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/InterfaceRulesTest.java index b1b0318467..8e85772e44 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/InterfaceRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/InterfaceRulesTest.java @@ -2,9 +2,9 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.SomeBusinessInterface; -import com.tngtech.archunit.example.persistence.first.dao.SomeDao; -import com.tngtech.archunit.example.service.impl.SomeInterfacePlacedInTheWrongPackage; +import com.tngtech.archunit.example.layers.SomeBusinessInterface; +import com.tngtech.archunit.example.layers.persistence.first.dao.SomeDao; +import com.tngtech.archunit.example.layers.service.impl.SomeInterfacePlacedInTheWrongPackage; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/LayerDependencyRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/LayerDependencyRulesTest.java index 88b909fca2..7dc4b8b535 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/LayerDependencyRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/LayerDependencyRulesTest.java @@ -2,7 +2,7 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.ClassViolatingCodingRules; +import com.tngtech.archunit.example.layers.ClassViolatingCodingRules; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/LayeredArchitectureTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/LayeredArchitectureTest.java index cfdbceffc0..ff9879a9d4 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/LayeredArchitectureTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/LayeredArchitectureTest.java @@ -2,8 +2,8 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.SomeMediator; -import com.tngtech.archunit.example.service.ServiceViolatingLayerRules; +import com.tngtech.archunit.example.layers.SomeMediator; +import com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -11,15 +11,15 @@ @Category(Example.class) public class LayeredArchitectureTest { - private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example"); + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.layers"); @Test public void layer_dependencies_are_respected() { layeredArchitecture() - .layer("Controllers").definedBy("com.tngtech.archunit.example.controller..") - .layer("Services").definedBy("com.tngtech.archunit.example.service..") - .layer("Persistence").definedBy("com.tngtech.archunit.example.persistence..") + .layer("Controllers").definedBy("com.tngtech.archunit.example.layers.controller..") + .layer("Services").definedBy("com.tngtech.archunit.example.layers.service..") + .layer("Persistence").definedBy("com.tngtech.archunit.example.layers.persistence..") .whereLayer("Controllers").mayNotBeAccessedByAnyLayer() .whereLayer("Services").mayOnlyBeAccessedByLayers("Controllers") @@ -32,9 +32,9 @@ public void layer_dependencies_are_respected() { public void layer_dependencies_are_respected_with_exception() { layeredArchitecture() - .layer("Controllers").definedBy("com.tngtech.archunit.example.controller..") - .layer("Services").definedBy("com.tngtech.archunit.example.service..") - .layer("Persistence").definedBy("com.tngtech.archunit.example.persistence..") + .layer("Controllers").definedBy("com.tngtech.archunit.example.layers.controller..") + .layer("Services").definedBy("com.tngtech.archunit.example.layers.service..") + .layer("Persistence").definedBy("com.tngtech.archunit.example.layers.persistence..") .whereLayer("Controllers").mayNotBeAccessedByAnyLayer() .whereLayer("Services").mayOnlyBeAccessedByLayers("Controllers") diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/MethodsTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/MethodsTest.java index 71246db77e..1fc6397d84 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/MethodsTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/MethodsTest.java @@ -2,8 +2,8 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.anticorruption.WrappedResult; -import com.tngtech.archunit.example.security.Secured; +import com.tngtech.archunit.example.layers.anticorruption.WrappedResult; +import com.tngtech.archunit.example.layers.security.Secured; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -12,7 +12,7 @@ @Category(Example.class) public class MethodsTest { - private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example"); + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.layers"); @Test public void all_public_methods_in_the_controller_layer_should_return_API_response_wrappers() { diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/NamingConventionTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/NamingConventionTest.java index ed7924f75b..538fbd2acb 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/NamingConventionTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/NamingConventionTest.java @@ -2,9 +2,9 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.AbstractController; -import com.tngtech.archunit.example.MyController; -import com.tngtech.archunit.example.MyService; +import com.tngtech.archunit.example.layers.AbstractController; +import com.tngtech.archunit.example.layers.MyController; +import com.tngtech.archunit.example.layers.MyService; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -13,7 +13,7 @@ @Category(Example.class) public class NamingConventionTest { - private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example"); + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.layers"); @Test public void services_should_be_prefixed() { diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/OnionArchitectureTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/OnionArchitectureTest.java new file mode 100644 index 0000000000..5ca8fc2238 --- /dev/null +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/OnionArchitectureTest.java @@ -0,0 +1,25 @@ +package com.tngtech.archunit.exampletest; + +import com.tngtech.archunit.core.domain.JavaClasses; +import com.tngtech.archunit.core.importer.ClassFileImporter; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import static com.tngtech.archunit.library.Architectures.onionArchitecture; + +@Category(Example.class) +public class OnionArchitectureTest { + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.onionarchitecture"); + + @Test + public void onion_architecture_is_respected() { + onionArchitecture() + .domainModels("..domain.model..") + .domainServices("..domain.service..") + .applicationServices("..application..") + .adapter("cli", "..adapter.cli..") + .adapter("persistence", "..adapter.persistence..") + .adapter("rest", "..adapter.rest..") + .check(classes); + } +} diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/PlantUmlArchitectureTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/PlantUmlArchitectureTest.java index bd3c33bd46..eb8210d9f1 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/PlantUmlArchitectureTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/PlantUmlArchitectureTest.java @@ -5,9 +5,9 @@ import com.tngtech.archunit.base.PackageMatchers; import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.shopping.catalog.ProductCatalog; -import com.tngtech.archunit.example.shopping.order.Order; -import com.tngtech.archunit.example.shopping.product.Product; +import com.tngtech.archunit.example.plantuml.catalog.ProductCatalog; +import com.tngtech.archunit.example.plantuml.order.Order; +import com.tngtech.archunit.example.plantuml.product.Product; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -22,7 +22,7 @@ @Category(Example.class) public class PlantUmlArchitectureTest { - private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.shopping"); + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.plantuml"); private final URL plantUmlDiagram = PlantUmlArchitectureTest.class.getResource("shopping_example.puml"); @Test diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/RestrictNumberOfClassesWithACertainPropertyTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/RestrictNumberOfClassesWithACertainPropertyTest.java index 0f932740b6..89ba9fc1da 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/RestrictNumberOfClassesWithACertainPropertyTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/RestrictNumberOfClassesWithACertainPropertyTest.java @@ -2,8 +2,8 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.SomeBusinessInterface; -import com.tngtech.archunit.example.SomeOtherBusinessInterface; +import com.tngtech.archunit.example.layers.SomeBusinessInterface; +import com.tngtech.archunit.example.layers.SomeOtherBusinessInterface; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -13,7 +13,7 @@ @Category(Example.class) public class RestrictNumberOfClassesWithACertainPropertyTest { - private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example"); + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.layers"); @Test public void no_new_classes_should_implement_SomeBusinessInterface() { diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SecurityTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SecurityTest.java index 83a4430c70..2944ab5f02 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SecurityTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SecurityTest.java @@ -16,10 +16,10 @@ public class SecurityTest { @Test public void only_security_infrastructure_should_use_java_security() { ArchRule rule = classes().that().resideInAPackage("java.security..") - .should().onlyBeAccessed().byAnyPackage("..example.security..", "java.security..") + .should().onlyBeAccessed().byAnyPackage("..example.layers.security..", "java.security..") .because("we want to have one isolated cross-cutting concern 'security'"); - JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example", "java.security"); + JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.layers", "java.security"); rule.check(classes); } @@ -27,7 +27,7 @@ public void only_security_infrastructure_should_use_java_security() { @Test public void only_security_infrastructure_should_use_java_security_on_whole_classpath() { ArchRule rule = classes().that().resideInAPackage("java.security.cert..") - .should().onlyBeAccessed().byAnyPackage("..example.security..", "java..", "..sun..", "javax..", "apple.security.."); + .should().onlyBeAccessed().byAnyPackage("..example.layers.security..", "java..", "..sun..", "javax..", "apple.security.."); JavaClasses classes = new ClassFileImporter().importClasspath(onlyAppAndRuntime()); diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SessionBeanRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SessionBeanRulesTest.java index eaae6f3865..2257e7117d 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SessionBeanRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SessionBeanRulesTest.java @@ -16,7 +16,7 @@ import com.tngtech.archunit.core.domain.JavaFieldAccess; import com.tngtech.archunit.core.domain.properties.HasOwner; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.ClassViolatingSessionBeanRules; +import com.tngtech.archunit.example.layers.ClassViolatingSessionBeanRules; import com.tngtech.archunit.lang.ArchCondition; import com.tngtech.archunit.lang.ConditionEvents; import com.tngtech.archunit.lang.SimpleConditionEvent; diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SingleClassTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SingleClassTest.java index 9fa0141586..284d726e1f 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SingleClassTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SingleClassTest.java @@ -2,11 +2,11 @@ import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.ClassViolatingCodingRules; -import com.tngtech.archunit.example.SomeOtherBusinessInterface; -import com.tngtech.archunit.example.core.CoreSatellite; -import com.tngtech.archunit.example.core.HighSecurity; -import com.tngtech.archunit.example.core.VeryCentralCore; +import com.tngtech.archunit.example.layers.ClassViolatingCodingRules; +import com.tngtech.archunit.example.layers.SomeOtherBusinessInterface; +import com.tngtech.archunit.example.layers.core.CoreSatellite; +import com.tngtech.archunit.example.layers.core.HighSecurity; +import com.tngtech.archunit.example.layers.core.VeryCentralCore; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SlicesIsolationTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SlicesIsolationTest.java index 4abf7341d8..ba9eabc312 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SlicesIsolationTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/SlicesIsolationTest.java @@ -4,8 +4,8 @@ import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.controller.one.UseCaseOneTwoController; -import com.tngtech.archunit.example.controller.two.UseCaseTwoController; +import com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController; +import com.tngtech.archunit.example.layers.controller.two.UseCaseTwoController; import com.tngtech.archunit.library.dependencies.Slice; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -16,7 +16,7 @@ @Category(Example.class) public class SlicesIsolationTest { - private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example"); + private final JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.example.layers"); @Test public void controllers_should_only_use_their_own_slice() { diff --git a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/ThirdPartyRulesTest.java b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/ThirdPartyRulesTest.java index cf7a162aae..8a5c3b6cda 100644 --- a/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/ThirdPartyRulesTest.java +++ b/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest/ThirdPartyRulesTest.java @@ -5,9 +5,9 @@ import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.ClassViolatingThirdPartyRules; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWithProblem; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWorkaroundFactory; +import com.tngtech.archunit.example.layers.ClassViolatingThirdPartyRules; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWithProblem; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWorkaroundFactory; import com.tngtech.archunit.lang.ArchCondition; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/archunit-example/example-plain/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 b/archunit-example/example-plain/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 index 5da26125d6..0d923cc037 100644 --- a/archunit-example/example-plain/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 +++ b/archunit-example/example-plain/src/test/resources/frozen/a81a2b54-5a18-4145-b544-7a580aba0425 @@ -1,15 +1,15 @@ -Class implements interface in (DaoCallingService.java:0) -Class implements interface in (ServiceImplementation.java:0) -Constructor (com.tngtech.archunit.example.service.ServiceViolatingLayerRules)> has parameter of type in (SomeMediator.java:0) -Field has type in (SomeMediator.java:0) -Field has type in (SomeController.java:0) -Field has type in (SomeController.java:0) -Field has type in (DaoCallingService.java:0) -Field has type in (ServiceViolatingDaoRules.java:0) -Method calls method in (SomeMediator.java:15) -Method calls constructor ()> in (SomeGuiController.java:7) -Method calls constructor (java.lang.String)> in (SomeGuiController.java:8) -Method gets field in (SomeGuiController.java:10) -Method gets field in (SomeGuiController.java:11) -Method calls method in (DaoCallingService.java:14) -Method calls method in (ServiceViolatingDaoRules.java:27) \ No newline at end of file +Class implements interface in (DaoCallingService.java:0) +Class implements interface in (ServiceImplementation.java:0) +Constructor (com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules)> has parameter of type in (SomeMediator.java:0) +Field has type in (SomeMediator.java:0) +Field has type in (SomeController.java:0) +Field has type in (SomeController.java:0) +Field has type in (DaoCallingService.java:0) +Field has type in (ServiceViolatingDaoRules.java:0) +Method calls method in (SomeMediator.java:15) +Method calls constructor ()> in (SomeGuiController.java:7) +Method calls constructor (java.lang.String)> in (SomeGuiController.java:8) +Method gets field in (SomeGuiController.java:10) +Method gets field in (SomeGuiController.java:11) +Method calls method in (DaoCallingService.java:14) +Method calls method in (ServiceViolatingDaoRules.java:27) \ No newline at end of file diff --git a/archunit-example/example-plain/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 b/archunit-example/example-plain/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 index 6e464ed232..8b8178ae7f 100644 --- a/archunit-example/example-plain/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 +++ b/archunit-example/example-plain/src/test/resources/frozen/e77ec262-4d5c-4a7b-b41f-362a71e5a1d8 @@ -1,9 +1,9 @@ -Class implements interface in (ServiceViolatingDaoRules.java:0) -Field has type in (SomeJpa.java:0) -Field has type in (OtherJpa.java:0) -Field has type in (ServiceViolatingDaoRules.java:0) -Method calls method in (SomeJpa.java:20) -Method has return type in (OtherDao.java:0) -Method calls method in (OtherJpa.java:19) -Method has return type in (OtherJpa.java:0) -Method calls method in (OtherJpa.java:24) \ No newline at end of file +Class implements interface in (ServiceViolatingDaoRules.java:0) +Field has type in (SomeJpa.java:0) +Field has type in (OtherJpa.java:0) +Field has type in (ServiceViolatingDaoRules.java:0) +Method calls method in (SomeJpa.java:20) +Method has return type in (OtherDao.java:0) +Method calls method in (OtherJpa.java:19) +Method has return type in (OtherJpa.java:0) +Method calls method in (OtherJpa.java:24) \ No newline at end of file diff --git a/archunit-integration-test/src/test/java/com/tngtech/archunit/integration/ExamplesIntegrationTest.java b/archunit-integration-test/src/test/java/com/tngtech/archunit/integration/ExamplesIntegrationTest.java index ed631dfd54..47d9964e93 100644 --- a/archunit-integration-test/src/test/java/com/tngtech/archunit/integration/ExamplesIntegrationTest.java +++ b/archunit-integration-test/src/test/java/com/tngtech/archunit/integration/ExamplesIntegrationTest.java @@ -7,6 +7,7 @@ import java.util.Collection; import java.util.List; import java.util.Set; +import java.util.UUID; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.stream.Stream; @@ -16,94 +17,106 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSet; import com.tngtech.archunit.core.domain.JavaModifier; -import com.tngtech.archunit.example.AbstractController; -import com.tngtech.archunit.example.ClassViolatingCodingRules; -import com.tngtech.archunit.example.ClassViolatingSessionBeanRules; -import com.tngtech.archunit.example.ClassViolatingThirdPartyRules; -import com.tngtech.archunit.example.EvilCoreAccessor; -import com.tngtech.archunit.example.MyController; -import com.tngtech.archunit.example.MyService; -import com.tngtech.archunit.example.OtherClassViolatingSessionBeanRules; -import com.tngtech.archunit.example.SecondBeanImplementingSomeBusinessInterface; -import com.tngtech.archunit.example.SomeBusinessInterface; -import com.tngtech.archunit.example.SomeCustomException; -import com.tngtech.archunit.example.SomeMediator; -import com.tngtech.archunit.example.SomeOtherBusinessInterface; -import com.tngtech.archunit.example.anticorruption.WithIllegalReturnType; -import com.tngtech.archunit.example.anticorruption.WrappedResult; -import com.tngtech.archunit.example.controller.SomeController; -import com.tngtech.archunit.example.controller.SomeGuiController; -import com.tngtech.archunit.example.controller.SomeUtility; -import com.tngtech.archunit.example.controller.WronglyAnnotated; -import com.tngtech.archunit.example.controller.one.SomeEnum; -import com.tngtech.archunit.example.controller.one.UseCaseOneThreeController; -import com.tngtech.archunit.example.controller.one.UseCaseOneTwoController; -import com.tngtech.archunit.example.controller.three.UseCaseThreeController; -import com.tngtech.archunit.example.controller.two.UseCaseTwoController; -import com.tngtech.archunit.example.core.CoreSatellite; -import com.tngtech.archunit.example.core.HighSecurity; -import com.tngtech.archunit.example.core.VeryCentralCore; -import com.tngtech.archunit.example.cycle.complexcycles.slice1.ClassBeingCalledInSliceOne; -import com.tngtech.archunit.example.cycle.complexcycles.slice1.ClassOfMinimalCycleCallingSliceTwo; -import com.tngtech.archunit.example.cycle.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; -import com.tngtech.archunit.example.cycle.complexcycles.slice2.ClassOfMinimalCycleCallingSliceOne; -import com.tngtech.archunit.example.cycle.complexcycles.slice2.InstantiatedClassInSliceTwo; -import com.tngtech.archunit.example.cycle.complexcycles.slice2.SliceTwoInheritingFromSliceOne; -import com.tngtech.archunit.example.cycle.complexcycles.slice2.SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour; -import com.tngtech.archunit.example.cycle.complexcycles.slice3.ClassCallingConstructorInSliceFive; -import com.tngtech.archunit.example.cycle.complexcycles.slice3.InheritedClassInSliceThree; -import com.tngtech.archunit.example.cycle.complexcycles.slice4.ClassWithAccessedFieldCallingMethodInSliceOne; -import com.tngtech.archunit.example.cycle.complexcycles.slice5.InstantiatedClassInSliceFive; -import com.tngtech.archunit.example.cycle.constructorcycle.slice1.SliceOneCallingConstructorInSliceTwo; -import com.tngtech.archunit.example.cycle.constructorcycle.slice1.SomeClassWithCalledConstructor; -import com.tngtech.archunit.example.cycle.constructorcycle.slice2.SliceTwoCallingConstructorInSliceOne; -import com.tngtech.archunit.example.cycle.fieldaccesscycle.slice1.ClassInSliceOneWithAccessedField; -import com.tngtech.archunit.example.cycle.fieldaccesscycle.slice1.SliceOneAccessingFieldInSliceTwo; -import com.tngtech.archunit.example.cycle.fieldaccesscycle.slice2.SliceTwoAccessingFieldInSliceOne; -import com.tngtech.archunit.example.cycle.inheritancecycle.slice1.ClassThatCallSliceThree; -import com.tngtech.archunit.example.cycle.inheritancecycle.slice1.ClassThatInheritsFromSliceTwo; -import com.tngtech.archunit.example.cycle.inheritancecycle.slice1.ClassThatIsInheritedFromSliceTwo; -import com.tngtech.archunit.example.cycle.inheritancecycle.slice1.InterfaceInSliceOne; -import com.tngtech.archunit.example.cycle.inheritancecycle.slice2.ClassThatInheritsFromSliceOne; -import com.tngtech.archunit.example.cycle.inheritancecycle.slice3.ClassThatImplementsInterfaceFromSliceOne; -import com.tngtech.archunit.example.cycle.membercycle.slice1.SliceOneWithFieldTypeInSliceTwo; -import com.tngtech.archunit.example.cycle.membercycle.slice2.SliceTwoWithMethodParameterTypeInSliceThree; -import com.tngtech.archunit.example.cycle.membercycle.slice3.SliceThreeWithMethodReturnTypeInSliceFour; -import com.tngtech.archunit.example.cycle.membercycle.slice4.SliceFourWithConstructorParameterInSliceOne; -import com.tngtech.archunit.example.cycle.simplecycle.slice1.SliceOneCallingMethodInSliceTwo; -import com.tngtech.archunit.example.cycle.simplecycle.slice1.SomeClassBeingCalledInSliceOne; -import com.tngtech.archunit.example.cycle.simplecycle.slice2.SliceTwoCallingMethodOfSliceThree; -import com.tngtech.archunit.example.cycle.simplecycle.slice3.SliceThreeCallingMethodOfSliceOne; -import com.tngtech.archunit.example.cycle.simplescenario.administration.AdministrationService; -import com.tngtech.archunit.example.cycle.simplescenario.administration.Invoice; -import com.tngtech.archunit.example.cycle.simplescenario.importer.ImportService; -import com.tngtech.archunit.example.cycle.simplescenario.report.Report; -import com.tngtech.archunit.example.cycle.simplescenario.report.ReportService; -import com.tngtech.archunit.example.persistence.WrongSecurityCheck; -import com.tngtech.archunit.example.persistence.first.InWrongPackageDao; -import com.tngtech.archunit.example.persistence.first.dao.EntityInWrongPackage; -import com.tngtech.archunit.example.persistence.first.dao.jpa.SomeJpa; -import com.tngtech.archunit.example.persistence.layerviolation.DaoCallingService; -import com.tngtech.archunit.example.persistence.second.dao.OtherDao; -import com.tngtech.archunit.example.persistence.second.dao.jpa.OtherJpa; -import com.tngtech.archunit.example.security.Secured; -import com.tngtech.archunit.example.service.ServiceHelper; -import com.tngtech.archunit.example.service.ServiceInterface; -import com.tngtech.archunit.example.service.ServiceViolatingDaoRules; -import com.tngtech.archunit.example.service.ServiceViolatingLayerRules; -import com.tngtech.archunit.example.service.impl.SomeInterfacePlacedInTheWrongPackage; -import com.tngtech.archunit.example.service.impl.WronglyNamedSvc; -import com.tngtech.archunit.example.shopping.address.Address; -import com.tngtech.archunit.example.shopping.catalog.ProductCatalog; -import com.tngtech.archunit.example.shopping.customer.Customer; -import com.tngtech.archunit.example.shopping.importer.ProductImport; -import com.tngtech.archunit.example.shopping.order.Order; -import com.tngtech.archunit.example.shopping.product.Product; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWithProblem; -import com.tngtech.archunit.example.thirdparty.ThirdPartyClassWorkaroundFactory; -import com.tngtech.archunit.example.thirdparty.ThirdPartySubClassWithProblem; -import com.tngtech.archunit.example.web.AnnotatedController; -import com.tngtech.archunit.example.web.InheritedControllerImpl; +import com.tngtech.archunit.example.cycles.complexcycles.slice1.ClassBeingCalledInSliceOne; +import com.tngtech.archunit.example.cycles.complexcycles.slice1.ClassOfMinimalCycleCallingSliceTwo; +import com.tngtech.archunit.example.cycles.complexcycles.slice1.SliceOneCallingConstructorInSliceTwoAndMethodInSliceThree; +import com.tngtech.archunit.example.cycles.complexcycles.slice2.ClassOfMinimalCycleCallingSliceOne; +import com.tngtech.archunit.example.cycles.complexcycles.slice2.InstantiatedClassInSliceTwo; +import com.tngtech.archunit.example.cycles.complexcycles.slice2.SliceTwoInheritingFromSliceOne; +import com.tngtech.archunit.example.cycles.complexcycles.slice2.SliceTwoInheritingFromSliceThreeAndAccessingFieldInSliceFour; +import com.tngtech.archunit.example.cycles.complexcycles.slice3.ClassCallingConstructorInSliceFive; +import com.tngtech.archunit.example.cycles.complexcycles.slice3.InheritedClassInSliceThree; +import com.tngtech.archunit.example.cycles.complexcycles.slice4.ClassWithAccessedFieldCallingMethodInSliceOne; +import com.tngtech.archunit.example.cycles.complexcycles.slice5.InstantiatedClassInSliceFive; +import com.tngtech.archunit.example.cycles.constructorcycle.slice1.SliceOneCallingConstructorInSliceTwo; +import com.tngtech.archunit.example.cycles.constructorcycle.slice1.SomeClassWithCalledConstructor; +import com.tngtech.archunit.example.cycles.constructorcycle.slice2.SliceTwoCallingConstructorInSliceOne; +import com.tngtech.archunit.example.cycles.fieldaccesscycle.slice1.ClassInSliceOneWithAccessedField; +import com.tngtech.archunit.example.cycles.fieldaccesscycle.slice1.SliceOneAccessingFieldInSliceTwo; +import com.tngtech.archunit.example.cycles.fieldaccesscycle.slice2.SliceTwoAccessingFieldInSliceOne; +import com.tngtech.archunit.example.cycles.inheritancecycle.slice1.ClassThatCallSliceThree; +import com.tngtech.archunit.example.cycles.inheritancecycle.slice1.ClassThatInheritsFromSliceTwo; +import com.tngtech.archunit.example.cycles.inheritancecycle.slice1.ClassThatIsInheritedFromSliceTwo; +import com.tngtech.archunit.example.cycles.inheritancecycle.slice1.InterfaceInSliceOne; +import com.tngtech.archunit.example.cycles.inheritancecycle.slice2.ClassThatInheritsFromSliceOne; +import com.tngtech.archunit.example.cycles.inheritancecycle.slice3.ClassThatImplementsInterfaceFromSliceOne; +import com.tngtech.archunit.example.cycles.membercycle.slice1.SliceOneWithFieldTypeInSliceTwo; +import com.tngtech.archunit.example.cycles.membercycle.slice2.SliceTwoWithMethodParameterTypeInSliceThree; +import com.tngtech.archunit.example.cycles.membercycle.slice3.SliceThreeWithMethodReturnTypeInSliceFour; +import com.tngtech.archunit.example.cycles.membercycle.slice4.SliceFourWithConstructorParameterInSliceOne; +import com.tngtech.archunit.example.cycles.simplecycle.slice1.SliceOneCallingMethodInSliceTwo; +import com.tngtech.archunit.example.cycles.simplecycle.slice1.SomeClassBeingCalledInSliceOne; +import com.tngtech.archunit.example.cycles.simplecycle.slice2.SliceTwoCallingMethodOfSliceThree; +import com.tngtech.archunit.example.cycles.simplecycle.slice3.SliceThreeCallingMethodOfSliceOne; +import com.tngtech.archunit.example.cycles.simplescenario.administration.AdministrationService; +import com.tngtech.archunit.example.cycles.simplescenario.administration.Invoice; +import com.tngtech.archunit.example.cycles.simplescenario.importer.ImportService; +import com.tngtech.archunit.example.cycles.simplescenario.report.Report; +import com.tngtech.archunit.example.cycles.simplescenario.report.ReportService; +import com.tngtech.archunit.example.layers.AbstractController; +import com.tngtech.archunit.example.layers.ClassViolatingCodingRules; +import com.tngtech.archunit.example.layers.ClassViolatingSessionBeanRules; +import com.tngtech.archunit.example.layers.ClassViolatingThirdPartyRules; +import com.tngtech.archunit.example.layers.EvilCoreAccessor; +import com.tngtech.archunit.example.layers.MyController; +import com.tngtech.archunit.example.layers.MyService; +import com.tngtech.archunit.example.layers.OtherClassViolatingSessionBeanRules; +import com.tngtech.archunit.example.layers.SecondBeanImplementingSomeBusinessInterface; +import com.tngtech.archunit.example.layers.SomeBusinessInterface; +import com.tngtech.archunit.example.layers.SomeCustomException; +import com.tngtech.archunit.example.layers.SomeMediator; +import com.tngtech.archunit.example.layers.SomeOtherBusinessInterface; +import com.tngtech.archunit.example.layers.anticorruption.WithIllegalReturnType; +import com.tngtech.archunit.example.layers.anticorruption.WrappedResult; +import com.tngtech.archunit.example.layers.controller.SomeController; +import com.tngtech.archunit.example.layers.controller.SomeGuiController; +import com.tngtech.archunit.example.layers.controller.SomeUtility; +import com.tngtech.archunit.example.layers.controller.WronglyAnnotated; +import com.tngtech.archunit.example.layers.controller.one.SomeEnum; +import com.tngtech.archunit.example.layers.controller.one.UseCaseOneThreeController; +import com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController; +import com.tngtech.archunit.example.layers.controller.three.UseCaseThreeController; +import com.tngtech.archunit.example.layers.controller.two.UseCaseTwoController; +import com.tngtech.archunit.example.layers.core.CoreSatellite; +import com.tngtech.archunit.example.layers.core.HighSecurity; +import com.tngtech.archunit.example.layers.core.VeryCentralCore; +import com.tngtech.archunit.example.layers.persistence.WrongSecurityCheck; +import com.tngtech.archunit.example.layers.persistence.first.InWrongPackageDao; +import com.tngtech.archunit.example.layers.persistence.first.dao.EntityInWrongPackage; +import com.tngtech.archunit.example.layers.persistence.first.dao.jpa.SomeJpa; +import com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService; +import com.tngtech.archunit.example.layers.persistence.second.dao.OtherDao; +import com.tngtech.archunit.example.layers.persistence.second.dao.jpa.OtherJpa; +import com.tngtech.archunit.example.layers.security.Secured; +import com.tngtech.archunit.example.layers.service.ServiceHelper; +import com.tngtech.archunit.example.layers.service.ServiceInterface; +import com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules; +import com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules; +import com.tngtech.archunit.example.layers.service.impl.SomeInterfacePlacedInTheWrongPackage; +import com.tngtech.archunit.example.layers.service.impl.WronglyNamedSvc; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWithProblem; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartyClassWorkaroundFactory; +import com.tngtech.archunit.example.layers.thirdparty.ThirdPartySubClassWithProblem; +import com.tngtech.archunit.example.layers.web.AnnotatedController; +import com.tngtech.archunit.example.layers.web.InheritedControllerImpl; +import com.tngtech.archunit.example.onionarchitecture.adapter.cli.AdministrationCLI; +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ProductId; +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ProductRepository; +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ShoppingCartId; +import com.tngtech.archunit.example.onionarchitecture.adapter.persistence.ShoppingCartRepository; +import com.tngtech.archunit.example.onionarchitecture.adapter.rest.ShoppingController; +import com.tngtech.archunit.example.onionarchitecture.application.AdministrationPort; +import com.tngtech.archunit.example.onionarchitecture.domain.model.OrderItem; +import com.tngtech.archunit.example.onionarchitecture.domain.model.ShoppingCart; +import com.tngtech.archunit.example.onionarchitecture.domain.service.OrderQuantity; +import com.tngtech.archunit.example.onionarchitecture.domain.service.ProductName; +import com.tngtech.archunit.example.onionarchitecture.domain.service.ShoppingService; +import com.tngtech.archunit.example.plantuml.address.Address; +import com.tngtech.archunit.example.plantuml.catalog.ProductCatalog; +import com.tngtech.archunit.example.plantuml.customer.Customer; +import com.tngtech.archunit.example.plantuml.importer.ProductImport; +import com.tngtech.archunit.example.plantuml.order.Order; +import com.tngtech.archunit.example.plantuml.product.Product; import com.tngtech.archunit.exampletest.ControllerRulesTest; import com.tngtech.archunit.exampletest.SecurityTest; import com.tngtech.archunit.testutils.CyclicErrorMatcher; @@ -123,16 +136,16 @@ import static com.google.common.base.Predicates.containsPattern; import static com.google.common.collect.Collections2.filter; import static com.tngtech.archunit.core.domain.JavaClass.namesOf; -import static com.tngtech.archunit.example.OtherClassViolatingSessionBeanRules.init; -import static com.tngtech.archunit.example.SomeMediator.violateLayerRulesIndirectly; -import static com.tngtech.archunit.example.controller.one.UseCaseOneTwoController.doSomethingOne; -import static com.tngtech.archunit.example.controller.one.UseCaseOneTwoController.someString; -import static com.tngtech.archunit.example.controller.three.UseCaseThreeController.doSomethingThree; -import static com.tngtech.archunit.example.controller.two.UseCaseTwoController.doSomethingTwo; -import static com.tngtech.archunit.example.core.VeryCentralCore.DO_CORE_STUFF_METHOD_NAME; -import static com.tngtech.archunit.example.persistence.layerviolation.DaoCallingService.violateLayerRules; -import static com.tngtech.archunit.example.service.ServiceViolatingLayerRules.dependentMethod; -import static com.tngtech.archunit.example.service.ServiceViolatingLayerRules.illegalAccessToController; +import static com.tngtech.archunit.example.layers.OtherClassViolatingSessionBeanRules.init; +import static com.tngtech.archunit.example.layers.SomeMediator.violateLayerRulesIndirectly; +import static com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController.doSomethingOne; +import static com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController.someString; +import static com.tngtech.archunit.example.layers.controller.three.UseCaseThreeController.doSomethingThree; +import static com.tngtech.archunit.example.layers.controller.two.UseCaseTwoController.doSomethingTwo; +import static com.tngtech.archunit.example.layers.core.VeryCentralCore.DO_CORE_STUFF_METHOD_NAME; +import static com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService.violateLayerRules; +import static com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules.dependentMethod; +import static com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules.illegalAccessToController; import static com.tngtech.archunit.testutils.CyclicErrorMatcher.cycle; import static com.tngtech.archunit.testutils.ExpectedAccess.callFromConstructor; import static com.tngtech.archunit.testutils.ExpectedAccess.callFromMethod; @@ -721,9 +734,9 @@ Stream LayeredArchitectureTest() { expectedTestFailures .ofRule(memberName, "Layered architecture consisting of" + lineSeparator() + - "layer 'Controllers' ('com.tngtech.archunit.example.controller..')" + lineSeparator() + - "layer 'Services' ('com.tngtech.archunit.example.service..')" + lineSeparator() + - "layer 'Persistence' ('com.tngtech.archunit.example.persistence..')" + lineSeparator() + + "layer 'Controllers' ('com.tngtech.archunit.example.layers.controller..')" + lineSeparator() + + "layer 'Services' ('com.tngtech.archunit.example.layers.service..')" + lineSeparator() + + "layer 'Persistence' ('com.tngtech.archunit.example.layers.persistence..')" + lineSeparator() + "where layer 'Controllers' may not be accessed by any layer" + lineSeparator() + "where layer 'Services' may only be accessed by layers ['Controllers']" + lineSeparator() + "where layer 'Persistence' may only be accessed by layers ['Services']") @@ -777,6 +790,60 @@ Stream LayeredArchitectureTest() { return expectedTestFailures.toDynamicTests(); } + @TestFactory + Stream OnionArchitectureTest() { + ExpectedTestFailures expectedTestFailures = ExpectedTestFailures + .forTests( + com.tngtech.archunit.exampletest.OnionArchitectureTest.class, + com.tngtech.archunit.exampletest.junit4.OnionArchitectureTest.class, + com.tngtech.archunit.exampletest.junit5.OnionArchitectureTest.class) + + .ofRule("Onion architecture consisting of" + lineSeparator() + + "domain models ('..domain.model..')" + lineSeparator() + + "domain services ('..domain.service..')" + lineSeparator() + + "application services ('..application..')" + lineSeparator() + + "adapter 'cli' ('..adapter.cli..')" + lineSeparator() + + "adapter 'persistence' ('..adapter.persistence..')" + lineSeparator() + + "adapter 'rest' ('..adapter.rest..')") + + .by(constructor(OrderItem.class).withParameter(OrderQuantity.class)) + .by(constructor(com.tngtech.archunit.example.onionarchitecture.domain.model.Product.class).withParameter(ProductId.class)) + .by(constructor(com.tngtech.archunit.example.onionarchitecture.domain.model.Product.class).withParameter(ProductName.class)) + .by(constructor(ShoppingCart.class).withParameter(ShoppingCartId.class)) + .by(constructor(ShoppingService.class).withParameter(ProductRepository.class)) + .by(constructor(ShoppingService.class).withParameter(ShoppingCartRepository.class)) + + .by(field(OrderItem.class, "quantity").ofType(OrderQuantity.class)) + .by(field(com.tngtech.archunit.example.onionarchitecture.domain.model.Product.class, "id").ofType(ProductId.class)) + .by(field(com.tngtech.archunit.example.onionarchitecture.domain.model.Product.class, "name").ofType(ProductName.class)) + .by(field(ShoppingCart.class, "id").ofType(ShoppingCartId.class)) + .by(field(ShoppingService.class, "productRepository").ofType(ProductRepository.class)) + .by(field(ShoppingService.class, "shoppingCartRepository").ofType(ShoppingCartRepository.class)) + + .by(callFromMethod(AdministrationCLI.class, "handle", String[].class, AdministrationPort.class) + .toMethod(ProductRepository.class, "getTotalCount") + .inLine(17).asDependency()) + .by(callFromMethod(ShoppingController.class, "addToShoppingCart", UUID.class, UUID.class, int.class) + .toConstructor(ProductId.class, UUID.class) + .inLine(20).asDependency()) + .by(callFromMethod(ShoppingController.class, "addToShoppingCart", UUID.class, UUID.class, int.class) + .toConstructor(ShoppingCartId.class, UUID.class) + .inLine(20).asDependency()) + .by(method(ShoppingService.class, "addToShoppingCart").withParameter(ProductId.class)) + .by(method(ShoppingService.class, "addToShoppingCart").withParameter(ShoppingCartId.class)) + .by(callFromMethod(ShoppingService.class, "addToShoppingCart", ShoppingCartId.class, ProductId.class, OrderQuantity.class) + .toMethod(ShoppingCartRepository.class, "read", ShoppingCartId.class) + .inLine(21).asDependency()) + .by(callFromMethod(ShoppingService.class, "addToShoppingCart", ShoppingCartId.class, ProductId.class, OrderQuantity.class) + .toMethod(ProductRepository.class, "read", ProductId.class) + .inLine(22).asDependency()) + .by(callFromMethod(ShoppingService.class, "addToShoppingCart", ShoppingCartId.class, ProductId.class, OrderQuantity.class) + .toMethod(ShoppingCartRepository.class, "save", ShoppingCart.class) + .inLine(25).asDependency()); + + return expectedTestFailures.toDynamicTests(); + } + @TestFactory Stream MethodsTest() { return ExpectedTestFailures @@ -948,11 +1015,11 @@ Stream SecurityTest() { .inLine(19)); addExpectedFailure.accept("classes that reside in a package 'java.security..' " - + "should only be accessed by any package ['..example.security..', 'java.security..'], " + + "should only be accessed by any package ['..example.layers.security..', 'java.security..'], " + "because we want to have one isolated cross-cutting concern 'security'"); addExpectedFailure.accept("classes that reside in a package 'java.security.cert..' " - + "should only be accessed by any package ['..example.security..', 'java..', '..sun..', 'javax..', 'apple.security..']"); + + "should only be accessed by any package ['..example.layers.security..', 'java..', '..sun..', 'javax..', 'apple.security..']"); return expectedTestFailures.toDynamicTests(); } diff --git a/archunit-integration-test/src/test/java/com/tngtech/archunit/integration/ExtensionIntegrationTest.java b/archunit-integration-test/src/test/java/com/tngtech/archunit/integration/ExtensionIntegrationTest.java index 5956fa1232..7721526c02 100644 --- a/archunit-integration-test/src/test/java/com/tngtech/archunit/integration/ExtensionIntegrationTest.java +++ b/archunit-integration-test/src/test/java/com/tngtech/archunit/integration/ExtensionIntegrationTest.java @@ -6,7 +6,7 @@ import com.tngtech.archunit.ArchConfiguration; import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; -import com.tngtech.archunit.example.ClassViolatingCodingRules; +import com.tngtech.archunit.example.layers.ClassViolatingCodingRules; import com.tngtech.archunit.exampletest.extension.EvaluatedRuleEvent; import com.tngtech.archunit.exampletest.extension.ExampleExtension; import com.tngtech.archunit.lang.ArchRule; diff --git a/archunit/src/main/java/com/tngtech/archunit/library/Architectures.java b/archunit/src/main/java/com/tngtech/archunit/library/Architectures.java index d94f785796..e3adda82ad 100644 --- a/archunit/src/main/java/com/tngtech/archunit/library/Architectures.java +++ b/archunit/src/main/java/com/tngtech/archunit/library/Architectures.java @@ -15,6 +15,9 @@ */ package com.tngtech.archunit.library; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -289,4 +292,137 @@ public String toString() { } } } + + @PublicAPI(usage = ACCESS) + public static OnionArchitecture onionArchitecture() { + return new OnionArchitecture(); + } + + public static final class OnionArchitecture implements ArchRule { + private static final String DOMAIN_MODEL_LAYER = "domain model"; + private static final String DOMAIN_SERVICE_LAYER = "domain service"; + private static final String APPLICATION_SERVICE_LAYER = "application service"; + private static final String ADAPTER_LAYER = "adapter"; + + private String[] domainModelPackageIdentifiers = new String[0]; + private String[] domainServicePackageIdentifiers = new String[0]; + private String[] applicationPackageIdentifiers = new String[0]; + private Map adapterPackageIdentifiers = new LinkedHashMap<>(); + + private final Optional overriddenDescription; + + private OnionArchitecture() { + overriddenDescription = Optional.absent(); + } + + private OnionArchitecture(String[] domainModelPackageIdentifiers, + String[] domainServicePackageIdentifiers, + String[] applicationPackageIdentifiers, + Map adapterPackageIdentifiers, + Optional overriddenDescription) { + this.domainModelPackageIdentifiers = domainModelPackageIdentifiers; + this.domainServicePackageIdentifiers = domainServicePackageIdentifiers; + this.applicationPackageIdentifiers = applicationPackageIdentifiers; + this.adapterPackageIdentifiers = adapterPackageIdentifiers; + this.overriddenDescription = overriddenDescription; + } + + @PublicAPI(usage = ACCESS) + public OnionArchitecture domainModels(String... packageIdentifiers) { + domainModelPackageIdentifiers = packageIdentifiers; + return this; + } + + @PublicAPI(usage = ACCESS) + public OnionArchitecture domainServices(String... packageIdentifiers) { + domainServicePackageIdentifiers = packageIdentifiers; + return this; + } + + @PublicAPI(usage = ACCESS) + public OnionArchitecture applicationServices(String... packageIdentifiers) { + applicationPackageIdentifiers = packageIdentifiers; + return this; + } + + @PublicAPI(usage = ACCESS) + public OnionArchitecture adapter(String name, String... packageIdentifiers) { + adapterPackageIdentifiers.put(name, packageIdentifiers); + return this; + } + + private LayeredArchitecture layeredArchitectureDelegate() { + LayeredArchitecture layeredArchitectureDelegate = layeredArchitecture() + .layer(DOMAIN_MODEL_LAYER).definedBy(domainModelPackageIdentifiers) + .layer(DOMAIN_SERVICE_LAYER).definedBy(domainServicePackageIdentifiers) + .layer(APPLICATION_SERVICE_LAYER).definedBy(applicationPackageIdentifiers) + .layer(ADAPTER_LAYER).definedBy(concatenateAll(adapterPackageIdentifiers.values())) + .whereLayer(DOMAIN_MODEL_LAYER).mayOnlyBeAccessedByLayers(DOMAIN_SERVICE_LAYER, APPLICATION_SERVICE_LAYER, ADAPTER_LAYER) + .whereLayer(DOMAIN_SERVICE_LAYER).mayOnlyBeAccessedByLayers(APPLICATION_SERVICE_LAYER, ADAPTER_LAYER) + .whereLayer(APPLICATION_SERVICE_LAYER).mayOnlyBeAccessedByLayers(ADAPTER_LAYER); + + for (Map.Entry adapter : adapterPackageIdentifiers.entrySet()) { + String adapterLayer = getAdapterLayer(adapter.getKey()); + layeredArchitectureDelegate = layeredArchitectureDelegate + .layer(adapterLayer).definedBy(adapter.getValue()) + .whereLayer(adapterLayer).mayNotBeAccessedByAnyLayer(); + } + return layeredArchitectureDelegate.as(getDescription()); + } + + private String[] concatenateAll(Collection arrays) { + List resultList = new ArrayList<>(); + for (String[] array : arrays) { + resultList.addAll(Arrays.asList(array)); + } + return resultList.toArray(new String[0]); + } + + private String getAdapterLayer(String name) { + return String.format("%s %s", name, ADAPTER_LAYER); + } + + @Override + public void check(JavaClasses classes) { + layeredArchitectureDelegate().check(classes); + } + + @Override + public ArchRule because(String reason) { + return ArchRule.Factory.withBecause(this, reason); + } + + @Override + public OnionArchitecture as(String newDescription) { + return new OnionArchitecture(domainModelPackageIdentifiers, domainServicePackageIdentifiers, + applicationPackageIdentifiers, adapterPackageIdentifiers, Optional.of(newDescription)); + } + + @Override + public EvaluationResult evaluate(JavaClasses classes) { + return layeredArchitectureDelegate().evaluate(classes); + } + + @Override + public String getDescription() { + if (overriddenDescription.isPresent()) { + return overriddenDescription.get(); + } + + List lines = newArrayList("Onion architecture consisting of"); + if (domainModelPackageIdentifiers.length > 0) { + lines.add(String.format("domain models ('%s')", Joiner.on("', '").join(domainModelPackageIdentifiers))); + } + if (domainServicePackageIdentifiers.length > 0) { + lines.add(String.format("domain services ('%s')", Joiner.on("', '").join(domainServicePackageIdentifiers))); + } + if (applicationPackageIdentifiers.length > 0) { + lines.add(String.format("application services ('%s')", Joiner.on("', '").join(applicationPackageIdentifiers))); + } + for (Map.Entry adapter : adapterPackageIdentifiers.entrySet()) { + lines.add(String.format("adapter '%s' ('%s')", adapter.getKey(), Joiner.on("', '").join(adapter.getValue()))); + } + return Joiner.on(lineSeparator()).join(lines); + } + } } diff --git a/archunit/src/test/java/com/tngtech/archunit/library/ArchitecturesTest.java b/archunit/src/test/java/com/tngtech/archunit/library/ArchitecturesTest.java index b7e2b58cd2..be1d1fc500 100644 --- a/archunit/src/test/java/com/tngtech/archunit/library/ArchitecturesTest.java +++ b/archunit/src/test/java/com/tngtech/archunit/library/ArchitecturesTest.java @@ -13,8 +13,15 @@ import com.tngtech.archunit.lang.ArchRule; import com.tngtech.archunit.lang.EvaluationResult; import com.tngtech.archunit.library.Architectures.LayeredArchitecture; +import com.tngtech.archunit.library.Architectures.OnionArchitecture; import com.tngtech.archunit.library.testclasses.first.any.pkg.FirstAnyPkgClass; import com.tngtech.archunit.library.testclasses.first.three.any.FirstThreeAnyClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.cli.CliAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.persistence.PersistenceAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.rest.RestAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.application.ApplicationLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.model.DomainModelLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.service.DomainServiceLayerClass; import com.tngtech.archunit.library.testclasses.second.three.any.SecondThreeAnyClass; import com.tngtech.archunit.library.testclasses.some.pkg.SomePkgClass; import com.tngtech.archunit.library.testclasses.some.pkg.sub.SomePkgSubClass; @@ -30,6 +37,8 @@ import static com.tngtech.archunit.core.domain.properties.HasName.Predicates.name; import static com.tngtech.archunit.library.Architectures.layeredArchitecture; +import static com.tngtech.archunit.library.Architectures.onionArchitecture; +import static java.beans.Introspector.decapitalize; import static java.lang.System.lineSeparator; import static java.util.regex.Pattern.quote; import static org.assertj.core.api.Assertions.assertThat; @@ -42,7 +51,7 @@ public class ArchitecturesTest { public final ExpectedException thrown = ExpectedException.none(); @Test - public void description_of_layered_architecture() { + public void layered_architecture_description() { LayeredArchitecture architecture = layeredArchitecture() .layer("One").definedBy("some.pkg..") .layer("Two").definedBy("first.any.pkg..", "second.any.pkg..") @@ -62,7 +71,7 @@ public void description_of_layered_architecture() { } @Test - public void overridden_description_of_layered_architecture() { + public void layered_architecture_overridden_description() { LayeredArchitecture architecture = layeredArchitecture() .layer("One").definedBy("some.pkg..") .whereLayer("One").mayNotBeAccessedByAnyLayer() @@ -72,7 +81,7 @@ public void overridden_description_of_layered_architecture() { } @Test - public void because_clause_on_layered_architecture() { + public void layered_architecture_because_clause() { ArchRule architecture = layeredArchitecture() .layer("One").definedBy("some.pkg..") .whereLayer("One").mayNotBeAccessedByAnyLayer() @@ -83,7 +92,7 @@ public void because_clause_on_layered_architecture() { } @Test - public void defining_constraint_on_non_existing_target_layer_is_rejected() { + public void layered_architecture_defining_constraint_on_non_existing_target_layer_is_rejected() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("no layer"); thrown.expectMessage("NotThere"); @@ -94,7 +103,7 @@ public void defining_constraint_on_non_existing_target_layer_is_rejected() { } @Test - public void defining_constraint_on_non_existing_origin_is_rejected() { + public void layered_architecture_defining_constraint_on_non_existing_origin_is_rejected() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("no layer"); thrown.expectMessage("NotThere"); @@ -105,7 +114,7 @@ public void defining_constraint_on_non_existing_origin_is_rejected() { } @Test - public void gathers_all_layer_violations() { + public void layered_architecture_gathers_all_layer_violations() { LayeredArchitecture architecture = layeredArchitecture() .layer("One").definedBy(absolute("some.pkg..")) .layer("Two").definedBy(absolute("first.any.pkg..", "second.any.pkg..")) @@ -148,7 +157,7 @@ public static Object[][] toIgnore() { @Test @UseDataProvider("toIgnore") - public void ignores_specified_violations(RuleWithIgnore layeredArchitectureWithIgnore) { + public void layered_architecture_ignores_specified_violations(RuleWithIgnore layeredArchitectureWithIgnore) { JavaClasses classes = new ClassFileImporter().importClasses( FirstAnyPkgClass.class, SomePkgSubClass.class, SecondThreeAnyClass.class, SomePkgClass.class); @@ -163,7 +172,7 @@ public void ignores_specified_violations(RuleWithIgnore layeredArchitectureWithI } @Test - public void combines_multiple_ignores() { + public void layered_architecture_combines_multiple_ignores() { JavaClasses classes = new ClassFileImporter().importClasses( FirstAnyPkgClass.class, SomePkgSubClass.class, SecondThreeAnyClass.class, SomePkgClass.class); @@ -181,6 +190,91 @@ public void combines_multiple_ignores() { assertThat(layeredArchitecture.evaluate(classes).hasViolation()).as("result has violation").isFalse(); } + @Test + public void onion_architecture_description() { + OnionArchitecture architecture = onionArchitecture() + .domainModels("onionarchitecture.domain.model..") + .domainServices("onionarchitecture.domain.service..") + .applicationServices("onionarchitecture.application..") + .adapter("cli", "onionarchitecture.adapter.cli..") + .adapter("persistence", "onionarchitecture.adapter.persistence..") + .adapter("rest", "onionarchitecture.adapter.rest.command..", "onionarchitecture.adapter.rest.query.."); + + assertThat(architecture.getDescription()).isEqualTo( + "Onion architecture consisting of" + lineSeparator() + + "domain models ('onionarchitecture.domain.model..')" + lineSeparator() + + "domain services ('onionarchitecture.domain.service..')" + lineSeparator() + + "application services ('onionarchitecture.application..')" + lineSeparator() + + "adapter 'cli' ('onionarchitecture.adapter.cli..')" + lineSeparator() + + "adapter 'persistence' ('onionarchitecture.adapter.persistence..')" + lineSeparator() + + "adapter 'rest' ('onionarchitecture.adapter.rest.command..', 'onionarchitecture.adapter.rest.query..')" + ); + } + + @Test + public void onion_architecture_description_with_missing_layers() { + OnionArchitecture architecture = onionArchitecture(); + + assertThat(architecture.getDescription()).isEqualTo("Onion architecture consisting of"); + } + + @Test + public void onion_architecture_overridden_description() { + OnionArchitecture architecture = onionArchitecture() + .domainModels("onionarchitecture.domain.model..") + .domainServices("onionarchitecture.domain.service..") + .applicationServices("onionarchitecture.application..") + .adapter("cli", "onionarchitecture.adapter.cli..") + .adapter("persistence", "onionarchitecture.adapter.persistence..") + .adapter("rest", "onionarchitecture.adapter.rest.command..", "onionarchitecture.adapter.rest.query..") + .as("overridden"); + + assertThat(architecture.getDescription()).isEqualTo("overridden"); + } + + @Test + public void onion_architecture_because_clause() { + ArchRule architecture = onionArchitecture() + .domainModels("onionarchitecture.domain.model..") + .domainServices("onionarchitecture.domain.service..") + .applicationServices("onionarchitecture.application..") + .adapter("cli", "onionarchitecture.adapter.cli..") + .adapter("persistence", "onionarchitecture.adapter.persistence..") + .adapter("rest", "onionarchitecture.adapter.rest.command..", "onionarchitecture.adapter.rest.query..") + .as("overridden") + .because("some reason"); + + assertThat(architecture.getDescription()).isEqualTo("overridden, because some reason"); + } + + @Test + public void onion_architecture_gathers_all_violations() { + OnionArchitecture architecture = onionArchitecture() + .domainModels(absolute("onionarchitecture.domain.model")) + .domainServices(absolute("onionarchitecture.domain.service")) + .applicationServices(absolute("onionarchitecture.application")) + .adapter("cli", absolute("onionarchitecture.adapter.cli")) + .adapter("persistence", absolute("onionarchitecture.adapter.persistence")) + .adapter("rest", absolute("onionarchitecture.adapter.rest")); + JavaClasses classes = new ClassFileImporter().importPackages(getClass().getPackage().getName() + ".testclasses.onionarchitecture"); + + EvaluationResult result = architecture.evaluate(classes); + + ExpectedOnionViolations expectedViolations = new ExpectedOnionViolations(); + expectedViolations.from(DomainModelLayerClass.class) + .to(DomainServiceLayerClass.class, ApplicationLayerClass.class, CliAdapterLayerClass.class, + PersistenceAdapterLayerClass.class, RestAdapterLayerClass.class); + expectedViolations.from(DomainServiceLayerClass.class) + .to(ApplicationLayerClass.class, CliAdapterLayerClass.class, PersistenceAdapterLayerClass.class, RestAdapterLayerClass.class); + expectedViolations.from(ApplicationLayerClass.class) + .to(CliAdapterLayerClass.class, PersistenceAdapterLayerClass.class, RestAdapterLayerClass.class); + expectedViolations.from(CliAdapterLayerClass.class).to(PersistenceAdapterLayerClass.class, RestAdapterLayerClass.class); + expectedViolations.from(PersistenceAdapterLayerClass.class).to(CliAdapterLayerClass.class, RestAdapterLayerClass.class); + expectedViolations.from(RestAdapterLayerClass.class).to(CliAdapterLayerClass.class, PersistenceAdapterLayerClass.class); + + assertPatternMatches(result.getFailureReport().getDetails(), expectedViolations.toPatterns()); + } + private String singleLine(EvaluationResult result) { return Joiner.on(NEW_LINE_REPLACE).join(result.getFailureReport().getDetails()).replace("\n", NEW_LINE_REPLACE); } @@ -192,6 +286,7 @@ private void assertPatternMatches(List input, Set expectedRegexe Assert.fail("Line " + line + " didn't match any pattern in " + expectedRegexes); } } + assertThat(toMatch).as("Unmatched Patterns").isEmpty(); } private boolean matchIteratorAndRemove(Set toMatch, String line) { @@ -204,12 +299,12 @@ private boolean matchIteratorAndRemove(Set toMatch, String line) { return false; } - private String expectedAccessViolationPattern(Class from, String fromMethod, Class to, String toMethod) { + private static String expectedAccessViolationPattern(Class from, String fromMethod, Class to, String toMethod) { return String.format(".*%s.%s().*%s.%s().*", quote(from.getName()), fromMethod, quote(to.getName()), toMethod); } - private String fieldTypePattern(Class owner, String fieldName, Class fieldType) { - return String.format("Field .*%s\\.%s.* has type .*%s.*", owner.getSimpleName(), fieldName, fieldType.getSimpleName()); + private static String fieldTypePattern(Class owner, String fieldName, Class fieldType) { + return String.format("Field .*%s\\.%s.* has type .*<%s>.*", owner.getSimpleName(), fieldName, fieldType.getName()); } private static String[] absolute(String... pkgSuffix) { @@ -218,7 +313,7 @@ private static String[] absolute(String... pkgSuffix) { String absolute = ArchitecturesTest.class.getPackage().getName() + ".testclasses." + s; result.add(absolute.replaceAll("\\.\\.\\.+", "..")); } - return result.toArray(new String[result.size()]); + return result.toArray(new String[0]); } private static class RuleWithIgnore { @@ -235,4 +330,56 @@ public String toString() { return description; } } -} \ No newline at end of file + + private static class ExpectedOnionViolations { + private final Set expected = new HashSet<>(); + + From from(Class from) { + return new From(from); + } + + private ExpectedOnionViolations add(ExpectedOnionViolation expectedOnionViolation) { + expected.add(expectedOnionViolation); + return this; + } + + Set toPatterns() { + ImmutableSet.Builder result = ImmutableSet.builder(); + for (ExpectedOnionViolation expectedOnionViolation : expected) { + result.addAll(expectedOnionViolation.toPatterns()); + } + return result.build(); + } + + class From { + private final Class from; + + private From(Class from) { + this.from = from; + } + + ExpectedOnionViolations to(Class... to) { + return ExpectedOnionViolations.this.add(new ExpectedOnionViolation(from, to)); + } + } + } + + private static class ExpectedOnionViolation { + private final Class from; + private final Set> tos; + + private ExpectedOnionViolation(Class from, Class[] tos) { + this.from = from; + this.tos = ImmutableSet.copyOf(tos); + } + + Set toPatterns() { + ImmutableSet.Builder result = ImmutableSet.builder(); + for (Class to : tos) { + result.add(expectedAccessViolationPattern(from, "call", to, "callMe")) + .add(fieldTypePattern(from, decapitalize(to.getSimpleName()), to)); + } + return result.build(); + } + } +} diff --git a/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/cli/CliAdapterLayerClass.java b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/cli/CliAdapterLayerClass.java new file mode 100644 index 0000000000..bae1791a10 --- /dev/null +++ b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/cli/CliAdapterLayerClass.java @@ -0,0 +1,28 @@ +package com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.cli; + +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.persistence.PersistenceAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.rest.RestAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.application.ApplicationLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.model.DomainModelLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.service.DomainServiceLayerClass; + +public class CliAdapterLayerClass { + private DomainModelLayerClass domainModelLayerClass; + private DomainServiceLayerClass domainServiceLayerClass; + private ApplicationLayerClass applicationLayerClass; + private CliAdapterLayerClass cliAdapterLayerClass; + private PersistenceAdapterLayerClass persistenceAdapterLayerClass; + private RestAdapterLayerClass restAdapterLayerClass; + + private void call() { + domainModelLayerClass.callMe(); + domainServiceLayerClass.callMe(); + applicationLayerClass.callMe(); + cliAdapterLayerClass.callMe(); + persistenceAdapterLayerClass.callMe(); + restAdapterLayerClass.callMe(); + } + + public void callMe() { + } +} diff --git a/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/persistence/PersistenceAdapterLayerClass.java b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/persistence/PersistenceAdapterLayerClass.java new file mode 100644 index 0000000000..d5189b01e5 --- /dev/null +++ b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/persistence/PersistenceAdapterLayerClass.java @@ -0,0 +1,28 @@ +package com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.persistence; + +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.cli.CliAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.rest.RestAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.application.ApplicationLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.model.DomainModelLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.service.DomainServiceLayerClass; + +public class PersistenceAdapterLayerClass { + private DomainModelLayerClass domainModelLayerClass; + private DomainServiceLayerClass domainServiceLayerClass; + private ApplicationLayerClass applicationLayerClass; + private CliAdapterLayerClass cliAdapterLayerClass; + private PersistenceAdapterLayerClass persistenceAdapterLayerClass; + private RestAdapterLayerClass restAdapterLayerClass; + + private void call() { + domainModelLayerClass.callMe(); + domainServiceLayerClass.callMe(); + applicationLayerClass.callMe(); + cliAdapterLayerClass.callMe(); + persistenceAdapterLayerClass.callMe(); + restAdapterLayerClass.callMe(); + } + + public void callMe() { + } +} diff --git a/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/rest/RestAdapterLayerClass.java b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/rest/RestAdapterLayerClass.java new file mode 100644 index 0000000000..7f42733529 --- /dev/null +++ b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/adapter/rest/RestAdapterLayerClass.java @@ -0,0 +1,28 @@ +package com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.rest; + +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.cli.CliAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.persistence.PersistenceAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.application.ApplicationLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.model.DomainModelLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.service.DomainServiceLayerClass; + +public class RestAdapterLayerClass { + private DomainModelLayerClass domainModelLayerClass; + private DomainServiceLayerClass domainServiceLayerClass; + private ApplicationLayerClass applicationLayerClass; + private CliAdapterLayerClass cliAdapterLayerClass; + private PersistenceAdapterLayerClass persistenceAdapterLayerClass; + private RestAdapterLayerClass restAdapterLayerClass; + + private void call() { + domainModelLayerClass.callMe(); + domainServiceLayerClass.callMe(); + applicationLayerClass.callMe(); + cliAdapterLayerClass.callMe(); + persistenceAdapterLayerClass.callMe(); + restAdapterLayerClass.callMe(); + } + + public void callMe() { + } +} diff --git a/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/application/ApplicationLayerClass.java b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/application/ApplicationLayerClass.java new file mode 100644 index 0000000000..a43ed49b8c --- /dev/null +++ b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/application/ApplicationLayerClass.java @@ -0,0 +1,28 @@ +package com.tngtech.archunit.library.testclasses.onionarchitecture.application; + +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.cli.CliAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.persistence.PersistenceAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.rest.RestAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.model.DomainModelLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.service.DomainServiceLayerClass; + +public class ApplicationLayerClass { + private DomainModelLayerClass domainModelLayerClass; + private DomainServiceLayerClass domainServiceLayerClass; + private ApplicationLayerClass applicationLayerClass; + private CliAdapterLayerClass cliAdapterLayerClass; + private PersistenceAdapterLayerClass persistenceAdapterLayerClass; + private RestAdapterLayerClass restAdapterLayerClass; + + private void call() { + domainModelLayerClass.callMe(); + domainServiceLayerClass.callMe(); + applicationLayerClass.callMe(); + cliAdapterLayerClass.callMe(); + persistenceAdapterLayerClass.callMe(); + restAdapterLayerClass.callMe(); + } + + public void callMe() { + } +} diff --git a/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/domain/model/DomainModelLayerClass.java b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/domain/model/DomainModelLayerClass.java new file mode 100644 index 0000000000..57e2282d58 --- /dev/null +++ b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/domain/model/DomainModelLayerClass.java @@ -0,0 +1,28 @@ +package com.tngtech.archunit.library.testclasses.onionarchitecture.domain.model; + +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.cli.CliAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.persistence.PersistenceAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.rest.RestAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.application.ApplicationLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.service.DomainServiceLayerClass; + +public class DomainModelLayerClass { + private DomainModelLayerClass domainModelLayerClass; + private DomainServiceLayerClass domainServiceLayerClass; + private ApplicationLayerClass applicationLayerClass; + private CliAdapterLayerClass cliAdapterLayerClass; + private PersistenceAdapterLayerClass persistenceAdapterLayerClass; + private RestAdapterLayerClass restAdapterLayerClass; + + private void call() { + domainModelLayerClass.callMe(); + domainServiceLayerClass.callMe(); + applicationLayerClass.callMe(); + cliAdapterLayerClass.callMe(); + persistenceAdapterLayerClass.callMe(); + restAdapterLayerClass.callMe(); + } + + public void callMe() { + } +} diff --git a/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/domain/service/DomainServiceLayerClass.java b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/domain/service/DomainServiceLayerClass.java new file mode 100644 index 0000000000..2d02d82713 --- /dev/null +++ b/archunit/src/test/java/com/tngtech/archunit/library/testclasses/onionarchitecture/domain/service/DomainServiceLayerClass.java @@ -0,0 +1,28 @@ +package com.tngtech.archunit.library.testclasses.onionarchitecture.domain.service; + +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.cli.CliAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.persistence.PersistenceAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.adapter.rest.RestAdapterLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.application.ApplicationLayerClass; +import com.tngtech.archunit.library.testclasses.onionarchitecture.domain.model.DomainModelLayerClass; + +public class DomainServiceLayerClass { + private DomainModelLayerClass domainModelLayerClass; + private DomainServiceLayerClass domainServiceLayerClass; + private ApplicationLayerClass applicationLayerClass; + private CliAdapterLayerClass cliAdapterLayerClass; + private PersistenceAdapterLayerClass persistenceAdapterLayerClass; + private RestAdapterLayerClass restAdapterLayerClass; + + private void call() { + domainModelLayerClass.callMe(); + domainServiceLayerClass.callMe(); + applicationLayerClass.callMe(); + cliAdapterLayerClass.callMe(); + persistenceAdapterLayerClass.callMe(); + restAdapterLayerClass.callMe(); + } + + public void callMe() { + } +} diff --git a/docs/docker-compose.yml b/docs/docker-compose.yml index 07d42c8bba..5026690e83 100644 --- a/docs/docker-compose.yml +++ b/docs/docker-compose.yml @@ -8,7 +8,7 @@ services: environment: - JEKYLL_ENV=development volumes: - - $PWD:/srv/jekyll - - $PWD/_config-dev.yml:/srv/jekyll/_config.yml + - ./:/srv/jekyll + - ./_config-dev.yml:/srv/jekyll/_config.yml ports: - 4000:4000 diff --git a/docs/userguide/008_The_Library_API.adoc b/docs/userguide/008_The_Library_API.adoc index b59c6fb2ea..cd4377b669 100644 --- a/docs/userguide/008_The_Library_API.adoc +++ b/docs/userguide/008_The_Library_API.adoc @@ -14,9 +14,106 @@ The entrance point for checks of common architectural styles is: com.tngtech.archunit.library.Architectures ---- -At the moment this only provides a convenient check for a layered architecture (compare -<>), but in the future it might be extended for styles like a hexagonal -architecture, pipes and filters, separation of business logic and technical infrastructure, etc. +At the moment this only provides a convenient check for a layered architecture and onion architecture. +But in the future it might be extended for styles like a pipes and filters, +separation of business logic and technical infrastructure, etc. + +==== Layered Architecture + +In layered architectures, we define different layers and how those interact with each other. +An example setup for a simple 3-tier architecture can be found in <>. + + +==== Onion Architecture + +In an "Onion Architecture" (also known as "Hexagonal Architecture" or "Ports and Adapters"), +we can define domain packages and adapter packages as follows. + +[source,java] +---- +onionArchitecture() + .domainModels("com.myapp.domain.model..") + .domainServices("com.myapp.domain.service..") + .applicationServices("com.myapp.application..") + .adapter("cli", "com.myapp.adapter.cli..") + .adapter("persistence", "com.myapp.adapter.persistence..") + .adapter("rest", "com.myapp.adapter.rest.."); +---- + +The semantic follows the descriptions in https://jeffreypalermo.com/2008/07/the-onion-architecture-part-1/. +More precisely, the following holds: + +* The `domain` package is the core of the application. It consists of two parts. + . The `domainModels` packages contain the domain entities. + . The packages in `domainServices` contains services that use the entities in the `domainModel` packages. +* The `applicationServices` packages contain services and configuration to run the application and use cases. + It can use the items of the `domain` package but there must not be any dependency from the `domain` + to the `application` packages. +* The `adapter` package contains logic to connect to external systems and/or infrastructure. + No adapter may depend on another adapter. Adapters can use both the items of the `domain` as well as + the `application` packages. Vice versa, neither the `domain` nor the `application` packages must + contain dependencies on any `adapter` package. + + +[plantuml, "onion-architecture-check"] +---- +skinparam componentStyle uml2 + +skinparam class { + BorderColor #grey + BackgroundColor #white +} + +package com.myapp.domain { + package model { + class DomainModel + } + package service { + class DomainService + interface DomainRepository + } +} +package com.myapp.application { + class ApplicationConfiguration +} +package com.myapp.adapter { + package cli { + class Cli + } + package persistence { + class NoSqlRepository + } + package rest { + class RestController + } +} + +DomainService --> DomainModel #green +DomainService -right-> DomainRepository #green + +ApplicationConfiguration ---> DomainService #green +Cli --> DomainService #green +Cli --> DomainRepository #green +NoSqlRepository --|> DomainRepository #green +NoSqlRepository --> DomainModel #green +RestController -> DomainService #green +RestController --> DomainModel #green + +DomainModel ---> DomainService #crimson +note right on link #crimson: the domain model\nmust be independent + +DomainService --> RestController #crimson +note right on link #crimson: the domain must not know\nabout any driving adapters +DomainService --> NoSqlRepository #crimson +note right on link #crimson: the domain must not know about\nspecific technical infrastructure + +ApplicationConfiguration ---> Cli +note right on link #crimson: application services must not\nknow about any adapters + +Cli --> RestController #crimson +note right on link #crimson: one adapter must not know\nabout any other adapter +---- + === Slices @@ -93,7 +190,6 @@ com.tngtech.archunit.library.GeneralCodingRules These for example contain rules not to use `java.util.logging`, not to write to `System.out` (but use logging instead) or not to throw generic exceptions. - === PlantUML Component Diagrams as rules The Library API offers a feature that supports http://plantuml.com/component-diagram[PlantUML] diagrams. @@ -282,4 +378,4 @@ or via `archunit.properties`: [source,options="nowrap"] ---- freeze.lineMatcher=fully.qualified.name.of.MyCustomLineMatcher ----- \ No newline at end of file +---- diff --git a/docs/userguide/html/000_Index.html b/docs/userguide/html/000_Index.html index 2f9fa2e6e0..59b140d069 100644 --- a/docs/userguide/html/000_Index.html +++ b/docs/userguide/html/000_Index.html @@ -513,6 +513,7 @@

ArchUnit User Guide

  • 8.2. Slices
  • 8.3. General Coding Rules
  • 8.4. PlantUML Component Diagrams as rules
  • +
  • 8.5. Freezing Arch Rules
  • 9. JUnit Support @@ -1751,9 +1752,71 @@

    8.1. Archit
    -

    At the moment this only provides a convenient check for a layered architecture (compare -What to Check), but in the future it might be extended for styles like a hexagonal -architecture, pipes and filters, separation of business logic and technical infrastructure, etc.

    +

    At the moment this only provides a convenient check for a layered architecture and onion architecture. +But in the future it might be extended for styles like a pipes and filters, +separation of business logic and technical infrastructure, etc.

    +
    +
    +

    8.1.1. Layered Architecture

    +
    +

    In layered architectures, we define different layers and how those interact with each other. +An example setup for a simple 3-tier architecture can be found in Layer Checks.

    +
    +
    +
    +

    8.1.2. Onion Architecture

    +
    +

    In an "Onion Architecture" (also known as "Hexagonal Architecture" or "Ports and Adapters"), +we can define domain packages and adapter packages as follows.

    +
    +
    +
    +
    onionArchitecture()
    +        .domainModels("com.myapp.domain.model..")
    +        .domainServices("com.myapp.domain.service..")
    +        .applicationServices("com.myapp.application..")
    +        .adapter("cli", "com.myapp.adapter.cli..")
    +        .adapter("persistence", "com.myapp.adapter.persistence..")
    +        .adapter("rest", "com.myapp.adapter.rest..");
    +
    +
    +
    +

    The semantic follows the descriptions in https://jeffreypalermo.com/2008/07/the-onion-architecture-part-1/. +More precisely, the following holds:

    +
    +
    +
      +
    • +

      The domain package is the core of the application. It consists of two parts.

      +
      +
        +
      1. +

        The domainModels packages contain the domain entities.

        +
      2. +
      3. +

        The packages in domainServices contains services that use the entities in the domainModel packages.

        +
      4. +
      +
      +
    • +
    • +

      The applicationServices packages contain services and configuration to run the application and use cases. +It can use the items of the domain package but there must not be any dependency from the domain +to the application packages.

      +
    • +
    • +

      The adapter package contains logic to connect to external systems and/or infrastructure. +No adapter may depend on another adapter. Adapters can use both the items of the domain as well as +the application packages. Vice versa, neither the domain nor the application packages must +contain dependencies on any adapter package.

      +
    • +
    +
    +
    +
    +onion architecture check +
    +
    @@ -1951,6 +2014,122 @@

    8.4.1. Co

    +
    +

    8.5. Freezing Arch Rules

    +
    +

    When rules are introduced in grown projects, there are often hundreds or even thousands of violations, +way too many to fix immediately. The only way to tackle such extensive violations is to establish an +iterative approach, which prevents the code base from further deterioration.

    +
    +
    +

    FreezingArchRule can help in these scenarios by recording all existing violations to a ViolationStore. +Consecutive runs will then only report new violations and ignore known violations. +If violations are fixed, FreezingArchRule will automatically reduce the known stored violations to prevent any regression.

    +
    +
    +

    8.5.1. Usage

    +
    +

    To freeze an arbitrary ArchRule just wrap it into a FreezingArchRule:

    +
    +
    +
    +
    ArchRule rule = FreezingArchRule.freeze(classes().should()./*complete ArchRule*/);
    +
    +
    +
    +

    On the first run all violations of that rule will be stored as the current state. On consecutive runs only +new violations will be reported. By default FreezingArchRule will ignore line numbers, i.e. if a +violation is just shifted to a different line, it will still count as previously recorded +and will not be reported.

    +
    +
    +
    +

    8.5.2. Configuration

    +
    +

    By default FreezingArchRule will use a simple ViolationStore based on plain text files. +This is sufficient to add these files to any version control system to continuously track the progress. +You can configure the location of the violation store within archunit.properties (compare Advanced Configuration):

    +
    +
    +
    archunit.properties
    +
    +
    freeze.store.default.path=/some/path/in/a/vcs/repo
    +
    +
    +
    +
    +

    8.5.3. Extension

    +
    +

    FreezingArchRule provides two extension points to adjust the behavior to custom needs. +The first one is the ViolationStore, i.e. the store violations will be recorded to. The second one +is the ViolationLineMatcher, i.e. how FreezingArchRule will associate lines of stored violations +with lines of actual violations. As mentioned, by default this is a line matcher that ignores the +line numbers of violations within the same class.

    +
    +
    +
    Violation Store
    +
    +

    As mentioned in Configuration, the default ViolationStore is a simple text based store. +It can be exchanged though, for example to store violations in a database. +To provide your own implementation, implement com.tngtech.archunit.library.freeze.ViolationStore and +configure FreezingArchRule to use it. This can either be done programmatically:

    +
    +
    +
    +
    FreezingArchRule.freeze(rule).persistIn(customViolationStore);
    +
    +
    +
    +

    Alternatively it can be configured via archunit.properties (compare Advanced Configuration):

    +
    +
    +
    +
    freeze.store=fully.qualified.name.of.MyCustomViolationStore
    +
    +
    +
    +

    You can supply properties to initialize the store by using the namespace freeze.store. +For properties

    +
    +
    +
    +
    freeze.store.propOne=valueOne
    +freeze.store.propTwo=valueTwo
    +
    +
    +
    +

    the method ViolationStore.initialize(props) will be called with the properties

    +
    +
    +
    +
    propOne=valueOne
    +propTwo=valueTwo
    +
    +
    +
    +
    +
    Violation Line Matcher
    +
    +

    The ViolationLineMatcher compares lines from occurred violations with lines from the store. +The default implementation ignores line numbers and counts lines as equivalent when all other details match. +A custom ViolationLineMatcher can again either be defined programmatically:

    +
    +
    +
    +
    FreezingArchRule.freeze(rule).associateViolationLinesVia(customLineMatcher);
    +
    +
    +
    +

    or via archunit.properties:

    +
    +
    +
    +
    freeze.lineMatcher=fully.qualified.name.of.MyCustomLineMatcher
    +
    +
    +
    +
    +
    diff --git a/docs/userguide/html/onion-architecture-check.png b/docs/userguide/html/onion-architecture-check.png new file mode 100644 index 0000000000..f255db5189 Binary files /dev/null and b/docs/userguide/html/onion-architecture-check.png differ