Skip to content

Commit

Permalink
test: re-upgrade archunit
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Apr 4, 2023
1 parent 5b50a54 commit 1e0c130
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
4 changes: 2 additions & 2 deletions cola-samples/charge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<springfox.version>3.0.0</springfox.version>
<archunit.version>0.21.0</archunit.version>
<archunit.version>1.0.1</archunit.version>
<spring.boot.version>2.3.8.RELEASE</spring.boot.version>
</properties>

Expand Down Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit</artifactId>
<version>0.23.1</version>
<version>${archunit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package com.huawei.charging;

import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import org.junit.Test;

import static com.tngtech.archunit.library.Architectures.layeredArchitecture;

public class CleanArchTest {
@Test
public void protect_clean_arch() {
JavaClasses classes = new ClassFileImporter()
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
.importPackages("com.huawei.charging");

layeredArchitecture()
.layer("adapter").definedBy("com.huawei.charging.adapter")
.layer("application").definedBy("com.huawei.charging.application")
.layer("domain").definedBy("com.huawei.charging.domain")
.layer("infrastructure").definedBy("com.huawei.charging.infrastructure")
.whereLayer("adapter").mayNotBeAccessedByAnyLayer()
//.whereLayer("domain").mayOnlyBeAccessedByLayers("application", "infrastructure")
.as("The layer dependencies must be respected")
.because("we must follow the Clean Architecture principle")
.check(classes);
}
}
package com.huawei.charging;

import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import org.junit.Test;

import static com.tngtech.archunit.library.Architectures.layeredArchitecture;

public class CleanArchTest {
@Test
public void protect_clean_arch() {
JavaClasses classes = new ClassFileImporter()
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
.importPackages("com.huawei.charging");

layeredArchitecture()
.consideringAllDependencies()
.layer("adapter").definedBy("com.huawei.charging.adapter")
.layer("application").definedBy("com.huawei.charging.application")
.layer("domain").definedBy("com.huawei.charging.domain")
.layer("infrastructure").definedBy("com.huawei.charging.infrastructure")
.whereLayer("adapter").mayNotBeAccessedByAnyLayer()
//.whereLayer("domain").mayOnlyBeAccessedByLayers("application", "infrastructure")
.as("The layer dependencies must be respected")
.because("we must follow the Clean Architecture principle")
.check(classes);
}
}

0 comments on commit 1e0c130

Please sign in to comment.