forked from Infosys/Discourse-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArchTest.java
More file actions
36 lines (29 loc) · 1.15 KB
/
ArchTest.java
File metadata and controls
36 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Copyright 2021 Infosys Ltd.
* Use of this source code is governed by GNU General Public License version 2
* that can be found in the LICENSE file or at
* https://opensource.org/licenses/GPL-2.0
*/
package com.infy;
import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import org.junit.jupiter.api.Test;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
class ArchTest {
@Test
void servicesAndRepositoriesShouldNotDependOnWebLayer() {
JavaClasses importedClasses = new ClassFileImporter()
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
.importPackages("com.infy");
noClasses()
.that()
.resideInAnyPackage("com.infy.service..")
.or()
.resideInAnyPackage("com.infy.repository..")
.should().dependOnClassesThat()
.resideInAnyPackage("..com.infy.web..")
.because("Services and repositories should not depend on web layer")
.check(importedClasses);
}
}