@Test public void top_level() { String levelName = ""; Level level = transform(codemap, levelName); log.info("produced level '{}':\n{}", levelName, level.formatted()); Component animal = new Component("animal"); Component ghost = new Component("ghost"); Component plant = new Component("plant"); assertThat(level.name).isEqualTo(levelName); assertThat(level.components).containsExactly(animal, ghost, plant); assertThat(level.dependencies).containsExactly( new ComponentDep(animal, plant), new ComponentDep(plant, animal) ); assertThat(level.dependency(animal, plant).strength).isEqualTo(2); assertThat(level.dependency(plant, animal).strength).isEqualTo(1); assertThat(level.component("animal").size).isGreaterThan(level.component("plant").size); }
public static Level transform(Codemap codemap, String levelName) { Level level = new Level(levelName); for (CodePackage packet : codemap.packages()) { Component component = componentFor(packet, level); if (component == null) continue; component.incrementSizeBy(packet.size()); } for (PackageDep packageDep : codemap.packageDeps()) { Component fromComponent = componentFor(packageDep.from, level); if (fromComponent == null) continue; Component toComponent = componentFor(packageDep.to, level); if (toComponent == null) continue; if (fromComponent == toComponent) continue; ComponentDep componentDep = level.dependency(fromComponent, toComponent); componentDep.incrementStrengthBy(packageDep.strength()); } return level; }
CodemapToLevel { public static Level transform(Codemap codemap, String levelName) { Level level = new Level(levelName); for (CodePackage packet : codemap.packages()) { Component component = componentFor(packet, level); if (component == null) continue; component.incrementSizeBy(packet.size()); } for (PackageDep packageDep : codemap.packageDeps()) { Component fromComponent = componentFor(packageDep.from, level); if (fromComponent == null) continue; Component toComponent = componentFor(packageDep.to, level); if (toComponent == null) continue; if (fromComponent == toComponent) continue; ComponentDep componentDep = level.dependency(fromComponent, toComponent); componentDep.incrementStrengthBy(packageDep.strength()); } return level; } }
CodemapToLevel { public static Level transform(Codemap codemap, String levelName) { Level level = new Level(levelName); for (CodePackage packet : codemap.packages()) { Component component = componentFor(packet, level); if (component == null) continue; component.incrementSizeBy(packet.size()); } for (PackageDep packageDep : codemap.packageDeps()) { Component fromComponent = componentFor(packageDep.from, level); if (fromComponent == null) continue; Component toComponent = componentFor(packageDep.to, level); if (toComponent == null) continue; if (fromComponent == toComponent) continue; ComponentDep componentDep = level.dependency(fromComponent, toComponent); componentDep.incrementStrengthBy(packageDep.strength()); } return level; }  }
CodemapToLevel { public static Level transform(Codemap codemap, String levelName) { Level level = new Level(levelName); for (CodePackage packet : codemap.packages()) { Component component = componentFor(packet, level); if (component == null) continue; component.incrementSizeBy(packet.size()); } for (PackageDep packageDep : codemap.packageDeps()) { Component fromComponent = componentFor(packageDep.from, level); if (fromComponent == null) continue; Component toComponent = componentFor(packageDep.to, level); if (toComponent == null) continue; if (fromComponent == toComponent) continue; ComponentDep componentDep = level.dependency(fromComponent, toComponent); componentDep.incrementStrengthBy(packageDep.strength()); } return level; }  static Level transform(Codemap codemap, String levelName); }
CodemapToLevel { public static Level transform(Codemap codemap, String levelName) { Level level = new Level(levelName); for (CodePackage packet : codemap.packages()) { Component component = componentFor(packet, level); if (component == null) continue; component.incrementSizeBy(packet.size()); } for (PackageDep packageDep : codemap.packageDeps()) { Component fromComponent = componentFor(packageDep.from, level); if (fromComponent == null) continue; Component toComponent = componentFor(packageDep.to, level); if (toComponent == null) continue; if (fromComponent == toComponent) continue; ComponentDep componentDep = level.dependency(fromComponent, toComponent); componentDep.incrementStrengthBy(packageDep.strength()); } return level; }  static Level transform(Codemap codemap, String levelName);  }