From 812618fc20ddbc4881983c8307f4f5b226719954 Mon Sep 17 00:00:00 2001 From: Sung Ho Yoon <55358516+syoon2@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:00:30 +0900 Subject: [PATCH] JUnit 5 Migration (#26) * Use JUnit 5 dependencies * Replace JUnit 4 API with JUnit 5 API * Organize dependencies --- jungrapht-layout/pom.xml | 4 +- .../layout/algorithms/TestTreeLayouts.java | 44 ++++++------- .../layout/algorithms/ThingTest.java | 2 +- .../eiglsperger/EiglspergerTests.java | 6 +- .../algorithms/eiglsperger/LayoutTests.java | 6 +- .../TestInsertionOrderSplayTree.java | 2 +- .../eiglsperger/TestSmallGraph.java | 62 ++++++++++--------- .../AccumulatorTreeCrossCountingTest.java | 7 ++- .../algorithms/sugiyama/AvgMedianTests.java | 2 +- .../sugiyama/BiLayerCrossCountingTest.java | 7 ++- .../algorithms/sugiyama/BrandesKopfTest.java | 31 +++++----- .../sugiyama/TestAccumulatorTree.java | 21 ++++--- .../TestDelegateVerticesAndEdges.java | 25 ++++---- .../sugiyama/TestGreedyCycleRemoval.java | 17 ++--- .../algorithms/sugiyama/TestLevelCross.java | 19 +++--- .../sugiyama/TestSugiyamaFunctions.java | 59 +++++++++--------- .../sugiyama/TestTransformingGraphView.java | 11 ++-- .../layout/algorithms/util/TestCircles.java | 13 ++-- .../util/TestComponentGrouping.java | 6 +- .../util/TestInsertionSortCounter.java | 6 +- .../algorithms/util/TestNetworkSimplex.java | 2 +- .../util/TestNetworkSimplexFive.java | 2 +- .../util/TestNetworkSimplexFour.java | 15 ++--- .../util/TestNetworkSimplexOne.java | 23 +++---- .../util/TestNetworkSimplexSix.java | 2 +- .../util/TestNetworkSimplexThree.java | 2 +- .../synthetics/SingletonTransformerTest.java | 13 ++-- .../TestDelegateVerticesAndEdges.java | 25 ++++---- .../synthetics/TestTransformingGraphView.java | 11 ++-- .../visualization/layout/model/ModelTest.java | 2 +- .../quadtree/BarnesHutQuadTreeTests.java | 29 ++++----- .../layout/spatial/FA2LayoutsTest.java | 19 +++--- .../layout/spatial/FRLayoutsTest.java | 19 +++--- .../layout/spatial/FRLayoutsTimingTest.java | 6 +- .../layout/spatial/SpringLayoutsTest.java | 19 +++--- jungrapht-visualization/pom.xml | 4 +- .../LayoutAlgorithmTransitionTest.java | 2 +- .../jungrapht/visualization/ShapeTest.java | 2 +- .../visualization/SpatialRTreeTest.java | 13 ++-- .../visualization/TestImageShaper.java | 11 ++-- .../VisualizationServerTest.java | 4 +- .../eiglsperger/EiglspergerTests.java | 6 +- .../TestInsertionOrderSplayTree.java | 2 +- .../eiglsperger/TestSmallGraph.java | 61 +++++++++--------- .../AccumulatorTreeCrossCountingTest.java | 7 ++- .../algorithms/sugiyama/AvgMedianTests.java | 2 +- .../sugiyama/BiLayerCrossCountingTest.java | 7 ++- .../algorithms/sugiyama/BrandesKopfTest.java | 31 +++++----- .../sugiyama/TestAccumulatorTree.java | 21 ++++--- .../TestDelegateVerticesAndEdges.java | 25 ++++---- .../sugiyama/TestGreedyCycleRemoval.java | 17 ++--- .../algorithms/sugiyama/TestLevelCross.java | 19 +++--- .../sugiyama/TestSugiyamaFunctions.java | 59 +++++++++--------- .../sugiyama/TestTransformingGraphView.java | 11 ++-- .../util/TestComponentGrouping.java | 6 +- .../util/TestInsertionSortCounter.java | 6 +- .../algorithms/util/TestNetworkSimplex.java | 2 +- .../util/TestNetworkSimplexFive.java | 2 +- .../util/TestNetworkSimplexFour.java | 15 ++--- .../util/TestNetworkSimplexOne.java | 23 +++---- .../util/TestNetworkSimplexSix.java | 2 +- .../util/TestNetworkSimplexThree.java | 2 +- .../synthetics/SingletonTransformerTest.java | 13 ++-- .../TestDelegateVerticesAndEdges.java | 25 ++++---- .../synthetics/TestTransformingGraphView.java | 11 ++-- .../quadtree/BarnesHutQuadTreeTests.java | 29 ++++----- .../MultiMutableSelectedStateTest.java | 35 ++++++----- .../visualization/spatial/RTreeTest.java | 4 +- .../visualization/spatial/RTreeTest2.java | 31 +++++----- .../visualization/spatial/ShapesTest.java | 9 +-- .../spatial/SpatialGridTest.java | 2 +- .../spatial/SpatialQuadTreeTest.java | 13 ++-- .../sublayout/GraphCollapserTest.java | 41 ++++++------ .../transform/IntersectionsTest.java | 23 +++---- pom.xml | 17 ++--- 75 files changed, 598 insertions(+), 556 deletions(-) diff --git a/jungrapht-layout/pom.xml b/jungrapht-layout/pom.xml index 547661035..c392bab1e 100644 --- a/jungrapht-layout/pom.xml +++ b/jungrapht-layout/pom.xml @@ -32,8 +32,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/TestTreeLayouts.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/TestTreeLayouts.java index fd69a9cfe..f80d7730c 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/TestTreeLayouts.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/TestTreeLayouts.java @@ -1,14 +1,15 @@ package org.jungrapht.visualization.layout.algorithms; +import static org.junit.jupiter.api.Assertions.*; + import java.util.stream.IntStream; import org.jgrapht.Graph; import org.jgrapht.graph.DefaultGraphType; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; import org.jungrapht.visualization.layout.model.LayoutModel; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,7 +18,7 @@ public class TestTreeLayouts { private static Logger log = LoggerFactory.getLogger(TestTreeLayouts.class); Graph graph; - @Before + @BeforeEach public void setup() { graph = GraphTypeBuilder.forGraphType(DefaultGraphType.dag()) @@ -83,11 +84,11 @@ private void testEdgeAwareTrees( layoutAlgorithmOne.visit(layoutModelOne); layoutAlgorithmTwo.visit(layoutModelTwo); - Assert.assertEquals(layoutAlgorithmOne.getBaseBounds(), layoutAlgorithmTwo.getBaseBounds()); - Assert.assertEquals(layoutModelOne.getLocations(), layoutModelTwo.getLocations()); + assertEquals(layoutAlgorithmOne.getBaseBounds(), layoutAlgorithmTwo.getBaseBounds()); + assertEquals(layoutModelOne.getLocations(), layoutModelTwo.getLocations()); - Assert.assertEquals(layoutModelOne.getWidth(), layoutModelTwo.getWidth()); - Assert.assertEquals(layoutModelOne.getHeight(), layoutModelTwo.getHeight()); + assertEquals(layoutModelOne.getWidth(), layoutModelTwo.getWidth()); + assertEquals(layoutModelOne.getHeight(), layoutModelTwo.getHeight()); log.info("treeLayout bounds: {}", layoutAlgorithmOne.getBaseBounds()); log.info("edgeSortingTreeLayoutBounds: {}", layoutAlgorithmTwo.getBaseBounds()); log.info("positions: {}", layoutModelOne.getLocations()); @@ -104,11 +105,11 @@ private void testTrees( layoutAlgorithmOne.visit(layoutModelOne); layoutAlgorithmTwo.visit(layoutModelTwo); - Assert.assertEquals(layoutAlgorithmOne.getBaseBounds(), layoutAlgorithmTwo.getBaseBounds()); - Assert.assertEquals(layoutModelOne.getLocations(), layoutModelTwo.getLocations()); + assertEquals(layoutAlgorithmOne.getBaseBounds(), layoutAlgorithmTwo.getBaseBounds()); + assertEquals(layoutModelOne.getLocations(), layoutModelTwo.getLocations()); - Assert.assertEquals(layoutModelOne.getWidth(), layoutModelTwo.getWidth()); - Assert.assertEquals(layoutModelOne.getHeight(), layoutModelTwo.getHeight()); + assertEquals(layoutModelOne.getWidth(), layoutModelTwo.getWidth()); + assertEquals(layoutModelOne.getHeight(), layoutModelTwo.getHeight()); log.info("treeLayout bounds: {}", layoutAlgorithmOne.getBaseBounds()); log.info("edgeSortingTreeLayoutBounds: {}", layoutAlgorithmTwo.getBaseBounds()); log.info("positions: {}", layoutModelOne.getLocations()); @@ -143,19 +144,14 @@ public void testTreeWithIsolatedVertices() { private void testPositions(LayoutModel layoutModel) { // there should be 5 vertices in the top row, all with equal y values log.info("Positions: {}", layoutModel.getLocations()); - Assert.assertEquals( - "Y values should match", layoutModel.get("I1").y, layoutModel.get("I2").y, .1); - Assert.assertEquals( - "Y values should match", layoutModel.get("I2").y, layoutModel.get("L1").y, .1); - Assert.assertEquals( - "Y values should match", layoutModel.get("L1").y, layoutModel.get("L2").y, .1); - Assert.assertEquals( - "Y values should match", layoutModel.get("L2").y, layoutModel.get("R").y, .1); - Assert.assertNotEquals( - "Y values should not match", layoutModel.get("R").y, layoutModel.get("C1").y, .1); + assertEquals(layoutModel.get("I1").y, layoutModel.get("I2").y, .1, "Y values should match"); + assertEquals(layoutModel.get("I2").y, layoutModel.get("L1").y, .1, "Y values should match"); + assertEquals(layoutModel.get("L1").y, layoutModel.get("L2").y, .1, "Y values should match"); + assertEquals(layoutModel.get("L2").y, layoutModel.get("R").y, .1, "Y values should match"); + assertNotEquals( + layoutModel.get("R").y, layoutModel.get("C1").y, .1, "Y values should not match"); // there should be one vertex in row 2 with x value the same as "P" - Assert.assertEquals( - "X values should match", layoutModel.get("R").x, layoutModel.get("C1").x, .1); + assertEquals(layoutModel.get("R").x, layoutModel.get("C1").x, .1, "X values should match"); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/ThingTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/ThingTest.java index 6824598d9..f4fedd12a 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/ThingTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/ThingTest.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ThingTest { diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/EiglspergerTests.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/EiglspergerTests.java index 551ac8f45..ec3663618 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/EiglspergerTests.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/EiglspergerTests.java @@ -14,8 +14,8 @@ import org.jungrapht.visualization.layout.algorithms.sugiyama.LE; import org.jungrapht.visualization.layout.algorithms.sugiyama.LV; import org.jungrapht.visualization.layout.algorithms.sugiyama.TransformedGraphSupplier; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +31,7 @@ public class EiglspergerTests { EiglspergerStepsForward stepsForward; EiglspergerStepsBackward stepsBackward; - @Before + @BeforeEach public void setup() { buildGraph(); createLayers(); diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/LayoutTests.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/LayoutTests.java index c93977a31..c10dd43d6 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/LayoutTests.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/LayoutTests.java @@ -8,8 +8,8 @@ import org.jungrapht.visualization.layout.algorithms.LayoutAlgorithm; import org.jungrapht.visualization.layout.model.LayoutModel; import org.jungrapht.visualization.layout.model.Rectangle; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,7 +76,7 @@ private Graph getTwoComponentGraph() { LayoutModel layoutModel; LayoutAlgorithm layoutAlgorithm; - @Before + @BeforeEach public void setup() { layoutAlgorithm = diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestInsertionOrderSplayTree.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestInsertionOrderSplayTree.java index 1a37a283c..33e6e50cf 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestInsertionOrderSplayTree.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestInsertionOrderSplayTree.java @@ -6,7 +6,7 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.stream.IntStream; import org.jungrapht.visualization.layout.algorithms.util.Pair; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestSmallGraph.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestSmallGraph.java index f157f20eb..4b8297d36 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestSmallGraph.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestSmallGraph.java @@ -1,5 +1,8 @@ package org.jungrapht.visualization.layout.algorithms.eiglsperger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; + import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -14,9 +17,8 @@ import org.jungrapht.visualization.layout.algorithms.sugiyama.LE; import org.jungrapht.visualization.layout.algorithms.sugiyama.LV; import org.jungrapht.visualization.layout.algorithms.sugiyama.TransformedGraphSupplier; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class TestSmallGraph { @@ -24,7 +26,7 @@ public class TestSmallGraph { private Graph, LE> svGraph; private NeighborCache, LE> neighborCache; - @Before + @BeforeEach public void setup() { graph = createInitialGraph(); } @@ -40,10 +42,10 @@ public void testEiglsperger() { Collection> feedbackArcs = greedyCycleRemoval.getFeedbackArcs(); // should be no feedback arcs in this graph - Assert.assertEquals(0, feedbackArcs.size()); + assertEquals(0, feedbackArcs.size()); List>> layers = GraphLayers.assign(svGraph); - Assert.assertEquals(5, layers.size()); + assertEquals(5, layers.size()); Synthetics synthetics = new Synthetics<>(svGraph); List> edges = new ArrayList<>(svGraph.edgeSet()); @@ -74,10 +76,10 @@ public void testEiglspergerWithGraph() { Collection> feedbackArcs = greedyCycleRemoval.getFeedbackArcs(); // should be no feedback arcs in this graph - Assert.assertEquals(0, feedbackArcs.size()); + assertEquals(0, feedbackArcs.size()); List>> layers = GraphLayers.assign(svGraph); - Assert.assertEquals(5, layers.size()); + assertEquals(5, layers.size()); Synthetics synthetics = new Synthetics<>(svGraph); List> edges = new ArrayList<>(svGraph.edgeSet()); @@ -100,37 +102,37 @@ public void testEiglspergerWithGraph() { } private void checkLayersArray(LV[][] layersArray) { - Assert.assertEquals(5, layersArray.length); + assertEquals(5, layersArray.length); LV[] layer = layersArray[0]; - Assert.assertEquals(1, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(0, (int) layer[0].getVertex()); + assertEquals(1, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(0, layer[0].getVertex()); layer = layersArray[1]; - Assert.assertEquals(2, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(1, (int) layer[0].getVertex()); - Assert.assertTrue(layer[1] instanceof PVertex); + assertEquals(2, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(1, layer[0].getVertex()); + assertInstanceOf(PVertex.class, layer[1]); layer = layersArray[2]; - Assert.assertEquals(3, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(2, (int) layer[0].getVertex()); - Assert.assertTrue(layer[1] instanceof SyntheticLV); - Assert.assertTrue(layer[2] instanceof PVertex); + assertEquals(3, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(2, layer[0].getVertex()); + assertInstanceOf(SyntheticLV.class, layer[1]); + assertInstanceOf(PVertex.class, layer[2]); layer = layersArray[3]; - Assert.assertEquals(4, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(3, (int) layer[0].getVertex()); - Assert.assertTrue(layer[1] instanceof QVertex); - Assert.assertTrue(layer[2] instanceof QVertex); - Assert.assertTrue(layer[3] instanceof SyntheticLV); + assertEquals(4, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(3, layer[0].getVertex()); + assertInstanceOf(QVertex.class, layer[1]); + assertInstanceOf(QVertex.class, layer[2]); + assertInstanceOf(SyntheticLV.class, layer[3]); layer = layersArray[4]; - Assert.assertEquals(1, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(4, (int) layer[0].getVertex()); + assertEquals(1, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(4, layer[0].getVertex()); } private Graph createInitialGraph() { diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AccumulatorTreeCrossCountingTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AccumulatorTreeCrossCountingTest.java index 35596cf98..634e6498b 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AccumulatorTreeCrossCountingTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AccumulatorTreeCrossCountingTest.java @@ -1,13 +1,14 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.jungrapht.visualization.layout.algorithms.util.InsertionSortCounter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,7 +74,7 @@ public void runTest() { Collections.shuffle(edges); log.info("shuffled edges: {}", edges); int count = crossingCount(edges); - Assert.assertEquals(12, count); + assertEquals(12, count); } @Test diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java index de5eb6ee6..040d45d42 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java @@ -1,7 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BiLayerCrossCountingTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BiLayerCrossCountingTest.java index 0c1f1111d..e0b6a1720 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BiLayerCrossCountingTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BiLayerCrossCountingTest.java @@ -1,13 +1,14 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.jungrapht.visualization.layout.algorithms.util.InsertionSortCounter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,7 +74,7 @@ public void runTest() { Collections.shuffle(edges); log.info("shuffled edges: {}", edges); int count = crossingCount(edges); - Assert.assertEquals(12, count); + assertEquals(12, count); } @Test diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BrandesKopfTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BrandesKopfTest.java index e83a054dd..195fcaede 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BrandesKopfTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BrandesKopfTest.java @@ -1,13 +1,14 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import java.util.HashSet; import java.util.stream.IntStream; import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,7 +86,7 @@ void createDelegateGraph() { svGraph = new TransformedGraphSupplier<>(graph).get(); } - @Before + @BeforeEach public void setup() { createInitialGraph(); } @@ -95,17 +96,17 @@ public void makeBrandesKopf() { BrandesKopf brandesKopf = new BrandesKopf(graph); svGraph = brandesKopf.svGraph; LV[][] layers = brandesKopf.layersArray; - Assert.assertEquals(10, layers.length); - Assert.assertEquals(2, layers[0].length); - Assert.assertEquals(5, layers[1].length); - Assert.assertEquals(6, layers[2].length); - Assert.assertEquals(6, layers[3].length); - Assert.assertEquals(8, layers[4].length); - Assert.assertEquals(9, layers[5].length); - Assert.assertEquals(9, layers[6].length); - Assert.assertEquals(7, layers[7].length); - Assert.assertEquals(4, layers[8].length); - Assert.assertEquals(1, layers[9].length); + assertEquals(10, layers.length); + assertEquals(2, layers[0].length); + assertEquals(5, layers[1].length); + assertEquals(6, layers[2].length); + assertEquals(6, layers[3].length); + assertEquals(8, layers[4].length); + assertEquals(9, layers[5].length); + assertEquals(9, layers[6].length); + assertEquals(7, layers[7].length); + assertEquals(4, layers[8].length); + assertEquals(1, layers[9].length); HorizontalCoordinateAssignment horizontalCoordinateAssignment = new HorizontalCoordinateAssignment<>(layers, svGraph, new HashSet<>(), 20, 20); diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestAccumulatorTree.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestAccumulatorTree.java index 759fa4cb8..c6872bc45 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestAccumulatorTree.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestAccumulatorTree.java @@ -1,14 +1,15 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import org.jungrapht.visualization.layout.algorithms.util.InsertionSortCounter; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,7 +61,7 @@ public class TestAccumulatorTree { AccumulatorTree tree; - @Before + @BeforeEach public void setup() { log.info("edges: {}", edges); Collections.shuffle(edges); @@ -85,7 +86,7 @@ public void testCount() { int countIS = InsertionSortCounter.insertionSortCounter(targetIndices); log.info("countIS is :{}", countIS); - Assert.assertEquals(countIS, count); + assertEquals(countIS, count); } @Test @@ -109,7 +110,7 @@ public void testCountReversed() { int countIS = InsertionSortCounter.insertionSortCounter(sourceIndices); log.info("countIS is :{}", countIS); - Assert.assertEquals(countIS, count); + assertEquals(countIS, count); // swap the edge endpoints and run the count on the target indices edges = swapEdgeEndpoints(edges); @@ -128,10 +129,10 @@ public void testCountReversed() { countIS = InsertionSortCounter.insertionSortCounter(targetIndices); log.info("countIS is :{}", countIS); - Assert.assertEquals(countIS, count); + assertEquals(countIS, count); } - // Assert.assertEquals(countIS, count); + // assertEquals(countIS, count); // } private static List> swapEdgeEndpoints(List> list) { @@ -168,7 +169,7 @@ public void testWeighted() { int countIS = InsertionSortCounter.insertionSortCounter(targetIndices); log.info("countIS is :{}", countIS); - Assert.assertEquals(countIS, countWeight); + assertEquals(countIS, countWeight); } @Test @@ -184,7 +185,7 @@ public void testWeighted2() { int countWeight = tree.crossWeight(targetIndices, i -> 2); log.info("countWeight is :{}", countWeight); - Assert.assertEquals(48, countWeight); + assertEquals(48, countWeight); int countIS = InsertionSortCounter.insertionSortCounter(targetIndices); log.info("countIS is :{}", countIS); diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java index f25dbb73f..778e0af7c 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java @@ -1,9 +1,10 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import org.jungrapht.visualization.layout.util.synthetics.SVI; import org.jungrapht.visualization.layout.util.synthetics.Synthetic; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestDelegateVerticesAndEdges { @@ -15,12 +16,12 @@ public void testVertices() { LV sa = LV.of(a); LV sb = LV.of(b); - Assert.assertTrue(sa instanceof SVI); - Assert.assertNotEquals(sa, sb); - Assert.assertEquals(sa, LV.of("a")); + assertInstanceOf(SVI.class, sa); + assertNotEquals(sa, sb); + assertEquals(LV.of("a"), sa); LV syntheticA = new SyntheticLV<>(); - Assert.assertNotEquals(syntheticA, sa); - Assert.assertTrue(syntheticA instanceof Synthetic); + assertNotEquals(syntheticA, sa); + assertInstanceOf(Synthetic.class, syntheticA); } @Test @@ -35,10 +36,10 @@ public void testEdges() { LE se1 = LE.of(edge1, sa, sb); LE se2 = LE.of(edge2, sa, sc); LE se3 = LE.of(2, sa, sc); - Assert.assertTrue(se1 instanceof LEI); - Assert.assertTrue(se2 instanceof LEI); - Assert.assertNotEquals(se1, se2); - Assert.assertEquals(se2, se3); - Assert.assertTrue(new SyntheticLE<>(se1, sa, sb) instanceof Synthetic); + assertInstanceOf(LEI.class, se1); + assertInstanceOf(LEI.class, se2); + assertNotEquals(se1, se2); + assertEquals(se2, se3); + assertInstanceOf(Synthetic.class, new SyntheticLE<>(se1, sa, sb)); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestGreedyCycleRemoval.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestGreedyCycleRemoval.java index 4a681f5e0..86b1f1433 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestGreedyCycleRemoval.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestGreedyCycleRemoval.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Collection; import java.util.Set; import org.jgrapht.Graph; @@ -7,9 +9,8 @@ import org.jgrapht.graph.builder.GraphBuilder; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +19,7 @@ public class TestGreedyCycleRemoval { private static final Logger log = LoggerFactory.getLogger(TestGreedyCycleRemoval.class); Graph graph; - @Before + @BeforeEach public void setup() { graph = GraphTypeBuilder.directed() @@ -50,7 +51,7 @@ public void testCycleRemoval() { GreedyCycleRemoval gcr = new GreedyCycleRemoval<>(graph); - Assert.assertTrue(gcr.getFeedbackArcs().containsAll(Set.of(8))); + assertTrue(gcr.getFeedbackArcs().containsAll(Set.of(8))); } @Test @@ -60,7 +61,7 @@ public void anotherTest() { GreedyCycleRemoval gcr = new GreedyCycleRemoval<>(graph); log.info("reverseArcs: {}", gcr.getFeedbackArcs()); - Assert.assertTrue(gcr.getFeedbackArcs().containsAll(Set.of(122, 109))); + assertTrue(gcr.getFeedbackArcs().containsAll(Set.of(122, 109))); } public static Graph generateProgramGraph2() { @@ -128,8 +129,8 @@ public void smallTest() { graph.addEdge("D", "B"); // introduces a cycle log.info("graph: {}", graph); - Assert.assertEquals(graph.getEdgeSource(3), "D"); - Assert.assertEquals(graph.getEdgeTarget(3), "B"); + assertEquals("D", graph.getEdgeSource(3)); + assertEquals("B", graph.getEdgeTarget(3)); TransformedGraphSupplier transformedGraphSupplier = new TransformedGraphSupplier(graph); diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestLevelCross.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestLevelCross.java index 5f7bb841a..0a6924970 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestLevelCross.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestLevelCross.java @@ -1,9 +1,10 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +94,7 @@ public void testLevelCross5() { // should be 1 edgeList.add(LE.of(e++, c, y)); // trt edgeList.add(LE.of(e++, a, y)); - Assert.assertEquals(1, go()); + assertEquals(1, go()); } @Test @@ -113,7 +114,7 @@ public void testLevelCross6() { //1 edgeList.add(LE.of(e++, b, x)); edgeList.add(LE.of(e++, c, y)); edgeList.add(LE.of(e++, a, y)); - assert 1 == go(); + assertEquals(1, go()); } @Test @@ -135,7 +136,7 @@ public void testLevelCross7() { // 3 edgeList.add(LE.of(e++, a, y)); // trb edgeList.add(LE.of(e++, c, z)); - Assert.assertEquals(3, go()); + assertEquals(3, go()); } @Test @@ -152,7 +153,7 @@ public void testLevelCross8() { // 0 edgeList.add(LE.of(e++, a, z)); edgeList.add(LE.of(e++, c, y)); edgeList.add(LE.of(e++, a, y)); - Assert.assertEquals(0, go()); + assertEquals(0, go()); } @Test @@ -170,7 +171,7 @@ public void testLevelCross9() { // 1 edgeList.add(LE.of(e++, c, y)); edgeList.add(LE.of(e++, a, y)); edgeList.add(LE.of(e++, c, z)); - Assert.assertEquals(1, go()); + assertEquals(1, go()); } @Test @@ -185,7 +186,7 @@ public void testLevelCross10() { // 1 edgeList.add(LE.of(e++, a, x)); edgeList.add(LE.of(e++, b, z)); - Assert.assertEquals(1, go()); + assertEquals(1, go()); } @Test @@ -204,7 +205,7 @@ public void testLevelCross11() { // should be 1 edgeList.add(LE.of(e++, b, x)); edgeList.add(LE.of(e++, c, y)); edgeList.add(LE.of(e++, c, z)); - Assert.assertEquals(1, go()); + assertEquals(1, go()); } private int go() { diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestSugiyamaFunctions.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestSugiyamaFunctions.java index 2c8a84d25..58a7ca766 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestSugiyamaFunctions.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestSugiyamaFunctions.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -12,9 +14,8 @@ import org.jungrapht.visualization.layout.util.synthetics.SE; import org.jungrapht.visualization.layout.util.synthetics.SV; import org.jungrapht.visualization.layout.util.synthetics.SVTransformedGraphSupplier; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +25,7 @@ public class TestSugiyamaFunctions { Graph graph; - @Before + @BeforeEach public void setup() { // build a DAG graph = @@ -56,8 +57,8 @@ public void testTransformedGraph() { new SVTransformedGraphSupplier(graph); Graph, SE> sgraph = svTransformedGraphSupplier.get(); - Assert.assertEquals(graph.vertexSet().size(), sgraph.vertexSet().size()); - Assert.assertEquals(graph.edgeSet().size(), sgraph.edgeSet().size()); + assertEquals(graph.vertexSet().size(), sgraph.vertexSet().size()); + assertEquals(graph.edgeSet().size(), sgraph.edgeSet().size()); Set verticesCopy = new HashSet<>(graph.vertexSet()); Set edgesCopy = new HashSet<>(graph.edgeSet()); @@ -65,18 +66,18 @@ public void testTransformedGraph() { .vertexSet() .forEach( v -> { - Assert.assertTrue(graph.containsVertex(v.getVertex())); + assertTrue(graph.containsVertex(v.getVertex())); verticesCopy.remove(v.getVertex()); }); - Assert.assertTrue(verticesCopy.isEmpty()); + assertTrue(verticesCopy.isEmpty()); sgraph .edgeSet() .forEach( e -> { - Assert.assertTrue(graph.containsEdge(e.getEdge())); + assertTrue(graph.containsEdge(e.getEdge())); edgesCopy.remove(e.getEdge()); }); - Assert.assertTrue(edgesCopy.isEmpty()); + assertTrue(edgesCopy.isEmpty()); } @Test @@ -88,7 +89,7 @@ public void testAssignLayers() { List>> layers = GraphLayers.assign(sgraph); - Assert.assertEquals(3, layers.size()); // this graph should have 3 layers + assertEquals(3, layers.size()); // this graph should have 3 layers this.checkLayers(layers); log.info("assign layers:"); @@ -107,7 +108,7 @@ public void testAssignLayers() { } log.info("there are {} edges ", edges.size()); log.info("edges: {}", edges); - Assert.assertEquals(graph.edgeSet().size(), edges.size() - 1); + assertEquals(graph.edgeSet().size(), edges.size() - 1); checkLayers(layers); } @@ -147,7 +148,7 @@ public void testAssignLayersWithDoubleSkip() { log.info("edges: {}", edges); log.info("graph.edgeSet(): {}", graph.edgeSet()); log.info("edges.size(): {}", edges.size()); - Assert.assertEquals(graph.edgeSet().size(), edges.size() - 3); + assertEquals(graph.edgeSet().size(), edges.size() - 3); checkLayers(layers); log.info("outgoing dag: {}", sgraph.toString()); @@ -188,7 +189,7 @@ public void testAssignLayersWithDoubleSkip() { .map(v -> (SyntheticLV) v) .collect(Collectors.toList()); - Assert.assertEquals(3, virtualVertices.size()); + assertEquals(3, virtualVertices.size()); synthetics.makeArticulatedEdges(); @@ -203,14 +204,14 @@ public void testAssignLayersWithDoubleSkip() { && ((ArticulatedEdge) e).getIntermediateVertices().size() == 2) .map(e -> (ArticulatedEdge) e) .collect(Collectors.toList()); - Assert.assertEquals(1, articulatedEdges.size()); + assertEquals(1, articulatedEdges.size()); ArticulatedEdge bentEdge = articulatedEdges.get(0); List ranks = new ArrayList<>(); ranks.add(bentEdge.source.getRank()); ranks.addAll( bentEdge.getIntermediateVertices().stream().map(LV::getRank).collect(Collectors.toList())); ranks.add(bentEdge.target.getRank()); - Assert.assertEquals(ranks, List.of(0, 1, 2, 3)); + assertEquals(ranks, List.of(0, 1, 2, 3)); // test that one edge has 1 intermediate vertex articulatedEdges = @@ -223,14 +224,14 @@ public void testAssignLayersWithDoubleSkip() { && ((ArticulatedEdge) e).getIntermediateVertices().size() == 1) .map(e -> (ArticulatedEdge) e) .collect(Collectors.toList()); - Assert.assertEquals(1, articulatedEdges.size()); + assertEquals(1, articulatedEdges.size()); bentEdge = articulatedEdges.get(0); ranks = new ArrayList<>(); ranks.add(bentEdge.source.getRank()); ranks.addAll( bentEdge.getIntermediateVertices().stream().map(LV::getRank).collect(Collectors.toList())); ranks.add(bentEdge.target.getRank()); - Assert.assertEquals(ranks, List.of(0, 1, 2)); + assertEquals(ranks, List.of(0, 1, 2)); log.info("dag vertices: {}", sgraph.vertexSet()); log.info("dag edges: {}", sgraph.edgeSet()); @@ -264,15 +265,15 @@ private void checkLayers(List>> layers) { for (int j = 0; j < layer.size(); j++) { LV LV = layer.get(j); log.info("sv {},{}: {}", i, j, LV); - Assert.assertEquals(i, LV.getRank()); - Assert.assertEquals(j, LV.getIndex()); + assertEquals(i, LV.getRank()); + assertEquals(j, LV.getIndex()); } } } private void testConsecutive(int[] array) { for (int i = 0; i < array.length - 1; i++) { - Assert.assertEquals(array[i] + 1, array[i + 1]); + assertEquals(array[i] + 1, array[i + 1]); } } @@ -295,37 +296,37 @@ public void testInsertionSortCounter() { int[] array = new int[] {0, 1, 2, 3, 4, 5}; int count = insertionSortCounter(array); log.info("count is {}", count); - Assert.assertEquals(0, count); + assertEquals(0, count); array = new int[] {0, 1, 2, 0, 3, 4, 0, 2, 3, 2, 4}; count = insertionSortCounter(array); log.info("count is {}", count); - Assert.assertEquals(12, count); + assertEquals(12, count); array = new int[] {0, 1, 3, 1, 2}; count = insertionSortCounter(array); log.info("count is {}", count); - Assert.assertEquals(2, count); + assertEquals(2, count); array = new int[] {1, 2, 0, 1, 3}; count = insertionSortCounter(array); log.info("count is {}", count); - Assert.assertEquals(3, count); + assertEquals(3, count); List list = Arrays.asList(0, 1, 2, 0, 3, 4, 0, 2, 3, 2, 4); count = insertionSortCounter(list); log.info("count is {}", count); - Assert.assertEquals(12, count); + assertEquals(12, count); list = Arrays.asList(0, 1, 3, 1, 2); count = insertionSortCounter(list); log.info("count is {}", count); - Assert.assertEquals(2, count); + assertEquals(2, count); list = Arrays.asList(1, 2, 0, 1, 3); count = insertionSortCounter(list); log.info("count is {}", count); - Assert.assertEquals(3, count); + assertEquals(3, count); } private int insertionSortCounter(List list) { @@ -377,6 +378,6 @@ public void testRemoveCycles() { graph.removeEdge("20", "10"); graph.removeEdge("21", "11"); graph.removeEdge("20", "00"); - Assert.assertEquals(graph, dag); + assertEquals(graph, dag); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestTransformingGraphView.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestTransformingGraphView.java index 7d8ec36e3..71662e415 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestTransformingGraphView.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestTransformingGraphView.java @@ -1,12 +1,13 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; import org.jungrapht.visualization.layout.util.synthetics.SingletonTransformer; import org.jungrapht.visualization.layout.util.synthetics.TransformingGraphView; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestTransformingGraphView { @@ -42,9 +43,9 @@ public void testRoundTrip() { Graph transformedBackGraph = transformingGraphView.build(); - Assert.assertTrue(graph.vertexSet().containsAll(transformedBackGraph.vertexSet())); - Assert.assertTrue(graph.edgeSet().containsAll(transformedBackGraph.edgeSet())); + assertTrue(graph.vertexSet().containsAll(transformedBackGraph.vertexSet())); + assertTrue(graph.edgeSet().containsAll(transformedBackGraph.edgeSet())); - Assert.assertEquals(transformedBackGraph.getEdge("a", "b"), graph.getEdge("a", "b")); + assertEquals(transformedBackGraph.getEdge("a", "b"), graph.getEdge("a", "b")); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestCircles.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestCircles.java index 9fc685d2e..ca107de4d 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestCircles.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestCircles.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.util; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.List; import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; @@ -7,9 +9,8 @@ import org.jungrapht.visualization.layout.util.synthetics.SE; import org.jungrapht.visualization.layout.util.synthetics.SV; import org.jungrapht.visualization.layout.util.synthetics.SVTransformedGraphSupplier; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +21,7 @@ public class TestCircles { Graph graph; Graph, SE> svGraph; - @Before + @BeforeEach public void before() { graph = GraphTypeBuilder.undirected() @@ -65,7 +66,7 @@ public void testCount() { List vertexList = List.of(1, 10, 9, 7, 8, 6, 5, 4, 2, 3); int count = CircleLayoutReduceEdgeCrossing.countCrossings(graph, vertexList.toArray(new Integer[0])); - Assert.assertEquals(7, count); + assertEquals(7, count); } @Test @@ -75,7 +76,7 @@ public void testThis() { int count = CircleLayoutReduceEdgeCrossing.countCrossings( graph, circleLayouts.getVertexOrderedList().toArray(new Integer[0])); - Assert.assertEquals(0, count); + assertEquals(0, count); /* diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestComponentGrouping.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestComponentGrouping.java index 1a6ba4a7c..c837f2e55 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestComponentGrouping.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestComponentGrouping.java @@ -5,8 +5,8 @@ import org.jgrapht.graph.DefaultGraphType; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,7 +16,7 @@ public class TestComponentGrouping { Graph graph; - @Before + @BeforeEach public void setup() { this.graph = GraphTypeBuilder.forGraphType(DefaultGraphType.multigraph()) diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestInsertionSortCounter.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestInsertionSortCounter.java index 1633db1ec..de1390df1 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestInsertionSortCounter.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestInsertionSortCounter.java @@ -3,8 +3,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,7 +16,7 @@ public class TestInsertionSortCounter { List list = Arrays.asList(8, 2, 8, 5, 3, 7, 9, 2, 5, 4, 8, 4, 9); - @Before + @BeforeEach public void setup() { int size = 1000; array = new int[size]; diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplex.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplex.java index eed11d79a..23b25bbd6 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplex.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplex.java @@ -8,7 +8,7 @@ import org.jungrapht.visualization.layout.algorithms.sugiyama.LE; import org.jungrapht.visualization.layout.algorithms.sugiyama.LV; import org.jungrapht.visualization.layout.algorithms.sugiyama.TransformedGraphSupplier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFive.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFive.java index 411ba70a5..cd9c85eec 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFive.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFive.java @@ -3,7 +3,7 @@ import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFour.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFour.java index 79096bf35..30ddccdfc 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFour.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFour.java @@ -1,12 +1,13 @@ package org.jungrapht.visualization.layout.algorithms.util; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.Map; import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,18 +31,18 @@ public void computeCutValues() { Map.of(2, 3, 3, 3, 4, 0, 5, 0, 6, 3, 7, -1, 8, 3); // preliminary cut value map. check to make sure it matches values in the paper Map cutValueMap = networkSimplexDevelopment.getEdgeCutValues(spanningTree); - Assert.assertEquals(expectedFirstCutValueMap, cutValueMap); + assertEquals(expectedFirstCutValueMap, cutValueMap); Graph best = networkSimplexDevelopment.getTheBestSpanningTree(); cutValueMap = networkSimplexDevelopment.getEdgeCutValues(spanningTree); Map expectedSecondCutValueMap = Map.of(0, 1, 2, 2, 3, 2, 4, 1, 5, 0, 6, 2, 8, 2); - Assert.assertEquals(expectedSecondCutValueMap, cutValueMap); + assertEquals(expectedSecondCutValueMap, cutValueMap); log.info("bestSpanningTree: {}", best); - Assert.assertTrue(best.edgeSet().containsAll(List.of(0, 2, 3, 4, 5, 6, 8))); - Assert.assertFalse(best.containsEdge(1)); - Assert.assertFalse(best.containsEdge(7)); + assertTrue(best.edgeSet().containsAll(List.of(0, 2, 3, 4, 5, 6, 8))); + assertFalse(best.containsEdge(1)); + assertFalse(best.containsEdge(7)); } /** build the graph and the spanning tree shown in the paper */ diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexOne.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexOne.java index c6e021177..6adb4d24d 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexOne.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexOne.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.util; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -11,8 +13,7 @@ import org.jgrapht.graph.AbstractBaseGraph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,12 +69,12 @@ public void computeCutValues() { spanningTree.addEdge("d", "h", dh); Map cutValues = getEdgeCutValues(dag, spanningTree); - Assert.assertEquals(-1, (int) cutValues.get(7)); - Assert.assertEquals(3, (int) cutValues.get(2)); - Assert.assertEquals(3, (int) cutValues.get(3)); - Assert.assertEquals(0, (int) cutValues.get(4)); - Assert.assertEquals(3, (int) cutValues.get(6)); - Assert.assertEquals(3, (int) cutValues.get(8)); + assertEquals(-1, cutValues.get(7)); + assertEquals(3, cutValues.get(2)); + assertEquals(3, cutValues.get(3)); + assertEquals(0, cutValues.get(4)); + assertEquals(3, cutValues.get(6)); + assertEquals(3, cutValues.get(8)); // if there is a negative value... List values = new ArrayList<>(cutValues.values()); values.sort(Integer::compareTo); @@ -109,9 +110,9 @@ public void computeCutValues() { } } log.info("bestSpanningTree: {}", spanningTree); - Assert.assertTrue(spanningTree.edgeSet().containsAll(List.of(0, 2, 3, 4, 5, 6, 8))); - Assert.assertFalse(spanningTree.containsEdge(1)); - Assert.assertFalse(spanningTree.containsEdge(7)); + assertTrue(spanningTree.edgeSet().containsAll(List.of(0, 2, 3, 4, 5, 6, 8))); + assertFalse(spanningTree.containsEdge(1)); + assertFalse(spanningTree.containsEdge(7)); } Map getEdgeCutValues( diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexSix.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexSix.java index 36b170b94..73f7a9bbe 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexSix.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexSix.java @@ -4,7 +4,7 @@ import org.jgrapht.graph.DefaultGraphType; import org.jgrapht.graph.builder.GraphBuilder; import org.jgrapht.graph.builder.GraphTypeBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexThree.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexThree.java index c03e8e10a..190a847f9 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexThree.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexThree.java @@ -3,7 +3,7 @@ import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java index 304ae2fa3..5361a79b0 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java @@ -1,8 +1,9 @@ package org.jungrapht.visualization.layout.algorithms.util.synthetics; +import static org.junit.jupiter.api.Assertions.*; + import org.jungrapht.visualization.layout.util.synthetics.SingletonTransformer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test to ensure that keys return expected values, that a second transformation of the same key @@ -19,12 +20,12 @@ public void test() { int got2 = singletonTransformer.apply(1); int got3 = singletonTransformer.apply(2); - Assert.assertEquals(2, got2); - Assert.assertEquals(3, got3); + assertEquals(2, got2); + assertEquals(3, got3); int gotDupe = singletonTransformer.apply(1); - Assert.assertTrue(gotDupe == got2); + assertTrue(gotDupe == got2); - Assert.assertEquals(2, singletonTransformer.getTransformedMap().size()); + assertEquals(2, singletonTransformer.getTransformedMap().size()); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java index 1717a78e6..f7c8a32fc 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.util.synthetics; +import static org.junit.jupiter.api.Assertions.*; + import org.jungrapht.visualization.layout.util.synthetics.SE; import org.jungrapht.visualization.layout.util.synthetics.SEI; import org.jungrapht.visualization.layout.util.synthetics.SV; @@ -7,8 +9,7 @@ import org.jungrapht.visualization.layout.util.synthetics.Synthetic; import org.jungrapht.visualization.layout.util.synthetics.SyntheticSE; import org.jungrapht.visualization.layout.util.synthetics.SyntheticSV; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestDelegateVerticesAndEdges { @@ -20,12 +21,12 @@ public void testVertices() { SV sa = SV.of(a); SV sb = SV.of(b); - Assert.assertTrue(sa instanceof SVI); - Assert.assertNotEquals(sa, sb); - Assert.assertEquals(sa, SV.of("a")); + assertInstanceOf(SVI.class, sa); + assertNotEquals(sa, sb); + assertEquals(sa, SV.of("a")); SV syntheticA = new SyntheticSV(); - Assert.assertNotEquals(syntheticA, sa); - Assert.assertTrue(syntheticA instanceof Synthetic); + assertNotEquals(syntheticA, sa); + assertInstanceOf(Synthetic.class, syntheticA); } @Test @@ -37,10 +38,10 @@ public void testEdges() { SE se1 = SE.of(edge1); SE se2 = SE.of(edge2); SE se3 = SE.of(2); - Assert.assertTrue(se1 instanceof SEI); - Assert.assertTrue(se2 instanceof SEI); - Assert.assertNotEquals(se1, se2); - Assert.assertEquals(se2, se3); - Assert.assertTrue(new SyntheticSE<>() instanceof Synthetic); + assertInstanceOf(SEI.class, se1); + assertInstanceOf(SEI.class, se2); + assertNotEquals(se1, se2); + assertEquals(se2, se3); + assertInstanceOf(Synthetic.class, new SyntheticSE<>()); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestTransformingGraphView.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestTransformingGraphView.java index 6c043e0c6..828e1cca3 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestTransformingGraphView.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestTransformingGraphView.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.util.synthetics; +import static org.junit.jupiter.api.Assertions.*; + import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; @@ -8,8 +10,7 @@ import org.jungrapht.visualization.layout.util.synthetics.SVTransformedGraphSupplier; import org.jungrapht.visualization.layout.util.synthetics.SingletonTransformer; import org.jungrapht.visualization.layout.util.synthetics.TransformingGraphView; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestTransformingGraphView { @@ -45,9 +46,9 @@ public void testRoundTrip() { Graph transformedBackGraph = transformingGraphView.build(); - Assert.assertTrue(graph.vertexSet().containsAll(transformedBackGraph.vertexSet())); - Assert.assertTrue(graph.edgeSet().containsAll(transformedBackGraph.edgeSet())); + assertTrue(graph.vertexSet().containsAll(transformedBackGraph.vertexSet())); + assertTrue(graph.edgeSet().containsAll(transformedBackGraph.edgeSet())); - Assert.assertEquals(transformedBackGraph.getEdge("a", "b"), graph.getEdge("a", "b")); + assertEquals(transformedBackGraph.getEdge("a", "b"), graph.getEdge("a", "b")); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/model/ModelTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/model/ModelTest.java index 9cdf43dbf..b957e21ea 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/model/ModelTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/model/ModelTest.java @@ -1,6 +1,6 @@ package org.jungrapht.visualization.layout.model; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ModelTest { diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/quadtree/BarnesHutQuadTreeTests.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/quadtree/BarnesHutQuadTreeTests.java index 5c12d84af..402a7fab4 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/quadtree/BarnesHutQuadTreeTests.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/quadtree/BarnesHutQuadTreeTests.java @@ -1,9 +1,10 @@ package org.jungrapht.visualization.layout.quadtree; +import static org.junit.jupiter.api.Assertions.*; + import org.jungrapht.visualization.layout.model.Point; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +19,7 @@ public class BarnesHutQuadTreeTests { private static final Logger log = LoggerFactory.getLogger(BarnesHutQuadTreeTests.class); private BarnesHutQuadTree tree; - @Before + @BeforeEach public void setup() { tree = BarnesHutQuadTree.builder().bounds(500, 500).build(); } @@ -38,7 +39,7 @@ public void testOne() { log.info("tree: {}", tree); ForceObject expectedForceObject = new ForceObject("force", 10, 10, 3); - Assert.assertEquals(tree.getRoot().getForceObject(), expectedForceObject); + assertEquals(tree.getRoot().getForceObject(), expectedForceObject); } /** test a simple construction */ @@ -54,16 +55,16 @@ public void testTwo() { tree.insert(forceObjectD); log.info("tree: {}", tree); - Assert.assertNotNull(tree.getRoot()); + assertNotNull(tree.getRoot()); Node root = tree.getRoot(); - Assert.assertFalse(root.isLeaf()); + assertFalse(root.isLeaf()); Node NW = root.NW; - Assert.assertEquals(NW.forceObject, forceObjectA.add(forceObjectB).add(forceObjectC)); - Assert.assertFalse(NW.isLeaf()); - Assert.assertEquals(NW.NW.forceObject, forceObjectC); - Assert.assertEquals(NW.NE.forceObject, forceObjectA); - Assert.assertEquals(NW.SW.forceObject, forceObjectB); - Assert.assertNull(NW.SE.forceObject); - Assert.assertEquals(root.NE.forceObject, forceObjectD); + assertEquals(NW.forceObject, forceObjectA.add(forceObjectB).add(forceObjectC)); + assertFalse(NW.isLeaf()); + assertEquals(NW.NW.forceObject, forceObjectC); + assertEquals(NW.NE.forceObject, forceObjectA); + assertEquals(NW.SW.forceObject, forceObjectB); + assertNull(NW.SE.forceObject); + assertEquals(root.NE.forceObject, forceObjectD); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FA2LayoutsTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FA2LayoutsTest.java index 652b0b626..872e6056d 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FA2LayoutsTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FA2LayoutsTest.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.spatial; +import static org.junit.jupiter.api.Assertions.*; + import java.util.HashMap; import java.util.Map; import org.jgrapht.Graph; @@ -13,10 +15,9 @@ import org.jungrapht.visualization.layout.model.DefaultLayoutModel; import org.jungrapht.visualization.layout.model.LayoutModel; import org.jungrapht.visualization.layout.model.Point; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +57,7 @@ public class FA2LayoutsTest { * this runs again before each test. Build a simple graph, build a custom layout model (see below) * initialize the locations to be the same each time. */ - @Before + @BeforeEach public void setup() { int i = 0; graph = @@ -128,20 +129,20 @@ public void testFA2BHWithThetaZero() { * check to see if mapTwo and mapThree (the ones that used the BarnesHut optimization) returned * similar results */ - @AfterClass + @AfterAll public static void check() { log.debug("mapOne:{}", mapOne); log.debug("mapThree:{}", mapThree); log.debug("mapFour:{}", mapFour); - Assert.assertEquals(mapOne.keySet(), mapFour.keySet()); + assertEquals(mapOne.keySet(), mapFour.keySet()); for (String key : mapOne.keySet()) { Point p2 = mapOne.get(key); Point p3 = mapFour.get(key); log.info("p2.x:{} p3.x:{}", p2.x, p3.x); log.info("p2.y:{} p3.y:{}", p2.y, p3.y); - Assert.assertTrue(Math.abs(p2.x - p3.x) < 1.0E-3); - Assert.assertTrue(Math.abs(p2.y - p3.y) < 1.0E-3); + assertTrue(Math.abs(p2.x - p3.x) < 1.0E-3); + assertTrue(Math.abs(p2.y - p3.y) < 1.0E-3); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FRLayoutsTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FRLayoutsTest.java index 53958f9c8..de0e894bd 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FRLayoutsTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FRLayoutsTest.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.spatial; +import static org.junit.jupiter.api.Assertions.*; + import java.util.HashMap; import java.util.Map; import org.jgrapht.Graph; @@ -13,10 +15,9 @@ import org.jungrapht.visualization.layout.model.DefaultLayoutModel; import org.jungrapht.visualization.layout.model.LayoutModel; import org.jungrapht.visualization.layout.model.Point; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +57,7 @@ public class FRLayoutsTest { * this runs again before each test. Build a simple graph, build a custom layout model (see below) * initialize the locations to be the same each time. */ - @Before + @BeforeEach public void setup() { int i = 0; graph = @@ -128,20 +129,20 @@ public void testFRBHWithThetaZero() { * check to see if mapTwo and mapThree (the ones that used the BarnesHut optimization) returned * similar results */ - @AfterClass + @AfterAll public static void check() { log.debug("mapOne:{}", mapOne); log.debug("mapThree:{}", mapThree); log.debug("mapFour:{}", mapFour); - Assert.assertEquals(mapOne.keySet(), mapFour.keySet()); + assertEquals(mapOne.keySet(), mapFour.keySet()); for (String key : mapOne.keySet()) { Point p2 = mapOne.get(key); Point p3 = mapFour.get(key); log.info("p2.x:{} p3.x:{}", p2.x, p3.x); log.info("p2.y:{} p3.y:{}", p2.y, p3.y); - Assert.assertTrue(Math.abs(p2.x - p3.x) < 1.0E-3); - Assert.assertTrue(Math.abs(p2.y - p3.y) < 1.0E-3); + assertTrue(Math.abs(p2.x - p3.x) < 1.0E-3); + assertTrue(Math.abs(p2.y - p3.y) < 1.0E-3); } } diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FRLayoutsTimingTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FRLayoutsTimingTest.java index 28754219c..7eb6f5ca6 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FRLayoutsTimingTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/FRLayoutsTimingTest.java @@ -8,8 +8,8 @@ import org.jungrapht.visualization.layout.algorithms.repulsion.BarnesHutFRRepulsion; import org.jungrapht.visualization.layout.model.LayoutModel; import org.jungrapht.visualization.layout.util.RandomLocationTransformer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +36,7 @@ public class FRLayoutsTimingTest { * this runs again before each test. Build a simple graph, build a custom layout model (see below) * initialize the locations to be the same each time. */ - @Before + @BeforeEach public void setup() { graph = GraphTypeBuilder.forGraphType(DefaultGraphType.multigraph()).buildGraph(); diff --git a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/SpringLayoutsTest.java b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/SpringLayoutsTest.java index ab701cbf6..91e0a6933 100644 --- a/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/SpringLayoutsTest.java +++ b/jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/spatial/SpringLayoutsTest.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.spatial; +import static org.junit.jupiter.api.Assertions.*; + import java.util.HashMap; import java.util.Map; import org.jgrapht.Graph; @@ -13,10 +15,9 @@ import org.jungrapht.visualization.layout.model.DefaultLayoutModel; import org.jungrapht.visualization.layout.model.LayoutModel; import org.jungrapht.visualization.layout.model.Point; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +57,7 @@ public class SpringLayoutsTest { * this runs again before each test. Build a simple graph, build a custom layout model (see below) * initialize the locations to be the same each time. */ - @Before + @BeforeEach public void setup() { int i = 0; graph = GraphTypeBuilder.forGraphType(DefaultGraphType.dag()).buildGraph(); @@ -122,18 +123,18 @@ public void testFRBHWithThetaZero() { * check to see if mapTwo and mapThree (the ones that used the BarnesHut optimization) returned * similar results */ - @AfterClass + @AfterAll public static void check() { log.debug("mapOne:{}", mapOne); log.debug("mapThree:{}", mapThree); log.debug("mapFour:{}", mapFour); - Assert.assertEquals(mapOne.keySet(), mapFour.keySet()); + assertEquals(mapOne.keySet(), mapFour.keySet()); for (String key : mapOne.keySet()) { Point p2 = mapOne.get(key); Point p3 = mapFour.get(key); - Assert.assertTrue(Math.abs(p2.x - p3.x) < 1.0E-3); - Assert.assertTrue(Math.abs(p2.y - p3.y) < 1.0E-3); + assertTrue(Math.abs(p2.x - p3.x) < 1.0E-3); + assertTrue(Math.abs(p2.y - p3.y) < 1.0E-3); } } diff --git a/jungrapht-visualization/pom.xml b/jungrapht-visualization/pom.xml index 75ef5ab1e..f9e97245c 100644 --- a/jungrapht-visualization/pom.xml +++ b/jungrapht-visualization/pom.xml @@ -37,8 +37,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/LayoutAlgorithmTransitionTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/LayoutAlgorithmTransitionTest.java index 4c0281975..5f617ccfa 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/LayoutAlgorithmTransitionTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/LayoutAlgorithmTransitionTest.java @@ -6,7 +6,7 @@ import org.jungrapht.visualization.layout.algorithms.LayoutAlgorithm; import org.jungrapht.visualization.layout.algorithms.StaticLayoutAlgorithm; import org.jungrapht.visualization.layout.model.LayoutModel; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class LayoutAlgorithmTransitionTest { diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/ShapeTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/ShapeTest.java index 13a205a03..f62386367 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/ShapeTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/ShapeTest.java @@ -2,7 +2,7 @@ import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/SpatialRTreeTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/SpatialRTreeTest.java index 0f53e8000..d5a74e09f 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/SpatialRTreeTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/SpatialRTreeTest.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization; +import static org.junit.jupiter.api.Assertions.*; + import java.awt.*; import java.util.Collection; import java.util.stream.IntStream; @@ -12,9 +14,8 @@ import org.jungrapht.visualization.layout.util.VertexAccessor; import org.jungrapht.visualization.spatial.Spatial; import org.jungrapht.visualization.spatial.rtree.TreeNode; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,7 +33,7 @@ public class SpatialRTreeTest { LayoutModel layoutModel; Spatial tree; - @Before + @BeforeEach public void setup() { // generate 100 random nodes in a graph at random locations in the layoutModel this.graph = Pseudograph.createBuilder(Integer.class).build(); @@ -62,7 +63,7 @@ public void testRandomPointsAndLocations() { Collection pointQuadTrees = tree.getContainingLeafs(location.x, location.y); TreeNode nodeQuadTree = tree.getContainingLeaf(node); - Assert.assertTrue(pointQuadTrees.contains(nodeQuadTree)); + assertTrue(pointQuadTrees.contains(nodeQuadTree)); } } @@ -106,7 +107,7 @@ public void testClosestVertices() { log.warn("the cell for winnerTwo {} is {}", winnerTwo, tree.getContainingLeaf(winnerTwo)); log.warn("the cell for the search point {},{} is {}", x, y, tree.getContainingLeafs(x, y)); } - Assert.assertEquals(winnerOne, winnerTwo); + assertEquals(winnerOne, winnerTwo); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/TestImageShaper.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/TestImageShaper.java index 4544f814f..8f9e8bcbe 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/TestImageShaper.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/TestImageShaper.java @@ -3,16 +3,16 @@ import java.awt.Shape; import java.awt.geom.PathIterator; import java.awt.image.BufferedImage; -import junit.framework.TestCase; import org.jungrapht.visualization.util.ImageShapeUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class TestImageShaper extends TestCase { +public class TestImageShaper { BufferedImage image; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + public void setUp() { int width = 6; int height = 5; image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); @@ -31,6 +31,7 @@ protected void setUp() throws Exception { image.setRGB(4, 3, 0xffffffff); } + @Test public void testShaper() { Shape shape = ImageShapeUtils.getShape(image, 30); // System.err.println("complete shape = "+shape); diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/VisualizationServerTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/VisualizationServerTest.java index 88e2bb67e..8bea794e3 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/VisualizationServerTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/VisualizationServerTest.java @@ -1,13 +1,13 @@ package org.jungrapht.visualization; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.awt.*; import org.jgrapht.Graph; import org.jgrapht.graph.DirectedPseudograph; import org.jungrapht.visualization.layout.algorithms.CircleLayoutAlgorithm; import org.jungrapht.visualization.selection.MutableSelectedState; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class VisualizationServerTest { diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/EiglspergerTests.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/EiglspergerTests.java index 551ac8f45..ec3663618 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/EiglspergerTests.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/EiglspergerTests.java @@ -14,8 +14,8 @@ import org.jungrapht.visualization.layout.algorithms.sugiyama.LE; import org.jungrapht.visualization.layout.algorithms.sugiyama.LV; import org.jungrapht.visualization.layout.algorithms.sugiyama.TransformedGraphSupplier; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +31,7 @@ public class EiglspergerTests { EiglspergerStepsForward stepsForward; EiglspergerStepsBackward stepsBackward; - @Before + @BeforeEach public void setup() { buildGraph(); createLayers(); diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestInsertionOrderSplayTree.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestInsertionOrderSplayTree.java index 1a37a283c..33e6e50cf 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestInsertionOrderSplayTree.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestInsertionOrderSplayTree.java @@ -6,7 +6,7 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.stream.IntStream; import org.jungrapht.visualization.layout.algorithms.util.Pair; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestSmallGraph.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestSmallGraph.java index 9a1770cbf..13027f6d1 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestSmallGraph.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/TestSmallGraph.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.eiglsperger; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -14,9 +16,8 @@ import org.jungrapht.visualization.layout.algorithms.sugiyama.LE; import org.jungrapht.visualization.layout.algorithms.sugiyama.LV; import org.jungrapht.visualization.layout.algorithms.sugiyama.TransformedGraphSupplier; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class TestSmallGraph { @@ -24,7 +25,7 @@ public class TestSmallGraph { private Graph, LE> svGraph; private NeighborCache, LE> neighborCache; - @Before + @BeforeEach public void setup() { graph = createInitialGraph(); } @@ -40,10 +41,10 @@ public void testEiglsperger() { Collection> feedbackArcs = greedyCycleRemoval.getFeedbackArcs(); // should be no feedback arcs in this graph - Assert.assertEquals(0, feedbackArcs.size()); + assertEquals(0, feedbackArcs.size()); List>> layers = GraphLayers.assign(svGraph); - Assert.assertEquals(5, layers.size()); + assertEquals(5, layers.size()); Synthetics synthetics = new Synthetics<>(svGraph); List> edges = new ArrayList<>(svGraph.edgeSet()); @@ -75,10 +76,10 @@ public void testEiglspergerWithGraph() { Collection> feedbackArcs = greedyCycleRemoval.getFeedbackArcs(); // should be no feedback arcs in this graph - Assert.assertEquals(0, feedbackArcs.size()); + assertEquals(0, feedbackArcs.size()); List>> layers = GraphLayers.assign(svGraph); - Assert.assertEquals(5, layers.size()); + assertEquals(5, layers.size()); Synthetics synthetics = new Synthetics<>(svGraph); List> edges = new ArrayList<>(svGraph.edgeSet()); @@ -101,37 +102,37 @@ public void testEiglspergerWithGraph() { } private void checkLayersArray(LV[][] layersArray) { - Assert.assertEquals(5, layersArray.length); + assertEquals(5, layersArray.length); LV[] layer = layersArray[0]; - Assert.assertEquals(1, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(0, (int) layer[0].getVertex()); + assertEquals(1, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(0, layer[0].getVertex()); layer = layersArray[1]; - Assert.assertEquals(2, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(1, (int) layer[0].getVertex()); - Assert.assertTrue(layer[1] instanceof PVertex); + assertEquals(2, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(1, layer[0].getVertex()); + assertInstanceOf(PVertex.class, layer[1]); layer = layersArray[2]; - Assert.assertEquals(3, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(2, (int) layer[0].getVertex()); - Assert.assertTrue(layer[1] instanceof SyntheticLV); - Assert.assertTrue(layer[2] instanceof PVertex); + assertEquals(3, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(2, layer[0].getVertex()); + assertInstanceOf(SyntheticLV.class, layer[1]); + assertInstanceOf(PVertex.class, layer[2]); layer = layersArray[3]; - Assert.assertEquals(4, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(3, (int) layer[0].getVertex()); - Assert.assertTrue(layer[1] instanceof QVertex); - Assert.assertTrue(layer[2] instanceof QVertex); - Assert.assertTrue(layer[3] instanceof SyntheticLV); + assertEquals(4, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(3, layer[0].getVertex()); + assertInstanceOf(QVertex.class, layer[1]); + assertInstanceOf(QVertex.class, layer[2]); + assertInstanceOf(SyntheticLV.class, layer[3]); layer = layersArray[4]; - Assert.assertEquals(1, layer.length); - Assert.assertTrue(layer[0] instanceof LV); - Assert.assertEquals(4, (int) layer[0].getVertex()); + assertEquals(1, layer.length); + assertInstanceOf(LV.class, layer[0]); + assertEquals(4, layer[0].getVertex()); } private Graph createInitialGraph() { diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AccumulatorTreeCrossCountingTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AccumulatorTreeCrossCountingTest.java index 35596cf98..634e6498b 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AccumulatorTreeCrossCountingTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AccumulatorTreeCrossCountingTest.java @@ -1,13 +1,14 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.jungrapht.visualization.layout.algorithms.util.InsertionSortCounter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,7 +74,7 @@ public void runTest() { Collections.shuffle(edges); log.info("shuffled edges: {}", edges); int count = crossingCount(edges); - Assert.assertEquals(12, count); + assertEquals(12, count); } @Test diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java index de5eb6ee6..040d45d42 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java @@ -1,7 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BiLayerCrossCountingTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BiLayerCrossCountingTest.java index 0c1f1111d..968eab10e 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BiLayerCrossCountingTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BiLayerCrossCountingTest.java @@ -1,13 +1,14 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.jungrapht.visualization.layout.algorithms.util.InsertionSortCounter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,7 +74,7 @@ public void runTest() { Collections.shuffle(edges); log.info("shuffled edges: {}", edges); int count = crossingCount(edges); - Assert.assertEquals(12, count); + assertEquals(12, count); } @Test diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BrandesKopfTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BrandesKopfTest.java index e83a054dd..195fcaede 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BrandesKopfTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/BrandesKopfTest.java @@ -1,13 +1,14 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import java.util.HashSet; import java.util.stream.IntStream; import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,7 +86,7 @@ void createDelegateGraph() { svGraph = new TransformedGraphSupplier<>(graph).get(); } - @Before + @BeforeEach public void setup() { createInitialGraph(); } @@ -95,17 +96,17 @@ public void makeBrandesKopf() { BrandesKopf brandesKopf = new BrandesKopf(graph); svGraph = brandesKopf.svGraph; LV[][] layers = brandesKopf.layersArray; - Assert.assertEquals(10, layers.length); - Assert.assertEquals(2, layers[0].length); - Assert.assertEquals(5, layers[1].length); - Assert.assertEquals(6, layers[2].length); - Assert.assertEquals(6, layers[3].length); - Assert.assertEquals(8, layers[4].length); - Assert.assertEquals(9, layers[5].length); - Assert.assertEquals(9, layers[6].length); - Assert.assertEquals(7, layers[7].length); - Assert.assertEquals(4, layers[8].length); - Assert.assertEquals(1, layers[9].length); + assertEquals(10, layers.length); + assertEquals(2, layers[0].length); + assertEquals(5, layers[1].length); + assertEquals(6, layers[2].length); + assertEquals(6, layers[3].length); + assertEquals(8, layers[4].length); + assertEquals(9, layers[5].length); + assertEquals(9, layers[6].length); + assertEquals(7, layers[7].length); + assertEquals(4, layers[8].length); + assertEquals(1, layers[9].length); HorizontalCoordinateAssignment horizontalCoordinateAssignment = new HorizontalCoordinateAssignment<>(layers, svGraph, new HashSet<>(), 20, 20); diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestAccumulatorTree.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestAccumulatorTree.java index 759fa4cb8..c6872bc45 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestAccumulatorTree.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestAccumulatorTree.java @@ -1,14 +1,15 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import org.jungrapht.visualization.layout.algorithms.util.InsertionSortCounter; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,7 +61,7 @@ public class TestAccumulatorTree { AccumulatorTree tree; - @Before + @BeforeEach public void setup() { log.info("edges: {}", edges); Collections.shuffle(edges); @@ -85,7 +86,7 @@ public void testCount() { int countIS = InsertionSortCounter.insertionSortCounter(targetIndices); log.info("countIS is :{}", countIS); - Assert.assertEquals(countIS, count); + assertEquals(countIS, count); } @Test @@ -109,7 +110,7 @@ public void testCountReversed() { int countIS = InsertionSortCounter.insertionSortCounter(sourceIndices); log.info("countIS is :{}", countIS); - Assert.assertEquals(countIS, count); + assertEquals(countIS, count); // swap the edge endpoints and run the count on the target indices edges = swapEdgeEndpoints(edges); @@ -128,10 +129,10 @@ public void testCountReversed() { countIS = InsertionSortCounter.insertionSortCounter(targetIndices); log.info("countIS is :{}", countIS); - Assert.assertEquals(countIS, count); + assertEquals(countIS, count); } - // Assert.assertEquals(countIS, count); + // assertEquals(countIS, count); // } private static List> swapEdgeEndpoints(List> list) { @@ -168,7 +169,7 @@ public void testWeighted() { int countIS = InsertionSortCounter.insertionSortCounter(targetIndices); log.info("countIS is :{}", countIS); - Assert.assertEquals(countIS, countWeight); + assertEquals(countIS, countWeight); } @Test @@ -184,7 +185,7 @@ public void testWeighted2() { int countWeight = tree.crossWeight(targetIndices, i -> 2); log.info("countWeight is :{}", countWeight); - Assert.assertEquals(48, countWeight); + assertEquals(48, countWeight); int countIS = InsertionSortCounter.insertionSortCounter(targetIndices); log.info("countIS is :{}", countIS); diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java index f25dbb73f..66d5873de 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java @@ -1,9 +1,10 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import org.jungrapht.visualization.layout.util.synthetics.SVI; import org.jungrapht.visualization.layout.util.synthetics.Synthetic; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestDelegateVerticesAndEdges { @@ -15,12 +16,12 @@ public void testVertices() { LV sa = LV.of(a); LV sb = LV.of(b); - Assert.assertTrue(sa instanceof SVI); - Assert.assertNotEquals(sa, sb); - Assert.assertEquals(sa, LV.of("a")); + assertInstanceOf(SVI.class, sa); + assertNotEquals(sa, sb); + assertEquals(sa, LV.of("a")); LV syntheticA = new SyntheticLV<>(); - Assert.assertNotEquals(syntheticA, sa); - Assert.assertTrue(syntheticA instanceof Synthetic); + assertNotEquals(syntheticA, sa); + assertInstanceOf(Synthetic.class, syntheticA); } @Test @@ -35,10 +36,10 @@ public void testEdges() { LE se1 = LE.of(edge1, sa, sb); LE se2 = LE.of(edge2, sa, sc); LE se3 = LE.of(2, sa, sc); - Assert.assertTrue(se1 instanceof LEI); - Assert.assertTrue(se2 instanceof LEI); - Assert.assertNotEquals(se1, se2); - Assert.assertEquals(se2, se3); - Assert.assertTrue(new SyntheticLE<>(se1, sa, sb) instanceof Synthetic); + assertInstanceOf(LEI.class, se1); + assertInstanceOf(LEI.class, se2); + assertNotEquals(se1, se2); + assertEquals(se2, se3); + assertInstanceOf(Synthetic.class, new SyntheticLE<>(se1, sa, sb)); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestGreedyCycleRemoval.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestGreedyCycleRemoval.java index 4a681f5e0..86b1f1433 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestGreedyCycleRemoval.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestGreedyCycleRemoval.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Collection; import java.util.Set; import org.jgrapht.Graph; @@ -7,9 +9,8 @@ import org.jgrapht.graph.builder.GraphBuilder; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +19,7 @@ public class TestGreedyCycleRemoval { private static final Logger log = LoggerFactory.getLogger(TestGreedyCycleRemoval.class); Graph graph; - @Before + @BeforeEach public void setup() { graph = GraphTypeBuilder.directed() @@ -50,7 +51,7 @@ public void testCycleRemoval() { GreedyCycleRemoval gcr = new GreedyCycleRemoval<>(graph); - Assert.assertTrue(gcr.getFeedbackArcs().containsAll(Set.of(8))); + assertTrue(gcr.getFeedbackArcs().containsAll(Set.of(8))); } @Test @@ -60,7 +61,7 @@ public void anotherTest() { GreedyCycleRemoval gcr = new GreedyCycleRemoval<>(graph); log.info("reverseArcs: {}", gcr.getFeedbackArcs()); - Assert.assertTrue(gcr.getFeedbackArcs().containsAll(Set.of(122, 109))); + assertTrue(gcr.getFeedbackArcs().containsAll(Set.of(122, 109))); } public static Graph generateProgramGraph2() { @@ -128,8 +129,8 @@ public void smallTest() { graph.addEdge("D", "B"); // introduces a cycle log.info("graph: {}", graph); - Assert.assertEquals(graph.getEdgeSource(3), "D"); - Assert.assertEquals(graph.getEdgeTarget(3), "B"); + assertEquals("D", graph.getEdgeSource(3)); + assertEquals("B", graph.getEdgeTarget(3)); TransformedGraphSupplier transformedGraphSupplier = new TransformedGraphSupplier(graph); diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestLevelCross.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestLevelCross.java index 5f7bb841a..0a6924970 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestLevelCross.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestLevelCross.java @@ -1,9 +1,10 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +94,7 @@ public void testLevelCross5() { // should be 1 edgeList.add(LE.of(e++, c, y)); // trt edgeList.add(LE.of(e++, a, y)); - Assert.assertEquals(1, go()); + assertEquals(1, go()); } @Test @@ -113,7 +114,7 @@ public void testLevelCross6() { //1 edgeList.add(LE.of(e++, b, x)); edgeList.add(LE.of(e++, c, y)); edgeList.add(LE.of(e++, a, y)); - assert 1 == go(); + assertEquals(1, go()); } @Test @@ -135,7 +136,7 @@ public void testLevelCross7() { // 3 edgeList.add(LE.of(e++, a, y)); // trb edgeList.add(LE.of(e++, c, z)); - Assert.assertEquals(3, go()); + assertEquals(3, go()); } @Test @@ -152,7 +153,7 @@ public void testLevelCross8() { // 0 edgeList.add(LE.of(e++, a, z)); edgeList.add(LE.of(e++, c, y)); edgeList.add(LE.of(e++, a, y)); - Assert.assertEquals(0, go()); + assertEquals(0, go()); } @Test @@ -170,7 +171,7 @@ public void testLevelCross9() { // 1 edgeList.add(LE.of(e++, c, y)); edgeList.add(LE.of(e++, a, y)); edgeList.add(LE.of(e++, c, z)); - Assert.assertEquals(1, go()); + assertEquals(1, go()); } @Test @@ -185,7 +186,7 @@ public void testLevelCross10() { // 1 edgeList.add(LE.of(e++, a, x)); edgeList.add(LE.of(e++, b, z)); - Assert.assertEquals(1, go()); + assertEquals(1, go()); } @Test @@ -204,7 +205,7 @@ public void testLevelCross11() { // should be 1 edgeList.add(LE.of(e++, b, x)); edgeList.add(LE.of(e++, c, y)); edgeList.add(LE.of(e++, c, z)); - Assert.assertEquals(1, go()); + assertEquals(1, go()); } private int go() { diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestSugiyamaFunctions.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestSugiyamaFunctions.java index 2c8a84d25..58a7ca766 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestSugiyamaFunctions.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestSugiyamaFunctions.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -12,9 +14,8 @@ import org.jungrapht.visualization.layout.util.synthetics.SE; import org.jungrapht.visualization.layout.util.synthetics.SV; import org.jungrapht.visualization.layout.util.synthetics.SVTransformedGraphSupplier; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +25,7 @@ public class TestSugiyamaFunctions { Graph graph; - @Before + @BeforeEach public void setup() { // build a DAG graph = @@ -56,8 +57,8 @@ public void testTransformedGraph() { new SVTransformedGraphSupplier(graph); Graph, SE> sgraph = svTransformedGraphSupplier.get(); - Assert.assertEquals(graph.vertexSet().size(), sgraph.vertexSet().size()); - Assert.assertEquals(graph.edgeSet().size(), sgraph.edgeSet().size()); + assertEquals(graph.vertexSet().size(), sgraph.vertexSet().size()); + assertEquals(graph.edgeSet().size(), sgraph.edgeSet().size()); Set verticesCopy = new HashSet<>(graph.vertexSet()); Set edgesCopy = new HashSet<>(graph.edgeSet()); @@ -65,18 +66,18 @@ public void testTransformedGraph() { .vertexSet() .forEach( v -> { - Assert.assertTrue(graph.containsVertex(v.getVertex())); + assertTrue(graph.containsVertex(v.getVertex())); verticesCopy.remove(v.getVertex()); }); - Assert.assertTrue(verticesCopy.isEmpty()); + assertTrue(verticesCopy.isEmpty()); sgraph .edgeSet() .forEach( e -> { - Assert.assertTrue(graph.containsEdge(e.getEdge())); + assertTrue(graph.containsEdge(e.getEdge())); edgesCopy.remove(e.getEdge()); }); - Assert.assertTrue(edgesCopy.isEmpty()); + assertTrue(edgesCopy.isEmpty()); } @Test @@ -88,7 +89,7 @@ public void testAssignLayers() { List>> layers = GraphLayers.assign(sgraph); - Assert.assertEquals(3, layers.size()); // this graph should have 3 layers + assertEquals(3, layers.size()); // this graph should have 3 layers this.checkLayers(layers); log.info("assign layers:"); @@ -107,7 +108,7 @@ public void testAssignLayers() { } log.info("there are {} edges ", edges.size()); log.info("edges: {}", edges); - Assert.assertEquals(graph.edgeSet().size(), edges.size() - 1); + assertEquals(graph.edgeSet().size(), edges.size() - 1); checkLayers(layers); } @@ -147,7 +148,7 @@ public void testAssignLayersWithDoubleSkip() { log.info("edges: {}", edges); log.info("graph.edgeSet(): {}", graph.edgeSet()); log.info("edges.size(): {}", edges.size()); - Assert.assertEquals(graph.edgeSet().size(), edges.size() - 3); + assertEquals(graph.edgeSet().size(), edges.size() - 3); checkLayers(layers); log.info("outgoing dag: {}", sgraph.toString()); @@ -188,7 +189,7 @@ public void testAssignLayersWithDoubleSkip() { .map(v -> (SyntheticLV) v) .collect(Collectors.toList()); - Assert.assertEquals(3, virtualVertices.size()); + assertEquals(3, virtualVertices.size()); synthetics.makeArticulatedEdges(); @@ -203,14 +204,14 @@ public void testAssignLayersWithDoubleSkip() { && ((ArticulatedEdge) e).getIntermediateVertices().size() == 2) .map(e -> (ArticulatedEdge) e) .collect(Collectors.toList()); - Assert.assertEquals(1, articulatedEdges.size()); + assertEquals(1, articulatedEdges.size()); ArticulatedEdge bentEdge = articulatedEdges.get(0); List ranks = new ArrayList<>(); ranks.add(bentEdge.source.getRank()); ranks.addAll( bentEdge.getIntermediateVertices().stream().map(LV::getRank).collect(Collectors.toList())); ranks.add(bentEdge.target.getRank()); - Assert.assertEquals(ranks, List.of(0, 1, 2, 3)); + assertEquals(ranks, List.of(0, 1, 2, 3)); // test that one edge has 1 intermediate vertex articulatedEdges = @@ -223,14 +224,14 @@ public void testAssignLayersWithDoubleSkip() { && ((ArticulatedEdge) e).getIntermediateVertices().size() == 1) .map(e -> (ArticulatedEdge) e) .collect(Collectors.toList()); - Assert.assertEquals(1, articulatedEdges.size()); + assertEquals(1, articulatedEdges.size()); bentEdge = articulatedEdges.get(0); ranks = new ArrayList<>(); ranks.add(bentEdge.source.getRank()); ranks.addAll( bentEdge.getIntermediateVertices().stream().map(LV::getRank).collect(Collectors.toList())); ranks.add(bentEdge.target.getRank()); - Assert.assertEquals(ranks, List.of(0, 1, 2)); + assertEquals(ranks, List.of(0, 1, 2)); log.info("dag vertices: {}", sgraph.vertexSet()); log.info("dag edges: {}", sgraph.edgeSet()); @@ -264,15 +265,15 @@ private void checkLayers(List>> layers) { for (int j = 0; j < layer.size(); j++) { LV LV = layer.get(j); log.info("sv {},{}: {}", i, j, LV); - Assert.assertEquals(i, LV.getRank()); - Assert.assertEquals(j, LV.getIndex()); + assertEquals(i, LV.getRank()); + assertEquals(j, LV.getIndex()); } } } private void testConsecutive(int[] array) { for (int i = 0; i < array.length - 1; i++) { - Assert.assertEquals(array[i] + 1, array[i + 1]); + assertEquals(array[i] + 1, array[i + 1]); } } @@ -295,37 +296,37 @@ public void testInsertionSortCounter() { int[] array = new int[] {0, 1, 2, 3, 4, 5}; int count = insertionSortCounter(array); log.info("count is {}", count); - Assert.assertEquals(0, count); + assertEquals(0, count); array = new int[] {0, 1, 2, 0, 3, 4, 0, 2, 3, 2, 4}; count = insertionSortCounter(array); log.info("count is {}", count); - Assert.assertEquals(12, count); + assertEquals(12, count); array = new int[] {0, 1, 3, 1, 2}; count = insertionSortCounter(array); log.info("count is {}", count); - Assert.assertEquals(2, count); + assertEquals(2, count); array = new int[] {1, 2, 0, 1, 3}; count = insertionSortCounter(array); log.info("count is {}", count); - Assert.assertEquals(3, count); + assertEquals(3, count); List list = Arrays.asList(0, 1, 2, 0, 3, 4, 0, 2, 3, 2, 4); count = insertionSortCounter(list); log.info("count is {}", count); - Assert.assertEquals(12, count); + assertEquals(12, count); list = Arrays.asList(0, 1, 3, 1, 2); count = insertionSortCounter(list); log.info("count is {}", count); - Assert.assertEquals(2, count); + assertEquals(2, count); list = Arrays.asList(1, 2, 0, 1, 3); count = insertionSortCounter(list); log.info("count is {}", count); - Assert.assertEquals(3, count); + assertEquals(3, count); } private int insertionSortCounter(List list) { @@ -377,6 +378,6 @@ public void testRemoveCycles() { graph.removeEdge("20", "10"); graph.removeEdge("21", "11"); graph.removeEdge("20", "00"); - Assert.assertEquals(graph, dag); + assertEquals(graph, dag); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestTransformingGraphView.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestTransformingGraphView.java index 7d8ec36e3..71662e415 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestTransformingGraphView.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestTransformingGraphView.java @@ -1,12 +1,13 @@ package org.jungrapht.visualization.layout.algorithms.sugiyama; +import static org.junit.jupiter.api.Assertions.*; + import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; import org.jungrapht.visualization.layout.util.synthetics.SingletonTransformer; import org.jungrapht.visualization.layout.util.synthetics.TransformingGraphView; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestTransformingGraphView { @@ -42,9 +43,9 @@ public void testRoundTrip() { Graph transformedBackGraph = transformingGraphView.build(); - Assert.assertTrue(graph.vertexSet().containsAll(transformedBackGraph.vertexSet())); - Assert.assertTrue(graph.edgeSet().containsAll(transformedBackGraph.edgeSet())); + assertTrue(graph.vertexSet().containsAll(transformedBackGraph.vertexSet())); + assertTrue(graph.edgeSet().containsAll(transformedBackGraph.edgeSet())); - Assert.assertEquals(transformedBackGraph.getEdge("a", "b"), graph.getEdge("a", "b")); + assertEquals(transformedBackGraph.getEdge("a", "b"), graph.getEdge("a", "b")); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestComponentGrouping.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestComponentGrouping.java index 1a6ba4a7c..c837f2e55 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestComponentGrouping.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestComponentGrouping.java @@ -5,8 +5,8 @@ import org.jgrapht.graph.DefaultGraphType; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,7 +16,7 @@ public class TestComponentGrouping { Graph graph; - @Before + @BeforeEach public void setup() { this.graph = GraphTypeBuilder.forGraphType(DefaultGraphType.multigraph()) diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestInsertionSortCounter.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestInsertionSortCounter.java index 1633db1ec..de1390df1 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestInsertionSortCounter.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestInsertionSortCounter.java @@ -3,8 +3,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,7 +16,7 @@ public class TestInsertionSortCounter { List list = Arrays.asList(8, 2, 8, 5, 3, 7, 9, 2, 5, 4, 8, 4, 9); - @Before + @BeforeEach public void setup() { int size = 1000; array = new int[size]; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplex.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplex.java index eed11d79a..23b25bbd6 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplex.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplex.java @@ -8,7 +8,7 @@ import org.jungrapht.visualization.layout.algorithms.sugiyama.LE; import org.jungrapht.visualization.layout.algorithms.sugiyama.LV; import org.jungrapht.visualization.layout.algorithms.sugiyama.TransformedGraphSupplier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFive.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFive.java index 411ba70a5..cd9c85eec 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFive.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFive.java @@ -3,7 +3,7 @@ import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFour.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFour.java index 79096bf35..30ddccdfc 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFour.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexFour.java @@ -1,12 +1,13 @@ package org.jungrapht.visualization.layout.algorithms.util; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.Map; import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,18 +31,18 @@ public void computeCutValues() { Map.of(2, 3, 3, 3, 4, 0, 5, 0, 6, 3, 7, -1, 8, 3); // preliminary cut value map. check to make sure it matches values in the paper Map cutValueMap = networkSimplexDevelopment.getEdgeCutValues(spanningTree); - Assert.assertEquals(expectedFirstCutValueMap, cutValueMap); + assertEquals(expectedFirstCutValueMap, cutValueMap); Graph best = networkSimplexDevelopment.getTheBestSpanningTree(); cutValueMap = networkSimplexDevelopment.getEdgeCutValues(spanningTree); Map expectedSecondCutValueMap = Map.of(0, 1, 2, 2, 3, 2, 4, 1, 5, 0, 6, 2, 8, 2); - Assert.assertEquals(expectedSecondCutValueMap, cutValueMap); + assertEquals(expectedSecondCutValueMap, cutValueMap); log.info("bestSpanningTree: {}", best); - Assert.assertTrue(best.edgeSet().containsAll(List.of(0, 2, 3, 4, 5, 6, 8))); - Assert.assertFalse(best.containsEdge(1)); - Assert.assertFalse(best.containsEdge(7)); + assertTrue(best.edgeSet().containsAll(List.of(0, 2, 3, 4, 5, 6, 8))); + assertFalse(best.containsEdge(1)); + assertFalse(best.containsEdge(7)); } /** build the graph and the spanning tree shown in the paper */ diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexOne.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexOne.java index c6e021177..6adb4d24d 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexOne.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexOne.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.util; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -11,8 +13,7 @@ import org.jgrapht.graph.AbstractBaseGraph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,12 +69,12 @@ public void computeCutValues() { spanningTree.addEdge("d", "h", dh); Map cutValues = getEdgeCutValues(dag, spanningTree); - Assert.assertEquals(-1, (int) cutValues.get(7)); - Assert.assertEquals(3, (int) cutValues.get(2)); - Assert.assertEquals(3, (int) cutValues.get(3)); - Assert.assertEquals(0, (int) cutValues.get(4)); - Assert.assertEquals(3, (int) cutValues.get(6)); - Assert.assertEquals(3, (int) cutValues.get(8)); + assertEquals(-1, cutValues.get(7)); + assertEquals(3, cutValues.get(2)); + assertEquals(3, cutValues.get(3)); + assertEquals(0, cutValues.get(4)); + assertEquals(3, cutValues.get(6)); + assertEquals(3, cutValues.get(8)); // if there is a negative value... List values = new ArrayList<>(cutValues.values()); values.sort(Integer::compareTo); @@ -109,9 +110,9 @@ public void computeCutValues() { } } log.info("bestSpanningTree: {}", spanningTree); - Assert.assertTrue(spanningTree.edgeSet().containsAll(List.of(0, 2, 3, 4, 5, 6, 8))); - Assert.assertFalse(spanningTree.containsEdge(1)); - Assert.assertFalse(spanningTree.containsEdge(7)); + assertTrue(spanningTree.edgeSet().containsAll(List.of(0, 2, 3, 4, 5, 6, 8))); + assertFalse(spanningTree.containsEdge(1)); + assertFalse(spanningTree.containsEdge(7)); } Map getEdgeCutValues( diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexSix.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexSix.java index 36b170b94..73f7a9bbe 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexSix.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexSix.java @@ -4,7 +4,7 @@ import org.jgrapht.graph.DefaultGraphType; import org.jgrapht.graph.builder.GraphBuilder; import org.jgrapht.graph.builder.GraphTypeBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexThree.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexThree.java index c03e8e10a..190a847f9 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexThree.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/TestNetworkSimplexThree.java @@ -3,7 +3,7 @@ import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java index 304ae2fa3..5361a79b0 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java @@ -1,8 +1,9 @@ package org.jungrapht.visualization.layout.algorithms.util.synthetics; +import static org.junit.jupiter.api.Assertions.*; + import org.jungrapht.visualization.layout.util.synthetics.SingletonTransformer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test to ensure that keys return expected values, that a second transformation of the same key @@ -19,12 +20,12 @@ public void test() { int got2 = singletonTransformer.apply(1); int got3 = singletonTransformer.apply(2); - Assert.assertEquals(2, got2); - Assert.assertEquals(3, got3); + assertEquals(2, got2); + assertEquals(3, got3); int gotDupe = singletonTransformer.apply(1); - Assert.assertTrue(gotDupe == got2); + assertTrue(gotDupe == got2); - Assert.assertEquals(2, singletonTransformer.getTransformedMap().size()); + assertEquals(2, singletonTransformer.getTransformedMap().size()); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java index 1717a78e6..f7c8a32fc 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.util.synthetics; +import static org.junit.jupiter.api.Assertions.*; + import org.jungrapht.visualization.layout.util.synthetics.SE; import org.jungrapht.visualization.layout.util.synthetics.SEI; import org.jungrapht.visualization.layout.util.synthetics.SV; @@ -7,8 +9,7 @@ import org.jungrapht.visualization.layout.util.synthetics.Synthetic; import org.jungrapht.visualization.layout.util.synthetics.SyntheticSE; import org.jungrapht.visualization.layout.util.synthetics.SyntheticSV; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestDelegateVerticesAndEdges { @@ -20,12 +21,12 @@ public void testVertices() { SV sa = SV.of(a); SV sb = SV.of(b); - Assert.assertTrue(sa instanceof SVI); - Assert.assertNotEquals(sa, sb); - Assert.assertEquals(sa, SV.of("a")); + assertInstanceOf(SVI.class, sa); + assertNotEquals(sa, sb); + assertEquals(sa, SV.of("a")); SV syntheticA = new SyntheticSV(); - Assert.assertNotEquals(syntheticA, sa); - Assert.assertTrue(syntheticA instanceof Synthetic); + assertNotEquals(syntheticA, sa); + assertInstanceOf(Synthetic.class, syntheticA); } @Test @@ -37,10 +38,10 @@ public void testEdges() { SE se1 = SE.of(edge1); SE se2 = SE.of(edge2); SE se3 = SE.of(2); - Assert.assertTrue(se1 instanceof SEI); - Assert.assertTrue(se2 instanceof SEI); - Assert.assertNotEquals(se1, se2); - Assert.assertEquals(se2, se3); - Assert.assertTrue(new SyntheticSE<>() instanceof Synthetic); + assertInstanceOf(SEI.class, se1); + assertInstanceOf(SEI.class, se2); + assertNotEquals(se1, se2); + assertEquals(se2, se3); + assertInstanceOf(Synthetic.class, new SyntheticSE<>()); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestTransformingGraphView.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestTransformingGraphView.java index 6c043e0c6..828e1cca3 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestTransformingGraphView.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestTransformingGraphView.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.layout.algorithms.util.synthetics; +import static org.junit.jupiter.api.Assertions.*; + import org.jgrapht.Graph; import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; @@ -8,8 +10,7 @@ import org.jungrapht.visualization.layout.util.synthetics.SVTransformedGraphSupplier; import org.jungrapht.visualization.layout.util.synthetics.SingletonTransformer; import org.jungrapht.visualization.layout.util.synthetics.TransformingGraphView; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestTransformingGraphView { @@ -45,9 +46,9 @@ public void testRoundTrip() { Graph transformedBackGraph = transformingGraphView.build(); - Assert.assertTrue(graph.vertexSet().containsAll(transformedBackGraph.vertexSet())); - Assert.assertTrue(graph.edgeSet().containsAll(transformedBackGraph.edgeSet())); + assertTrue(graph.vertexSet().containsAll(transformedBackGraph.vertexSet())); + assertTrue(graph.edgeSet().containsAll(transformedBackGraph.edgeSet())); - Assert.assertEquals(transformedBackGraph.getEdge("a", "b"), graph.getEdge("a", "b")); + assertEquals(transformedBackGraph.getEdge("a", "b"), graph.getEdge("a", "b")); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/quadtree/BarnesHutQuadTreeTests.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/quadtree/BarnesHutQuadTreeTests.java index 5c12d84af..402a7fab4 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/quadtree/BarnesHutQuadTreeTests.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/quadtree/BarnesHutQuadTreeTests.java @@ -1,9 +1,10 @@ package org.jungrapht.visualization.layout.quadtree; +import static org.junit.jupiter.api.Assertions.*; + import org.jungrapht.visualization.layout.model.Point; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +19,7 @@ public class BarnesHutQuadTreeTests { private static final Logger log = LoggerFactory.getLogger(BarnesHutQuadTreeTests.class); private BarnesHutQuadTree tree; - @Before + @BeforeEach public void setup() { tree = BarnesHutQuadTree.builder().bounds(500, 500).build(); } @@ -38,7 +39,7 @@ public void testOne() { log.info("tree: {}", tree); ForceObject expectedForceObject = new ForceObject("force", 10, 10, 3); - Assert.assertEquals(tree.getRoot().getForceObject(), expectedForceObject); + assertEquals(tree.getRoot().getForceObject(), expectedForceObject); } /** test a simple construction */ @@ -54,16 +55,16 @@ public void testTwo() { tree.insert(forceObjectD); log.info("tree: {}", tree); - Assert.assertNotNull(tree.getRoot()); + assertNotNull(tree.getRoot()); Node root = tree.getRoot(); - Assert.assertFalse(root.isLeaf()); + assertFalse(root.isLeaf()); Node NW = root.NW; - Assert.assertEquals(NW.forceObject, forceObjectA.add(forceObjectB).add(forceObjectC)); - Assert.assertFalse(NW.isLeaf()); - Assert.assertEquals(NW.NW.forceObject, forceObjectC); - Assert.assertEquals(NW.NE.forceObject, forceObjectA); - Assert.assertEquals(NW.SW.forceObject, forceObjectB); - Assert.assertNull(NW.SE.forceObject); - Assert.assertEquals(root.NE.forceObject, forceObjectD); + assertEquals(NW.forceObject, forceObjectA.add(forceObjectB).add(forceObjectC)); + assertFalse(NW.isLeaf()); + assertEquals(NW.NW.forceObject, forceObjectC); + assertEquals(NW.NE.forceObject, forceObjectA); + assertEquals(NW.SW.forceObject, forceObjectB); + assertNull(NW.SE.forceObject); + assertEquals(root.NE.forceObject, forceObjectD); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/selection/MultiMutableSelectedStateTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/selection/MultiMutableSelectedStateTest.java index 4bc68c88c..8a86c4703 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/selection/MultiMutableSelectedStateTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/selection/MultiMutableSelectedStateTest.java @@ -1,11 +1,12 @@ package org.jungrapht.visualization.selection; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Collections; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +19,7 @@ public class MultiMutableSelectedStateTest { AtomicBoolean atomicBoolean = new AtomicBoolean(false); - @Before + @BeforeEach public void setup() { atomicBoolean.set(false); multiMutableSelectedState.clear(); @@ -33,9 +34,9 @@ public void testSelectOne() { multiMutableSelectedState.addItemListener( new SelectedState.StateChangeListener<>(this::selected, this::forbidden)); multiMutableSelectedState.select("A"); - Assert.assertTrue(multiMutableSelectedState.getSelected().contains("A")); - Assert.assertEquals(multiMutableSelectedState.getSelected(), Collections.singleton("A")); - Assert.assertTrue(atomicBoolean.get()); + assertTrue(multiMutableSelectedState.getSelected().contains("A")); + assertEquals(Collections.singleton("A"), multiMutableSelectedState.getSelected()); + assertTrue(atomicBoolean.get()); } /** Select 'reselection' of one item. Should not fire an event to select or deselect */ @@ -46,8 +47,8 @@ public void testSelectionOfOneAlreadySelected() { new SelectedState.StateChangeListener<>(this::forbidden, this::forbidden)); // pick the already selected item. Should not fire an event to select or deselect multiMutableSelectedState.select("A"); - Assert.assertEquals(multiMutableSelectedState.getSelected(), Collections.singleton("A")); - Assert.assertFalse(atomicBoolean.get()); + assertEquals(Collections.singleton("A"), multiMutableSelectedState.getSelected()); + assertFalse(atomicBoolean.get()); } /** @@ -59,8 +60,8 @@ public void testSelectMany() { multiMutableSelectedState.addItemListener( new SelectedState.StateChangeListener<>(this::selected, this::forbidden)); multiMutableSelectedState.select(Set.of("A", "B", "C")); - Assert.assertEquals(multiMutableSelectedState.getSelected(), Set.of("A", "B", "C")); - Assert.assertTrue(atomicBoolean.get()); + assertEquals(Set.of("A", "B", "C"), multiMutableSelectedState.getSelected()); + assertTrue(atomicBoolean.get()); } /** @@ -73,8 +74,8 @@ public void testToggleSelectionOfMany() { multiMutableSelectedState.addItemListener( new SelectedState.StateChangeListener<>(this::forbidden, this::forbidden)); multiMutableSelectedState.select(Set.of("A", "B", "C")); - Assert.assertEquals(multiMutableSelectedState.getSelected(), Set.of("A", "B", "C")); - Assert.assertFalse(atomicBoolean.get()); + assertEquals(Set.of("A", "B", "C"), multiMutableSelectedState.getSelected()); + assertFalse(atomicBoolean.get()); } /** @@ -87,9 +88,9 @@ public void testSelectOneWithExistingSelection() { multiMutableSelectedState.addItemListener( new SelectedState.StateChangeListener<>(this::selected, this::deselected)); multiMutableSelectedState.select("D"); - Assert.assertTrue(multiMutableSelectedState.getSelected().contains("D")); - Assert.assertEquals(multiMutableSelectedState.getSelected(), Set.of("A", "B", "C", "D")); - Assert.assertTrue(atomicBoolean.get()); + assertTrue(multiMutableSelectedState.getSelected().contains("D")); + assertEquals(Set.of("A", "B", "C", "D"), multiMutableSelectedState.getSelected()); + assertTrue(atomicBoolean.get()); } private void selected(Object item) { @@ -105,6 +106,6 @@ private void deselected(Object item) { } private void forbidden(Object item) { - Assert.fail("Should not have gotten " + item); + fail("Should not have gotten " + item); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/RTreeTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/RTreeTest.java index 75dd65857..e7a1b28bb 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/RTreeTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/RTreeTest.java @@ -1,6 +1,6 @@ package org.jungrapht.visualization.spatial; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.awt.geom.Rectangle2D; import org.jungrapht.visualization.spatial.rtree.LeafNode; @@ -10,7 +10,7 @@ import org.jungrapht.visualization.spatial.rtree.RTree; import org.jungrapht.visualization.spatial.rtree.SplitterContext; import org.jungrapht.visualization.spatial.rtree.TreeNode; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/RTreeTest2.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/RTreeTest2.java index 7e9eb2632..3ef4b62c0 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/RTreeTest2.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/RTreeTest2.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.spatial; +import static org.junit.jupiter.api.Assertions.*; + import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.ArrayList; @@ -19,9 +21,8 @@ import org.jungrapht.visualization.spatial.rtree.RTree; import org.jungrapht.visualization.spatial.rtree.SplitterContext; import org.jungrapht.visualization.spatial.rtree.TreeNode; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +44,7 @@ public class RTreeTest2 { private Rectangle2D r8; Map linkedMap = new LinkedHashMap<>(); - @Before + @BeforeEach public void before() { rTree = RTree.create(); r1 = new Rectangle2D.Double(100, 100, 100, 100); @@ -107,11 +108,11 @@ public void testOne() { @Test public void testAddOne() { rTree = RTree.add(rTree, splitterContext, "A", r1); - // Assert.assertTrue(rTree.level == 0); - Assert.assertTrue(rTree.getRoot().isPresent()); + // assertTrue(rTree.level == 0); + assertTrue(rTree.getRoot().isPresent()); Node root = rTree.getRoot().get(); - Assert.assertTrue(root instanceof LeafNode); - Assert.assertEquals(1, root.size()); + assertInstanceOf(LeafNode.class, root); + assertEquals(1, root.size()); testAreas(rTree); } @@ -213,15 +214,15 @@ public void testFindingElementsByLocation() { Point2D p = new Point2D.Double(r4.getX() + r4.getWidth() / 2, r4.getY() + r4.getHeight() / 2); Object found = rTree.getPickedObject(p); - Assert.assertEquals(found, "D"); + assertEquals(found, "D"); p = new Point2D.Double(r7.getX() + r7.getWidth() / 2, r7.getY() + r7.getHeight() / 2); found = rTree.getPickedObject(p); - Assert.assertEquals(found, "H"); + assertEquals(found, "H"); p = new Point2D.Double(r1.getX() + r1.getWidth() / 2, r1.getY() + r1.getHeight() / 2); found = rTree.getPickedObject(p); - Assert.assertEquals(found, "A"); + assertEquals(found, "A"); } // make sure the rectangle area in rTree is the same as the union of the areas @@ -240,10 +241,10 @@ private void testAreas(TreeNode rootVertex) { if (rootVertex instanceof InnerNode) { InnerNode innerVertex = (InnerNode) rootVertex; Rectangle2D unionBounds = Node.union(innerVertex.getChildren()); - Assert.assertTrue(Math.abs(rootBounds.getMinX() - unionBounds.getMinX()) < 1.0E-3); - Assert.assertTrue(Math.abs(rootBounds.getMinY() - unionBounds.getMinY()) < 1.0E-3); - Assert.assertTrue(Math.abs(rootBounds.getMaxX() - unionBounds.getMaxX()) < 1.0E-3); - Assert.assertTrue(Math.abs(rootBounds.getMaxY() - unionBounds.getMaxY()) < 1.0E-3); + assertTrue(Math.abs(rootBounds.getMinX() - unionBounds.getMinX()) < 1.0E-3); + assertTrue(Math.abs(rootBounds.getMinY() - unionBounds.getMinY()) < 1.0E-3); + assertTrue(Math.abs(rootBounds.getMaxX() - unionBounds.getMaxX()) < 1.0E-3); + assertTrue(Math.abs(rootBounds.getMaxY() - unionBounds.getMaxY()) < 1.0E-3); } for (TreeNode rt : rootVertex.getChildren()) { diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/ShapesTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/ShapesTest.java index 987beb86b..33dacee76 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/ShapesTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/ShapesTest.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.spatial; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.awt.geom.Ellipse2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; @@ -7,8 +9,7 @@ import org.jungrapht.visualization.layout.model.Point; import org.jungrapht.visualization.layout.model.Rectangle; import org.jungrapht.visualization.util.AWT; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ShapesTest { @@ -27,7 +28,7 @@ public void testCircleAgainstAwt() { Rectangle r = new Rectangle(rx, ry, w, h); Rectangle2D r2d = new Rectangle2D.Double(rx, ry, w, h); - Assert.assertEquals(c.intersects(r), e2d.intersects(r2d)); + assertEquals(c.intersects(r), e2d.intersects(r2d)); } } @@ -45,7 +46,7 @@ public void testPointAgainstAwt() { Rectangle r = new Rectangle(rx, ry, w, h); Rectangle2D r2d = AWT.convert(r); - Assert.assertEquals(p.inside(r), r2d.contains(p2d)); + assertEquals(p.inside(r), r2d.contains(p2d)); } } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialGridTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialGridTest.java index 27e975f53..4b9e5bc2f 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialGridTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialGridTest.java @@ -2,7 +2,7 @@ import java.awt.Rectangle; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialQuadTreeTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialQuadTreeTest.java index be656abdc..431b55dc2 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialQuadTreeTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialQuadTreeTest.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.spatial; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.stream.IntStream; import org.jgrapht.Graph; import org.jgrapht.graph.Pseudograph; @@ -8,9 +10,8 @@ import org.jungrapht.visualization.layout.util.RadiusVertexAccessor; import org.jungrapht.visualization.layout.util.RandomLocationTransformer; import org.jungrapht.visualization.layout.util.VertexAccessor; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,7 +31,7 @@ public class SpatialQuadTreeTest { LayoutModel layoutModel; SpatialQuadTree tree; - @Before + @BeforeEach public void setup() { // generate 100 random vertices in a graph at random locations in the layoutModel Pseudograph graph = @@ -61,7 +62,7 @@ public void testRandomPointsAndLocations() { Point location = layoutModel.apply(vertex); SpatialQuadTree pointQuadTree = tree.getContainingQuadTreeLeaf(location.x, location.y); SpatialQuadTree vertexQuadTree = (SpatialQuadTree) tree.getContainingQuadTreeLeaf(vertex); - Assert.assertEquals(pointQuadTree, vertexQuadTree); + assertEquals(pointQuadTree, vertexQuadTree); log.debug( "pointQuadTree level {} vertexQuadTree level {}", pointQuadTree.getLevel(), @@ -119,7 +120,7 @@ public void testClosestVertices() { y, tree.getContainingQuadTreeLeaf(x, y)); } - Assert.assertEquals(winnerOne, winnerTwo); + assertEquals(winnerOne, winnerTwo); } } diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/sublayout/GraphCollapserTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/sublayout/GraphCollapserTest.java index 1634e086c..7699684d3 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/sublayout/GraphCollapserTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/sublayout/GraphCollapserTest.java @@ -1,5 +1,7 @@ package org.jungrapht.visualization.sublayout; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -9,8 +11,7 @@ import org.jgrapht.graph.builder.GraphTypeBuilder; import org.jgrapht.util.SupplierUtil; import org.jungrapht.visualization.selection.MultiMutableSelectedState; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,10 +31,10 @@ public void testCollapser() { // graph: ([A, B, C], [0={A,B}, 1={A,C}, 2={B,C}]) - Assert.assertEquals(Set.of("A", "B", "C"), graph.vertexSet()); - Assert.assertEquals(Set.of("B", "A"), endpoints(graph, 0)); - Assert.assertEquals(Set.of("C", "A"), endpoints(graph, 1)); - Assert.assertEquals(Set.of("B", "C"), endpoints(graph, 2)); + assertEquals(Set.of("A", "B", "C"), graph.vertexSet()); + assertEquals(Set.of("B", "A"), endpoints(graph, 0)); + assertEquals(Set.of("C", "A"), endpoints(graph, 1)); + assertEquals(Set.of("B", "C"), endpoints(graph, 2)); GraphCollapser collapser = new GraphCollapser(graph); MultiMutableSelectedState picker = new MultiMutableSelectedState<>(); @@ -41,7 +42,7 @@ public void testCollapser() { picker.select("C"); Graph clusterGraph = collapser.getClusterGraph(picker.getSelected()); - Assert.assertEquals(Set.of("B", "C"), clusterGraph.vertexSet()); + assertEquals(Set.of("B", "C"), clusterGraph.vertexSet()); String collapsedVertex = collapser.collapse(picker.getSelected(), s -> collapsedVertexFactory.get()); @@ -50,18 +51,18 @@ public void testCollapser() { Graph collapsedGraph = collapser.collapsedGraphFunction().apply(vertex); if (collapsedGraph != null) { - Assert.assertEquals(Set.of(2), collapsedGraph.edgeSet()); + assertEquals(Set.of(2), collapsedGraph.edgeSet()); } else { - Assert.assertEquals("A", vertex); + assertEquals("A", vertex); } } - Assert.assertEquals(Set.of(0, 1), graph.edgeSet()); + assertEquals(Set.of(0, 1), graph.edgeSet()); for (Integer edge : graph.edgeSet()) { - Assert.assertEquals("A", graph.getEdgeSource(edge)); + assertEquals("A", graph.getEdgeSource(edge)); String target = graph.getEdgeTarget(edge); - Assert.assertEquals(collapsedVertex, target); - Assert.assertTrue(collapser.collapsedGraphFunction().apply(target) instanceof Graph); + assertEquals(collapsedVertex, target); + assertTrue(collapser.collapsedGraphFunction().apply(target) instanceof Graph); } log.info("collapsed graph is now: {}", graph); @@ -80,12 +81,12 @@ public void testCollapser() { // graph should be the original graph // - Assert.assertEquals(Set.of("A", "B", "C"), graph.vertexSet()); - Assert.assertEquals(Set.of("B", "A"), endpoints(graph, 0)); - Assert.assertEquals(Set.of("C", "A"), endpoints(graph, 1)); - Assert.assertEquals(Set.of("B", "C"), endpoints(graph, 2)); + assertEquals(Set.of("A", "B", "C"), graph.vertexSet()); + assertEquals(Set.of("B", "A"), endpoints(graph, 0)); + assertEquals(Set.of("C", "A"), endpoints(graph, 1)); + assertEquals(Set.of("B", "C"), endpoints(graph, 2)); log.info("expanded graph is now: {}", graph); - Assert.assertEquals(getDemoGraph(), graph); + assertEquals(getDemoGraph(), graph); } @Test @@ -129,7 +130,7 @@ public void testTwoConnectedClustersExpandOneThenTheOther() { collapser.expand(clusterVertexOne); log.debug("graph now {}", graph); - Assert.assertEquals(getDemoGraph2(), graph); + assertEquals(getDemoGraph2(), graph); } @Test @@ -173,7 +174,7 @@ public void testMore() { collapser.expand(clusterVertexOne); log.info("graph is {}", graph); - Assert.assertEquals(getDemoGraph2(), graph); + assertEquals(getDemoGraph2(), graph); } private static void createEdge(Graph g, String v1Label, String v2Label) { diff --git a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/transform/IntersectionsTest.java b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/transform/IntersectionsTest.java index 45a317e48..1517911c5 100644 --- a/jungrapht-visualization/src/test/java/org/jungrapht/visualization/transform/IntersectionsTest.java +++ b/jungrapht-visualization/src/test/java/org/jungrapht/visualization/transform/IntersectionsTest.java @@ -1,11 +1,12 @@ package org.jungrapht.visualization.transform; +import static org.junit.jupiter.api.Assertions.*; + import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.Optional; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class IntersectionsTest { @@ -15,26 +16,26 @@ public class IntersectionsTest { public void testVectors() { Line2D vector = new Line2D.Double(50, 50, 60, 60); Optional intersectionPoint = Intersections.getIntersectionPoint(vector, rectangle); - Assert.assertTrue(intersectionPoint.isEmpty()); + assertTrue(intersectionPoint.isEmpty()); vector = new Line2D.Double(50, 50, 200, 50); intersectionPoint = Intersections.getIntersectionPoint(vector, rectangle); - Assert.assertTrue(intersectionPoint.isPresent()); - Assert.assertEquals(new Point2D.Double(90, 50), intersectionPoint.get()); + assertTrue(intersectionPoint.isPresent()); + assertEquals(new Point2D.Double(90, 50), intersectionPoint.get()); vector = new Line2D.Double(50, 50, 110, -10); intersectionPoint = Intersections.getIntersectionPoint(vector, rectangle); - Assert.assertTrue(intersectionPoint.isPresent()); - Assert.assertEquals(new Point2D.Double(90, 10), intersectionPoint.get()); + assertTrue(intersectionPoint.isPresent()); + assertEquals(new Point2D.Double(90, 10), intersectionPoint.get()); vector = new Line2D.Double(50, 50, -10, -10); intersectionPoint = Intersections.getIntersectionPoint(vector, rectangle); - Assert.assertTrue(intersectionPoint.isPresent()); - Assert.assertEquals(new Point2D.Double(10, 10), intersectionPoint.get()); + assertTrue(intersectionPoint.isPresent()); + assertEquals(new Point2D.Double(10, 10), intersectionPoint.get()); vector = new Line2D.Double(50, 50, 50, 100); intersectionPoint = Intersections.getIntersectionPoint(vector, rectangle); - Assert.assertTrue(intersectionPoint.isPresent()); - Assert.assertEquals(new Point2D.Double(50, 90), intersectionPoint.get()); + assertTrue(intersectionPoint.isPresent()); + assertEquals(new Point2D.Double(50, 90), intersectionPoint.get()); } } diff --git a/pom.xml b/pom.xml index 16ea6cf0f..5f66c4bf6 100644 --- a/pom.xml +++ b/pom.xml @@ -66,24 +66,19 @@ 17 3.1.0 1.5.1 - 4.13.1 + 5.10.2 2.5 3.12.0 UTF-8 UTF-8 2.5.3 3.0.1 - 2.19.1 + 3.2.5 1.2.10 1.7.32 - - junit - junit - ${junit.version} - org.jgrapht jgrapht-core @@ -94,6 +89,12 @@ jgrapht-guava ${jgrapht.version} + + org.junit.jupiter + junit-jupiter + ${junit.version} + test + @@ -204,7 +205,7 @@ - maven-surefire-report-plugin + maven-surefire-plugin ${surefire.plugin.version}