AllExplicitRulesUsedChecker extends Checker { @Override public String getViolationMessage() { return getViolationMessages().isEmpty() ? null : (getViolationMessages().size() + " unused rules: " + getViolationMessages()); } AllExplicitRulesUsedChecker(DependencyGraph dependencyGraph, Architecture architecture); @Override String getViolationMessage();  }
@Test public void testWithImplementedUsesRelation() { init(false, false); Component component = packageArchitecture.getParentComponent("com.my.a.b"); assertThat(component, notNullValue()); component.getUsesAPI().put("newRule", new ClassSet("newRule", Lists.newArrayList("com.my.a.e"))); new DependencyChecker(architectureGraph, packageArchitecture); AllExplicitRulesUsedChecker checker = new AllExplicitRulesUsedChecker(architectureGraph, packageArchitecture); assertThat(checker.isOk(), is(true)); assertThat(checker.getViolationMessage(), nullValue()); }
@Test public void testNotOk() { init(false, false); @SuppressWarnings("unchecked") List<String> uses = (List<String>) architectureGraph.getNode("com.my.a").getProperty(Constants.USES_API); uses.add("com.my.other"); new DependencyChecker(architectureGraph, packageArchitecture); AllExplicitRulesUsedChecker checker = new AllExplicitRulesUsedChecker(architectureGraph, packageArchitecture); assertThat(checker.isOk(), is(false)); assertThat(checker.getViolationMessage(), is("1 unused rules: [com.my.a: com.my.other]")); }