diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Cycle.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Cycle.java new file mode 100644 index 0000000..6539976 --- /dev/null +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Cycle.java @@ -0,0 +1,48 @@ +/** + * Copyright 2019 The ModiTect authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.moditect.deptective.internal.graph; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * A cycle between multiple nodes. + * + * @author Gunnar Morling + * @param the specific node type + */ +public class Cycle> { + + private static final String STRING_DELIMITER = ", "; + private final List nodes; + + public Cycle(List nodes) { + this.nodes = Collections.unmodifiableList(nodes); + } + + public List getNodes() { + return nodes; + } + + @Override + public String toString() { + return nodes.stream() + .map(Node::asShortString) + .sorted() + .collect(Collectors.joining(STRING_DELIMITER)); + } +} diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Dependency.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Dependency.java index 1316f59..4e933d1 100644 --- a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Dependency.java +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Dependency.java @@ -18,17 +18,17 @@ /** * @author Gerd Wütherich (gw@code-kontor.io) */ -public class Dependency { +public class Dependency> { - private final Node to; + private final T to; private final int aggregatedWeight; - public Dependency(Node to, int aggregatedWeight) { + public Dependency(T to, int aggregatedWeight) { this.to = to; this.aggregatedWeight = aggregatedWeight; } - public Node getTo() { + public T getTo() { return to; } diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/GraphUtils.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/GraphUtils.java index 4135cbf..e12da2e 100644 --- a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/GraphUtils.java +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/GraphUtils.java @@ -15,7 +15,6 @@ */ package org.moditect.deptective.internal.graph; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -42,8 +41,8 @@ public class GraphUtils { * contain just a single node. If you want to detect 'real' cycle (size > 1) please use * {@link GraphUtils#detectCycles(Collection)}. */ - public static List> detectStronglyConnectedComponents(Collection nodes) { - return new Tarjan<>().detectStronglyConnectedComponents(Objects.requireNonNull(nodes)); + public static > List> detectStronglyConnectedComponents(Collection nodes) { + return new Tarjan().detectStronglyConnectedComponents(Objects.requireNonNull(nodes)); } /** @@ -52,8 +51,11 @@ public static List> detectStronglyConnectedComponents(Collection 1. */ - public static List> detectCycles(Collection nodes) { - return new Tarjan<>().detectStronglyConnectedComponents(nodes).stream().filter(cycle -> cycle.size() > 1) + public static > List> detectCycles(Iterable nodes) { + return new Tarjan().detectStronglyConnectedComponents(nodes) + .stream() + .filter(cycle -> cycle.size() > 1) + .map(Cycle::new) .collect(Collectors.toList()); } @@ -63,9 +65,9 @@ public static List> detectCycles(Collection nodes) { * @param nodes the collection of nodes * @return */ - public static IDependencyStructureMatrix createDependencyStructureMatrix( - Collection nodes) { - return new DependencyStructureMatrix(nodes); + public static > IDependencyStructureMatrix createDependencyStructureMatrix( + Collection nodes) { + return new DependencyStructureMatrix(nodes); } /** @@ -75,23 +77,12 @@ public static IDependencyStructureMatrix createDependencyStructureMatrix( * @param nodes the collection of nodes * @return the adjacency matrix for the given list of nodes */ - public static int[][] computeAdjacencyMatrix(List nodes) { + public static > int[][] computeAdjacencyMatrix(List nodes) { Objects.requireNonNull(nodes); - return computeAdjacencyMatrix(nodes.toArray(new Node[nodes.size()])); - } - - /** - * An adjacency matrix is a square matrix used to represent a finite graph. The elements of the matrix - * indicate whether pairs of vertices are connected (adjacent) or not in the graph. - * - * @param nodes the array of nodes - * @return the adjacency matrix for the given list of nodes - */ - public static int[][] computeAdjacencyMatrix(Node... nodes) { - int[][] result = new int[nodes.length][nodes.length]; + int[][] result = new int[nodes.size()][nodes.size()]; for (int i = 0; i < result.length; i++) { for (int j = 0; j < result.length; j++) { - Dependency dependency = nodes[i].getOutgoingDependencyTo(nodes[j]); + Dependency dependency = nodes.get(i).getOutgoingDependencyTo(nodes.get(j)); result[i][j] = dependency != null ? dependency.getAggregatedWeight() : 0; } } @@ -105,40 +96,28 @@ public static int[][] computeAdjacencyMatrix(Node... nodes) { * @param nodes the array of nodes * @return the adjacency list for the given list of nodes */ - public static int[][] computeAdjacencyList(Collection nodes) { - Objects.requireNonNull(nodes); - return computeAdjacencyList(nodes.toArray(new Node[nodes.size()])); - } - - /** - * An adjacency list is a collection of (unordered) lists used to represent a finite graph. Each list - * describes the set of neighbors of a node. - * - * @param nodes the array of nodes - * @return the adjacency list for the given list of nodes - */ - public static int[][] computeAdjacencyList(Node... nodes) { + public static > int[][] computeAdjacencyList(Iterable nodes) { int[][] matrix; // prepare int i = 0; - Map map = new HashMap(); - for (Node iArtifact : nodes) { + Map map = new HashMap(); + for (T iArtifact : nodes) { map.put(iArtifact, i); i++; } - matrix = new int[nodes.length][]; + matrix = new int[map.size()][]; - for (Node node : nodes) { - Collection dependencies = node.getOutgoingDependenciesTo(Arrays.asList(nodes)); + for (T node : nodes) { + Collection> dependencies = node.getOutgoingDependenciesTo(nodes); if (dependencies == null) { dependencies = Collections.emptyList(); } int index = map.get(node); matrix[index] = new int[dependencies.size()]; int count = 0; - for (Dependency dependency : dependencies) { + for (Dependency dependency : dependencies) { matrix[index][count] = map.get(dependency.getTo()); count++; } diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/IDependencyStructureMatrix.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/IDependencyStructureMatrix.java index a5f2374..2176b94 100644 --- a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/IDependencyStructureMatrix.java +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/IDependencyStructureMatrix.java @@ -20,13 +20,13 @@ /** * @author Gerd Wütherich (gw@code-kontor.io) */ -public interface IDependencyStructureMatrix { +public interface IDependencyStructureMatrix> { - List getOrderedNodes(); + List getOrderedNodes(); - List getUpwardDependencies(); + List> getUpwardDependencies(); - List> getCycles(); + List> getCycles(); boolean isCellInCycle(int i, int j); diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/INodeSorter.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/INodeSorter.java index 42b8fbd..e6c0421 100644 --- a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/INodeSorter.java +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/INodeSorter.java @@ -22,12 +22,12 @@ */ public interface INodeSorter { - SortResult sort(List node); + > SortResult sort(List node); - public interface SortResult { + public interface SortResult> { - List getOrderedNodes(); + List getOrderedNodes(); - List getUpwardsDependencies(); + List> getUpwardsDependencies(); } } diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Node.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Node.java index ac0b766..581737d 100644 --- a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Node.java +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/Node.java @@ -15,87 +15,35 @@ */ package org.moditect.deptective.internal.graph; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.StreamSupport; /** + * A node in a graph. + * * @author Gerd Wütherich (gw@code-kontor.io) + * @author Gunnar Morling + * @param A specific sub-type, following the self-referential generic type pattern */ -public class Node { - - private Map outgoingDependencies; - private final String id; - - public Node(String id) { - this.id = Objects.requireNonNull(id); - } - - public String getId() { - return id; - } - - public Dependency getOutgoingDependencyTo(Node node) { - if (!hasOutgoingDependencies()) { - return null; - } - - return outgoingDependencies.get(node); - } +public interface Node> { - public Set getOutgoingDependenciesTo(Collection nodes) { - return Objects.requireNonNull(nodes).stream() - .map(node -> getOutgoingDependencyTo(node)) - .filter(dep -> dep != null) + default Set> getOutgoingDependenciesTo(Iterable nodes) { + return StreamSupport.stream(nodes.spliterator(), false) + .map(c -> getOutgoingDependencyTo(c)) + .filter(Objects::nonNull) .collect(Collectors.toSet()); } - public boolean hasOutgoingDependencies() { - return outgoingDependencies != null && !outgoingDependencies.isEmpty(); - } - - public void addOutgoingDependency(Node to, int aggregatedWeight) { - outgoingDependencies().put(to, new Dependency(to, aggregatedWeight)); - } - - @Override - public String toString() { - return "Node [id=" + id + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } + Dependency getOutgoingDependencyTo(T node); - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Node other = (Node) obj; - if (id == null) { - if (other.id != null) - return false; - } - else if (!id.equals(other.id)) - return false; - return true; - } + boolean hasOutgoingDependencies(); - private Map outgoingDependencies() { - if (outgoingDependencies == null) { - outgoingDependencies = new HashMap<>(); - } - return outgoingDependencies; + /** + * Returns a concise string representation of this node, e.g. used when rendering this node in a diagram. + */ + default String asShortString() { + return toString(); } } diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/SimpleNode.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/SimpleNode.java new file mode 100644 index 0000000..abf211e --- /dev/null +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/SimpleNode.java @@ -0,0 +1,93 @@ +/** + * Copyright 2019 The ModiTect authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.moditect.deptective.internal.graph; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @author Gerd Wütherich (gw@code-kontor.io) + */ +public class SimpleNode implements Node { + + private Map> outgoingDependencies; + private final String id; + + public SimpleNode(String id) { + this.id = Objects.requireNonNull(id); + } + + public String getId() { + return id; + } + + @Override + public Dependency getOutgoingDependencyTo(SimpleNode node) { + if (!hasOutgoingDependencies()) { + return null; + } + + return outgoingDependencies.get(node); + } + + @Override + public boolean hasOutgoingDependencies() { + return outgoingDependencies != null && !outgoingDependencies.isEmpty(); + } + + public void addOutgoingDependency(SimpleNode to, int aggregatedWeight) { + outgoingDependencies().put(to, new Dependency<>(to, aggregatedWeight)); + } + + @Override + public String toString() { + return "SimpleNode [id=" + id + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SimpleNode other = (SimpleNode) obj; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + return true; + } + + private Map> outgoingDependencies() { + if (outgoingDependencies == null) { + outgoingDependencies = new HashMap<>(); + } + return outgoingDependencies; + } +} diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/DependencyStructureMatrix.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/DependencyStructureMatrix.java index 9b0cdc1..0a6af35 100644 --- a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/DependencyStructureMatrix.java +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/DependencyStructureMatrix.java @@ -29,20 +29,20 @@ import org.moditect.deptective.internal.graph.INodeSorter.SortResult; import org.moditect.deptective.internal.graph.Node; -public class DependencyStructureMatrix implements IDependencyStructureMatrix { +public class DependencyStructureMatrix> implements IDependencyStructureMatrix { - private List> cycles; + private List> cycles; - private List nodes; + private List nodes; - private List upwardDependencies; + private List> upwardDependencies; - public DependencyStructureMatrix(Collection nodes) { + public DependencyStructureMatrix(Collection nodes) { initialize(nodes); } @Override - public List getUpwardDependencies() { + public List> getUpwardDependencies() { return upwardDependencies; } @@ -53,13 +53,13 @@ public int getWeight(int i, int j) { return -1; } - Dependency dependency = nodes.get(i).getOutgoingDependencyTo(nodes.get(j)); + Dependency dependency = nodes.get(i).getOutgoingDependencyTo(nodes.get(j)); return dependency != null ? dependency.getAggregatedWeight() : 0; } @Override - public List getOrderedNodes() { + public List getOrderedNodes() { return nodes; } @@ -75,7 +75,7 @@ public boolean isCellInCycle(int i, int j) { return false; } - for (List cycle : cycles) { + for (List cycle : cycles) { if (cycle.size() > 1 && cycle.contains(nodes.get(i)) && cycle.contains(nodes.get(j))) { return true; } @@ -85,35 +85,35 @@ public boolean isCellInCycle(int i, int j) { } @Override - public List> getCycles() { + public List> getCycles() { return cycles; } - private void initialize(Collection unorderedArtifacts) { + private void initialize(Collection unorderedArtifacts) { Objects.requireNonNull(unorderedArtifacts); upwardDependencies = new ArrayList<>(); - List> c = GraphUtils.detectStronglyConnectedComponents(unorderedArtifacts); + List> c = GraphUtils.detectStronglyConnectedComponents(unorderedArtifacts); INodeSorter artifactSorter = new FastFasSorter(); - for (List cycle : c) { - SortResult sortResult = artifactSorter.sort(cycle); + for (List cycle : c) { + SortResult sortResult = artifactSorter.sort(cycle); cycle.clear(); cycle.addAll(sortResult.getOrderedNodes()); upwardDependencies.addAll(sortResult.getUpwardsDependencies()); } - List orderedArtifacts = new ArrayList<>(); + List orderedArtifacts = new ArrayList<>(); // optimize: un-cycled artifacts without dependencies first - for (List artifactList : c) { + for (List artifactList : c) { if (artifactList.size() == 1 && !artifactList.get(0).hasOutgoingDependencies()) { orderedArtifacts.add(artifactList.get(0)); } } - for (List cycle : c) { - for (Node node : cycle) { + for (List cycle : c) { + for (T node : cycle) { if (!orderedArtifacts.contains(node)) { orderedArtifacts.add(node); } diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/FastFasSorter.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/FastFasSorter.java index 8ad60d7..476b2f9 100644 --- a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/FastFasSorter.java +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/FastFasSorter.java @@ -18,16 +18,16 @@ import java.util.ArrayList; import java.util.List; -import org.moditect.deptective.internal.graph.GraphUtils; import org.moditect.deptective.internal.graph.Dependency; -import org.moditect.deptective.internal.graph.Node; +import org.moditect.deptective.internal.graph.GraphUtils; import org.moditect.deptective.internal.graph.INodeSorter; +import org.moditect.deptective.internal.graph.Node; public class FastFasSorter implements INodeSorter { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public SortResult sort(List artifacts) { + public > SortResult sort(List artifacts) { // we have to compute the adjacency matrix first int[][] adjacencyMatrix = GraphUtils.computeAdjacencyMatrix(artifacts); diff --git a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/Tarjan.java b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/Tarjan.java index 7d0c8fb..1a128e9 100644 --- a/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/Tarjan.java +++ b/javac-plugin/src/main/java/org/moditect/deptective/internal/graph/impl/Tarjan.java @@ -16,14 +16,13 @@ package org.moditect.deptective.internal.graph.impl; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Objects; import org.moditect.deptective.internal.graph.GraphUtils; import org.moditect.deptective.internal.graph.Node; -public class Tarjan { +public class Tarjan> { private int _index = 0; private final ArrayList _stack = new ArrayList(); @@ -31,16 +30,22 @@ public class Tarjan { int[] _vlowlink; int[] _vindex; - private Node[] _artifacts; + private List _artifacts; - public List> detectStronglyConnectedComponents(Collection artifacts) { + public List> detectStronglyConnectedComponents(Iterable artifacts) { Objects.requireNonNull(artifacts); - _artifacts = artifacts.toArray(new Node[0]); - int[][] adjacencyList = GraphUtils.computeAdjacencyList(_artifacts); + _artifacts = asList(artifacts); + int[][] adjacencyList = GraphUtils.computeAdjacencyList(artifacts); return executeTarjan(adjacencyList); } + private static List asList(Iterable iterable) { + List list = new ArrayList<>(); + iterable.forEach(list::add); + return list; + } + private List> executeTarjan(int[][] graph) { Objects.requireNonNull(graph); @@ -63,7 +68,6 @@ private List> executeTarjan(int[][] graph) { return _stronglyConnectedComponents; } - @SuppressWarnings("unchecked") private void tarjan(int v, int[][] graph) { Objects.requireNonNull(v); Objects.requireNonNull(graph); @@ -87,7 +91,7 @@ else if (_stack.contains(n)) { ArrayList component = new ArrayList(); do { n = _stack.remove(0); - component.add((T) _artifacts[n]); + component.add(_artifacts.get(n)); } while (n != v); _stronglyConnectedComponents.add(component); diff --git a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/CyclesTest.java b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/CyclesTest.java index 4773e6c..346d1fb 100644 --- a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/CyclesTest.java +++ b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/CyclesTest.java @@ -28,10 +28,10 @@ public class CyclesTest { @Test public void detectCycle() { - List nodes = TestModelCreator.createDummyModel(); + List nodes = TestModelCreator.createDummyModel(); - List> cycles = GraphUtils.detectCycles(nodes); + List> cycles = GraphUtils.detectCycles(nodes); assertThat(cycles).hasSize(1); - assertThat(cycles.get(0)).contains(nodes.get(2)).contains(nodes.get(3)); + assertThat(cycles.get(0).getNodes()).contains(nodes.get(2)).contains(nodes.get(3)); } } diff --git a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/DependencyStructureMatrixTest.java b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/DependencyStructureMatrixTest.java index 4b2a23b..9f00f9e 100644 --- a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/DependencyStructureMatrixTest.java +++ b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/DependencyStructureMatrixTest.java @@ -28,9 +28,9 @@ public class DependencyStructureMatrixTest { @Test public void detectCycle() { - List nodes = TestModelCreator.createDummyModel(); + List nodes = TestModelCreator.createDummyModel(); - IDependencyStructureMatrix dsm = GraphUtils.createDependencyStructureMatrix(nodes); + IDependencyStructureMatrix dsm = GraphUtils.createDependencyStructureMatrix(nodes); // assert ordered nodes assertThat(dsm.getOrderedNodes()).hasSize(4).containsExactly( diff --git a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/FasNodeSorterTest.java b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/FasNodeSorterTest.java index 81afbb6..7763cbb 100644 --- a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/FasNodeSorterTest.java +++ b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/FasNodeSorterTest.java @@ -26,10 +26,10 @@ public class FasNodeSorterTest { @Test public void sortNodes() { - List nodes = TestModelCreator.createDummyModel(); + List nodes = TestModelCreator.createDummyModel(); INodeSorter nodeSorter = GraphUtils.createFasNodeSorter(); - SortResult sortResult = nodeSorter.sort(nodes); + SortResult sortResult = nodeSorter.sort(nodes); assertThat(sortResult.getUpwardsDependencies()).hasSize(1); } } diff --git a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/StronglyConnectedComponentsTest.java b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/StronglyConnectedComponentsTest.java index 435ddc1..4197b51 100644 --- a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/StronglyConnectedComponentsTest.java +++ b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/StronglyConnectedComponentsTest.java @@ -28,12 +28,12 @@ public class StronglyConnectedComponentsTest { @Test public void detectCycle() { - List nodes = TestModelCreator.createDummyModel(); + List nodes = TestModelCreator.createDummyModel(); - List> stronglyConnectedComponents = GraphUtils.detectStronglyConnectedComponents(nodes); + List> stronglyConnectedComponents = GraphUtils.detectStronglyConnectedComponents(nodes); assertThat(stronglyConnectedComponents).hasSize(3); - for (List scc : stronglyConnectedComponents) { + for (List scc : stronglyConnectedComponents) { if (scc.size() == 2) { assertThat(scc).contains(nodes.get(2)).contains(nodes.get(3)); } diff --git a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/TestModelCreator.java b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/TestModelCreator.java index 5e9e74d..19b4e21 100644 --- a/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/TestModelCreator.java +++ b/javac-plugin/src/test/java/org/moditect/deptective/internal/graph/TestModelCreator.java @@ -29,12 +29,12 @@ public class TestModelCreator { *

* P1 -> P2 -> P3 <-> P4 */ - public static List createDummyModel() { + public static List createDummyModel() { - Node p1 = new Node("p1"); - Node p2 = new Node("p2"); - Node p3 = new Node("p3"); - Node p4 = new Node("p4"); + SimpleNode p1 = new SimpleNode("p1"); + SimpleNode p2 = new SimpleNode("p2"); + SimpleNode p3 = new SimpleNode("p3"); + SimpleNode p4 = new SimpleNode("p4"); p1.addOutgoingDependency(p2, 13); p2.addOutgoingDependency(p3, 57);