Java Code Examples for com.tngtech.archunit.core.domain.JavaClass#getDirectDependenciesFromSelf()
The following examples show how to use
com.tngtech.archunit.core.domain.JavaClass#getDirectDependenciesFromSelf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DependencyRules.java From ArchUnit with Apache License 2.0 | 5 votes |
@Override public void check(final JavaClass clazz, final ConditionEvents events) { for (Dependency dependency : clazz.getDirectDependenciesFromSelf()) { boolean dependencyOnUpperPackage = isDependencyOnUpperPackage(dependency.getOriginClass(), dependency.getTargetClass()); events.add(new SimpleConditionEvent(dependency, dependencyOnUpperPackage, dependency.getDescription())); } }
Example 2
Source File: Slice.java From ArchUnit with Apache License 2.0 | 5 votes |
/** * @return All dependencies that originate from a class within this {@link Slice} and target a class outside of this {@link Slice} */ @PublicAPI(usage = ACCESS) public Set<Dependency> getDependenciesFromSelf() { ImmutableSet.Builder<Dependency> result = ImmutableSet.builder(); for (JavaClass javaClass : this) { for (Dependency dependency : javaClass.getDirectDependenciesFromSelf()) { if (isNotAssignedToOwnSlice(dependency.getTargetClass())) { result.add(dependency); } } } return result.build(); }
Example 3
Source File: ClassFileImporterTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void getDirectDependencies_does_not_return_transitive_dependencies() throws Exception { ImportedClasses classes = classesIn("testexamples/integration"); JavaClass javaClass = classes.get(ClassCDependingOnClassB_SuperClassOfX.class); JavaClass expectedTargetClass = classes.get(ClassBDependingOnClassA.class); Set<JavaClass> targetClasses = new HashSet<>(); for (Dependency dependency : javaClass.getDirectDependenciesFromSelf()) { if (dependency.getTargetClass().getPackageName().contains("testexamples")) { targetClasses.add(dependency.getTargetClass()); } } assertThat(targetClasses).containsOnly(expectedTargetClass); }