diff --git a/kshop/build.gradle b/kshop/build.gradle index 276bfd4..ed92484 100644 --- a/kshop/build.gradle +++ b/kshop/build.gradle @@ -30,6 +30,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' // testImplementation 'org.springframework.security:spring-security-test' + testImplementation 'com.tngtech.archunit:archunit-junit5:1.2.1' } tasks.named('test') { diff --git a/kshop/src/main/java/com/kampus/kshop/health/HealthController.java b/kshop/src/main/java/com/kampus/kshop/controller/HealthController.java similarity index 90% rename from kshop/src/main/java/com/kampus/kshop/health/HealthController.java rename to kshop/src/main/java/com/kampus/kshop/controller/HealthController.java index 6787315..cf096b7 100644 --- a/kshop/src/main/java/com/kampus/kshop/health/HealthController.java +++ b/kshop/src/main/java/com/kampus/kshop/controller/HealthController.java @@ -1,4 +1,4 @@ -package com.kampus.kshop.health; +package com.kampus.kshop.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/kshop/src/main/java/com/kampus/kshop/repository/ChangeMeRepository.java b/kshop/src/main/java/com/kampus/kshop/repository/ChangeMeRepository.java new file mode 100644 index 0000000..7d7a99c --- /dev/null +++ b/kshop/src/main/java/com/kampus/kshop/repository/ChangeMeRepository.java @@ -0,0 +1,7 @@ +package com.kampus.kshop.repository; + +import org.springframework.stereotype.Repository; + +@Repository +public class ChangeMeRepository { +} diff --git a/kshop/src/main/java/com/kampus/kshop/service/ChangeMeService.java b/kshop/src/main/java/com/kampus/kshop/service/ChangeMeService.java new file mode 100644 index 0000000..9dfbfdd --- /dev/null +++ b/kshop/src/main/java/com/kampus/kshop/service/ChangeMeService.java @@ -0,0 +1,7 @@ +package com.kampus.kshop.service; + +import org.springframework.stereotype.Service; + +@Service +public class ChangeMeService { +} diff --git a/kshop/src/test/java/com/kampus/kshop/architecture/LayeredTest.java b/kshop/src/test/java/com/kampus/kshop/architecture/LayeredTest.java new file mode 100644 index 0000000..134c5b5 --- /dev/null +++ b/kshop/src/test/java/com/kampus/kshop/architecture/LayeredTest.java @@ -0,0 +1,24 @@ +package com.kampus.kshop.architecture; + +import com.tngtech.archunit.core.importer.ImportOption; +import com.tngtech.archunit.junit.AnalyzeClasses; +import com.tngtech.archunit.junit.ArchTest; +import com.tngtech.archunit.lang.ArchRule; + +import static com.tngtech.archunit.library.Architectures.layeredArchitecture; + +@AnalyzeClasses(packages = "com.kampus.kshop", importOptions = ImportOption.DoNotIncludeTests.class) +public class LayeredTest { + + @ArchTest + static final ArchRule layeredArchitecture = + layeredArchitecture() + .consideringAllDependencies() + .layer("Controller").definedBy("..controller..") + .layer("Service").definedBy("..service..") + .layer("Repository").definedBy("..repository..") + .whereLayer("Controller").mayNotBeAccessedByAnyLayer() + .whereLayer("Service").mayOnlyBeAccessedByLayers("Controller") + .whereLayer("Repository").mayOnlyBeAccessedByLayers("Service"); + +} \ No newline at end of file