@Test public void createCyclicDependencies() { Component a = Component.of("a", "a"); Component b = Component.of("b", "b"); ComponentRelationships aRels = ComponentRelationships.builder().component(a).addDependency(Dependency.on(b)) .addDependency(Dependency.on(a)).build(); ComponentRelationships bRels = ComponentRelationships.builder().component(b).addDependency(Dependency.on(a)) .build(); LinkedHashSet<ComponentRelationships> set = new LinkedHashSet<>(); set.add(aRels); set.add(bRels); System system = System.of("sys", set); DependencyWheel result = DependencyWheel.of(system); DependencyWheel expected = DependencyWheel.builder() .name("a") .matrixLine(Arrays.asList(1, 1)) .name("b") .matrixLine(Arrays.asList(1, 0)) .build(); Assertions.assertThat(result).isEqualTo(expected); }
public static DependencyWheel of(System system) { final DependencyWheelBuilder builder = DependencyWheel.builder(); List<ComponentRelationships> rels = new ArrayList<>(system.getComponentRelationships()); rels.sort((c1, c2) -> c1.getComponent().asString().compareToIgnoreCase(c2.getComponent().asString())); for (ComponentRelationships rel : rels) { List<Integer> line = new ArrayList<>(); for (ComponentRelationships potentialDependency : rels) { line.add(rel.getDependencies().contains(Dependency.on(potentialDependency.getComponent())) ? 1 : 0); } builder.name(rel.getComponent().getName().toLowerCase()).matrixLine(line); } return builder.build(); }
DependencyWheel { public static DependencyWheel of(System system) { final DependencyWheelBuilder builder = DependencyWheel.builder(); List<ComponentRelationships> rels = new ArrayList<>(system.getComponentRelationships()); rels.sort((c1, c2) -> c1.getComponent().asString().compareToIgnoreCase(c2.getComponent().asString())); for (ComponentRelationships rel : rels) { List<Integer> line = new ArrayList<>(); for (ComponentRelationships potentialDependency : rels) { line.add(rel.getDependencies().contains(Dependency.on(potentialDependency.getComponent())) ? 1 : 0); } builder.name(rel.getComponent().getName().toLowerCase()).matrixLine(line); } return builder.build(); } }
DependencyWheel { public static DependencyWheel of(System system) { final DependencyWheelBuilder builder = DependencyWheel.builder(); List<ComponentRelationships> rels = new ArrayList<>(system.getComponentRelationships()); rels.sort((c1, c2) -> c1.getComponent().asString().compareToIgnoreCase(c2.getComponent().asString())); for (ComponentRelationships rel : rels) { List<Integer> line = new ArrayList<>(); for (ComponentRelationships potentialDependency : rels) { line.add(rel.getDependencies().contains(Dependency.on(potentialDependency.getComponent())) ? 1 : 0); } builder.name(rel.getComponent().getName().toLowerCase()).matrixLine(line); } return builder.build(); }  }
DependencyWheel { public static DependencyWheel of(System system) { final DependencyWheelBuilder builder = DependencyWheel.builder(); List<ComponentRelationships> rels = new ArrayList<>(system.getComponentRelationships()); rels.sort((c1, c2) -> c1.getComponent().asString().compareToIgnoreCase(c2.getComponent().asString())); for (ComponentRelationships rel : rels) { List<Integer> line = new ArrayList<>(); for (ComponentRelationships potentialDependency : rels) { line.add(rel.getDependencies().contains(Dependency.on(potentialDependency.getComponent())) ? 1 : 0); } builder.name(rel.getComponent().getName().toLowerCase()).matrixLine(line); } return builder.build(); }  static DependencyWheel of(System system); }
DependencyWheel { public static DependencyWheel of(System system) { final DependencyWheelBuilder builder = DependencyWheel.builder(); List<ComponentRelationships> rels = new ArrayList<>(system.getComponentRelationships()); rels.sort((c1, c2) -> c1.getComponent().asString().compareToIgnoreCase(c2.getComponent().asString())); for (ComponentRelationships rel : rels) { List<Integer> line = new ArrayList<>(); for (ComponentRelationships potentialDependency : rels) { line.add(rel.getDependencies().contains(Dependency.on(potentialDependency.getComponent())) ? 1 : 0); } builder.name(rel.getComponent().getName().toLowerCase()).matrixLine(line); } return builder.build(); }  static DependencyWheel of(System system);  }