From f9746d15a0e827ac9992d6e4a83a3d4f4d1f5c2b Mon Sep 17 00:00:00 2001 From: Alwine Balfanz <100916390+alwba@users.noreply.github.com> Date: Tue, 9 Aug 2022 20:14:34 +0200 Subject: [PATCH] [#1559] fixed some test cases --- .../GroupDegreeTreesToAggregateDegrees.java | 3 +- .../metric/AvgDegreeEvolutionTest.java | 4 +-- .../metric/MaxDegreeEvolutionTest.java | 14 ++++---- .../metric/MinDegreeEvolutionTest.java | 36 ++++++++++--------- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/operators/metric/functions/GroupDegreeTreesToAggregateDegrees.java b/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/operators/metric/functions/GroupDegreeTreesToAggregateDegrees.java index 1bdba9a84f28..fc9982ff5e41 100644 --- a/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/operators/metric/functions/GroupDegreeTreesToAggregateDegrees.java +++ b/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/operators/metric/functions/GroupDegreeTreesToAggregateDegrees.java @@ -23,6 +23,7 @@ import org.gradoop.common.model.impl.id.GradoopId; import java.util.*; +import java.util.stream.Stream; /** * A group reduce function that merges all Tuples (vId, degreeTree) to a dataset of tuples (time, aggDegree) @@ -51,7 +52,7 @@ public GroupDegreeTreesToAggregateDegrees(AggregateType aggregateType, DataSet> tuples; try { tuples = timePoints.collect(); - this.timePoints = null; + this.timePoints = new TreeSet<>(); for (int i = 0; i < timePoints.count(); i = i + 1) { this.timePoints.add(tuples.get(i).getField(0)); diff --git a/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/AvgDegreeEvolutionTest.java b/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/AvgDegreeEvolutionTest.java index c502c8e38743..1de5171e2479 100644 --- a/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/AvgDegreeEvolutionTest.java +++ b/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/AvgDegreeEvolutionTest.java @@ -85,7 +85,7 @@ public class AvgDegreeEvolutionTest extends TemporalGradoopTestBase { public VertexDegree degreeType; /** - * The expected degree evolution fo the given type. + * The expected degree evolution for the given type. */ @Parameterized.Parameter(1) public List> expectedDegrees; @@ -109,7 +109,7 @@ public static Iterable parameters() { } /** - * Set up the test graph an create the id-label mapping. + * Set up the test graph and create the id-label mapping. * * @throws Exception in case of an error */ diff --git a/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/MaxDegreeEvolutionTest.java b/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/MaxDegreeEvolutionTest.java index 244ec8fde1c8..f8c6befd0e16 100644 --- a/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/MaxDegreeEvolutionTest.java +++ b/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/MaxDegreeEvolutionTest.java @@ -56,7 +56,7 @@ public class MaxDegreeEvolutionTest extends TemporalGradoopTestBase { // IN DEGREES EXPECTED_IN_DEGREES.add(new Tuple2<>(Long.MIN_VALUE, 0)); EXPECTED_IN_DEGREES.add(new Tuple2<>(0L, 1)); - EXPECTED_IN_DEGREES.add(new Tuple2<>(4L, 2)); + EXPECTED_IN_DEGREES.add(new Tuple2<>(4L, 2)); //4,1 EXPECTED_IN_DEGREES.add(new Tuple2<>(5L, 1)); EXPECTED_IN_DEGREES.add(new Tuple2<>(6L, 1)); EXPECTED_IN_DEGREES.add(new Tuple2<>(7L, 1)); @@ -64,7 +64,7 @@ public class MaxDegreeEvolutionTest extends TemporalGradoopTestBase { // OUT DEGREES EXPECTED_OUT_DEGREES.add(new Tuple2<>(Long.MIN_VALUE, 0)); EXPECTED_OUT_DEGREES.add(new Tuple2<>(0L, 1)); - EXPECTED_OUT_DEGREES.add(new Tuple2<>(4L, 2)); + EXPECTED_OUT_DEGREES.add(new Tuple2<>(4L, 2)); //4,1 EXPECTED_OUT_DEGREES.add(new Tuple2<>(5L, 1)); EXPECTED_OUT_DEGREES.add(new Tuple2<>(6L, 1)); EXPECTED_OUT_DEGREES.add(new Tuple2<>(7L, 1)); @@ -72,9 +72,9 @@ public class MaxDegreeEvolutionTest extends TemporalGradoopTestBase { // DEGREES EXPECTED_BOTH_DEGREES.add(new Tuple2<>(Long.MIN_VALUE, 0)); EXPECTED_BOTH_DEGREES.add(new Tuple2<>(0L, 1)); - EXPECTED_BOTH_DEGREES.add(new Tuple2<>(4L, 3)); + EXPECTED_BOTH_DEGREES.add(new Tuple2<>(4L, 3)); // 4,2 EXPECTED_BOTH_DEGREES.add(new Tuple2<>(5L, 1)); - EXPECTED_BOTH_DEGREES.add(new Tuple2<>(6L, 2)); + EXPECTED_BOTH_DEGREES.add(new Tuple2<>(6L, 2)); // 6,1 EXPECTED_BOTH_DEGREES.add(new Tuple2<>(7L, 1)); } @@ -85,7 +85,7 @@ public class MaxDegreeEvolutionTest extends TemporalGradoopTestBase { public VertexDegree degreeType; /** - * The expected degree evolution fo the given type. + * The expected degree evolution for the given type. */ @Parameterized.Parameter(1) public List> expectedDegrees; @@ -109,7 +109,7 @@ public static Iterable parameters() { } /** - * Set up the test graph an create the id-label mapping. + * Set up the test graph and create the id-label mapping. * * @throws Exception in case of an error */ @@ -138,6 +138,8 @@ public void testMaxDegree() throws Exception { resultDataSet.output(new LocalCollectionOutputFormat<>(resultCollection)); getExecutionEnvironment().execute(); + System.out.println(resultCollection); + assertTrue(resultCollection.containsAll(expectedDegrees)); assertTrue(expectedDegrees.containsAll(resultCollection)); } diff --git a/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/MinDegreeEvolutionTest.java b/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/MinDegreeEvolutionTest.java index 485460da7cec..de34a600f3b5 100644 --- a/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/MinDegreeEvolutionTest.java +++ b/gradoop-temporal/src/test/java/org/gradoop/temporal/model/impl/operators/metric/MinDegreeEvolutionTest.java @@ -55,27 +55,27 @@ public class MinDegreeEvolutionTest extends TemporalGradoopTestBase { static { // IN DEGREES EXPECTED_IN_DEGREES.add(new Tuple2<>(Long.MIN_VALUE, 0)); - EXPECTED_IN_DEGREES.add(new Tuple2<>(0L, 0)); - EXPECTED_IN_DEGREES.add(new Tuple2<>(4L, 0)); - EXPECTED_IN_DEGREES.add(new Tuple2<>(5L, 0)); - EXPECTED_IN_DEGREES.add(new Tuple2<>(6L, 0)); - EXPECTED_IN_DEGREES.add(new Tuple2<>(7L, 0)); + EXPECTED_IN_DEGREES.add(new Tuple2<>(0L, 0)); //1 + EXPECTED_IN_DEGREES.add(new Tuple2<>(4L, 0)); //1 + EXPECTED_IN_DEGREES.add(new Tuple2<>(5L, 0)); //1 + EXPECTED_IN_DEGREES.add(new Tuple2<>(6L, 0)); //1 + EXPECTED_IN_DEGREES.add(new Tuple2<>(7L, 0)); //1 // OUT DEGREES EXPECTED_OUT_DEGREES.add(new Tuple2<>(Long.MIN_VALUE, 0)); - EXPECTED_OUT_DEGREES.add(new Tuple2<>(0L, 0)); - EXPECTED_OUT_DEGREES.add(new Tuple2<>(4L, 0)); - EXPECTED_OUT_DEGREES.add(new Tuple2<>(5L, 0)); - EXPECTED_OUT_DEGREES.add(new Tuple2<>(6L, 0)); - EXPECTED_OUT_DEGREES.add(new Tuple2<>(7L, 0)); + EXPECTED_OUT_DEGREES.add(new Tuple2<>(0L, 0)); //1 + EXPECTED_OUT_DEGREES.add(new Tuple2<>(4L, 0)); //1 + EXPECTED_OUT_DEGREES.add(new Tuple2<>(5L, 0)); //1 + EXPECTED_OUT_DEGREES.add(new Tuple2<>(6L, 0)); //1 + EXPECTED_OUT_DEGREES.add(new Tuple2<>(7L, 0)); //1 // DEGREES EXPECTED_BOTH_DEGREES.add(new Tuple2<>(Long.MIN_VALUE, 0)); - EXPECTED_BOTH_DEGREES.add(new Tuple2<>(0L, 0)); - EXPECTED_BOTH_DEGREES.add(new Tuple2<>(4L, 1)); - EXPECTED_BOTH_DEGREES.add(new Tuple2<>(5L, 0)); - EXPECTED_BOTH_DEGREES.add(new Tuple2<>(6L, 0)); - EXPECTED_BOTH_DEGREES.add(new Tuple2<>(7L, 0)); + EXPECTED_BOTH_DEGREES.add(new Tuple2<>(0L, 1)); + EXPECTED_BOTH_DEGREES.add(new Tuple2<>(4L, 1)); //2 + EXPECTED_BOTH_DEGREES.add(new Tuple2<>(5L, 1)); + EXPECTED_BOTH_DEGREES.add(new Tuple2<>(6L, 0)); //1 + EXPECTED_BOTH_DEGREES.add(new Tuple2<>(7L, 0)); //1 } /** @@ -85,7 +85,7 @@ public class MinDegreeEvolutionTest extends TemporalGradoopTestBase { public VertexDegree degreeType; /** - * The expected degree evolution fo the given type. + * The expected degree evolution for the given type. */ @Parameterized.Parameter(1) public List> expectedDegrees; @@ -109,7 +109,7 @@ public static Iterable parameters() { } /** - * Set up the test graph an create the id-label mapping. + * Set up the test graph and create the id-label mapping. * * @throws Exception in case of an error */ @@ -138,6 +138,8 @@ public void testMinDegree() throws Exception { resultDataSet.output(new LocalCollectionOutputFormat<>(resultCollection)); getExecutionEnvironment().execute(); + System.out.println(resultCollection); + assertTrue(resultCollection.containsAll(expectedDegrees)); assertTrue(expectedDegrees.containsAll(resultCollection)); }