diff --git a/pom.xml b/pom.xml index 6e8f38016..1d6b95add 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ 0.8.9 2.10.6 2.4.0 - 5.10.2 + 5.12.2 5.11.0 1.10.0 provided diff --git a/wayang-api/wayang-api-scala-java/src/test/java/org/apache/wayang/api/JavaApiTest.java b/wayang-api/wayang-api-scala-java/src/test/java/org/apache/wayang/api/JavaApiTest.java index 2d4bb6ca5..9240f2d9c 100644 --- a/wayang-api/wayang-api-scala-java/src/test/java/org/apache/wayang/api/JavaApiTest.java +++ b/wayang-api/wayang-api-scala-java/src/test/java/org/apache/wayang/api/JavaApiTest.java @@ -18,9 +18,6 @@ package org.apache.wayang.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.WayangContext; @@ -38,6 +35,8 @@ import org.apache.wayang.spark.Spark; import org.apache.wayang.sqlite3.Sqlite3; import org.apache.wayang.sqlite3.operators.Sqlite3TableSource; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -57,15 +56,17 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for the Java API. */ -public class JavaApiTest { +class JavaApiTest { private Configuration sqlite3Configuration; - @Before - public void setUp() throws SQLException, IOException { + @BeforeEach + void setUp() throws SQLException, IOException { // Generate test data. this.sqlite3Configuration = new Configuration(); File sqlite3dbFile = File.createTempFile("wayang-sqlite3", "db"); @@ -83,7 +84,7 @@ public void setUp() throws SQLException, IOException { } @Test - public void testMapReduce() { + void testMapReduce() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder javaPlanBuilder = new JavaPlanBuilder(wayangContext); @@ -94,11 +95,11 @@ public void testMapReduce() { .reduce((a, b) -> a + b).withName("sum") .collect(); - Assert.assertEquals(WayangCollections.asSet(1 + 4 + 9 + 16), WayangCollections.asSet(outputCollection)); + assertEquals(WayangCollections.asSet(1 + 4 + 9 + 16), WayangCollections.asSet(outputCollection)); } @Test - public void testMapReduceBy() { + void testMapReduceBy() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder javaPlanBuilder = new JavaPlanBuilder(wayangContext); @@ -109,11 +110,11 @@ public void testMapReduceBy() { .reduceByKey(i -> i & 1, (a, b) -> a + b).withName("sum") .collect(); - Assert.assertEquals(WayangCollections.asSet(4 + 16, 1 + 9), WayangCollections.asSet(outputCollection)); + assertEquals(WayangCollections.asSet(4 + 16, 1 + 9), WayangCollections.asSet(outputCollection)); } @Test - public void testBroadcast2() { + void testBroadcast2() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder javaPlanBuilder = new JavaPlanBuilder(wayangContext); @@ -129,11 +130,11 @@ public void testBroadcast2() { .map(new AddOffset("offset")).withName("add offset").withBroadcast(offsetDataQuanta, "offset") .collect(); - Assert.assertEquals(WayangCollections.asSet(-2, -1, 0, 1, 2), WayangCollections.asSet(outputCollection)); + assertEquals(WayangCollections.asSet(-2, -1, 0, 1, 2), WayangCollections.asSet(outputCollection)); } @Test - public void testCustomOperatorShortCut() { + void testCustomOperatorShortCut() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); @@ -154,11 +155,11 @@ public void testCustomOperatorShortCut() { // Check the outcome. final List expectedOutputValues = WayangArrays.asList(2, 3, 4, 5); - Assert.assertEquals(WayangCollections.asSet(expectedOutputValues), WayangCollections.asSet(outputValues)); + assertEquals(WayangCollections.asSet(expectedOutputValues), WayangCollections.asSet(outputValues)); } @Test - public void testWordCount() { + void testWordCount() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); @@ -179,11 +180,11 @@ public void testWordCount() { new Tuple2<>("is", 2), new Tuple2<>("data", 3) ); - Assert.assertEquals(WayangCollections.asSet(expectedOutputValues), WayangCollections.asSet(outputValues)); + assertEquals(WayangCollections.asSet(expectedOutputValues), WayangCollections.asSet(outputValues)); } @Test - public void testWordCountOnSparkAndJava() { + void testWordCountOnSparkAndJava() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()).with(Spark.basicPlugin()); @@ -204,11 +205,11 @@ public void testWordCountOnSparkAndJava() { new Tuple2<>("is", 2), new Tuple2<>("data", 3) ); - Assert.assertEquals(WayangCollections.asSet(expectedOutputValues), WayangCollections.asSet(outputValues)); + assertEquals(WayangCollections.asSet(expectedOutputValues), WayangCollections.asSet(outputValues)); } @Test - public void testSample() { + void testSample() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()).with(Spark.basicPlugin()); @@ -222,13 +223,13 @@ public void testSample() { .collect(); // Check the outcome. - Assert.assertEquals(10, outputValues.size()); - Assert.assertEquals(10, WayangCollections.asSet(outputValues).size()); + assertEquals(10, outputValues.size()); + assertEquals(10, WayangCollections.asSet(outputValues).size()); } @Test - public void testDoWhile() { + void testDoWhile() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); @@ -253,7 +254,7 @@ public void testDoWhile() { .collect(); Set expectedValues = WayangCollections.asSet(1, 2, 3, 6, 12, 24, 48, 96, 192); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } private static class AddOffset implements FunctionDescriptor.ExtendedSerializableFunction { @@ -278,7 +279,7 @@ public Integer apply(Integer input) { } @Test - public void testRepeat() { + void testRepeat() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); @@ -296,7 +297,7 @@ public void testRepeat() { .collect(); Set expectedValues = WayangCollections.asSet(42, 43); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } private static class SelectWords implements PredicateDescriptor.ExtendedSerializablePredicate { @@ -321,7 +322,7 @@ public boolean test(String word) { } @Test - public void testBroadcast() { + void testBroadcast() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -340,11 +341,11 @@ public void testBroadcast() { // Verify the outcome. Set expectedValues = WayangCollections.asSet("Hello", "World"); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } @Test - public void testGroupBy() { + void testGroupBy() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -369,11 +370,11 @@ public void testGroupBy() { // Verify the outcome. Set expectedValues = WayangCollections.asSet(5d, 6d); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } @Test - public void testJoin() { + void testJoin() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -404,11 +405,11 @@ public void testJoin() { new Tuple2<>("Orange juice", 10), new Tuple2<>("Tap water", 0) ); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } @Test - public void testJoinAndAssemble() { + void testJoinAndAssemble() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -439,11 +440,11 @@ public void testJoinAndAssemble() { new Tuple2<>("Orange juice", 10), new Tuple2<>("Tap water", 0) ); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } @Test - public void testCoGroup() { + void testCoGroup() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()).with(Spark.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -485,11 +486,11 @@ public void testCoGroup() { WayangCollections.asSet(new Tuple2<>("Apple juice", "Juice"), new Tuple2<>("Orange juice", "Juice")) ) ); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } @Test - public void testCoGroupViaKeyBy() { + void testCoGroupViaKeyBy() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()).with(Spark.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -532,11 +533,11 @@ public void testCoGroupViaKeyBy() { WayangCollections.asSet(new Tuple2<>("Apple juice", "Juice"), new Tuple2<>("Orange juice", "Juice")) ) ); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } @Test - public void testIntersect() { + void testIntersect() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -552,11 +553,11 @@ public void testIntersect() { // Verify the outcome. Set expectedValues = WayangCollections.asSet(2, 3, 4, 5, 7, 8, 9); - Assert.assertEquals(expectedValues, WayangCollections.asSet(outputValues)); + assertEquals(expectedValues, WayangCollections.asSet(outputValues)); } @Test - public void testSort() { + void testSort() { // Set up WayangContext. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -570,12 +571,12 @@ public void testSort() { // Verify the outcome. List expectedValues = Arrays.asList(1, 2, 3, 4, 5); - Assert.assertEquals(expectedValues, WayangCollections.asList(outputValues)); + assertEquals(expectedValues, WayangCollections.asList(outputValues)); } @Test - public void testPageRank() { + void testPageRank() { // Set up WayangContext. WayangContext wayangContext = new WayangContext() .with(Java.basicPlugin()) @@ -601,14 +602,14 @@ public void testPageRank() { sortedPageRanks.sort((pr1, pr2) -> Float.compare(pr2.field1, pr1.field1)); System.out.println(sortedPageRanks); - Assert.assertEquals(1L, sortedPageRanks.get(0).field0.longValue()); - Assert.assertEquals(0L, sortedPageRanks.get(1).field0.longValue()); - Assert.assertEquals(2L, sortedPageRanks.get(2).field0.longValue()); - Assert.assertEquals(3L, sortedPageRanks.get(3).field0.longValue()); + assertEquals(1L, sortedPageRanks.get(0).field0.longValue()); + assertEquals(0L, sortedPageRanks.get(1).field0.longValue()); + assertEquals(2L, sortedPageRanks.get(2).field0.longValue()); + assertEquals(3L, sortedPageRanks.get(3).field0.longValue()); } @Test - public void testMapPartitions() { + void testMapPartitions() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -635,11 +636,11 @@ public void testMapPartitions() { Set> expectedOutput = WayangCollections.asSet( new Tuple2<>("even", 5), new Tuple2<>("odd", 2) ); - Assert.assertEquals(expectedOutput, WayangCollections.asSet(outputValues)); + assertEquals(expectedOutput, WayangCollections.asSet(outputValues)); } @Test - public void testZipWithId() { + void testZipWithId() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -667,11 +668,11 @@ public void testZipWithId() { // Check the output. Set> expectedOutput = Collections.singleton(new Tuple2<>(42, 100)); - Assert.assertEquals(expectedOutput, WayangCollections.asSet(outputValues)); + assertEquals(expectedOutput, WayangCollections.asSet(outputValues)); } @Test - public void testWriteTextFile() throws IOException, URISyntaxException { + void testWriteTextFile() throws IOException, URISyntaxException { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); JavaPlanBuilder builder = new JavaPlanBuilder(wayangContext); @@ -689,11 +690,11 @@ public void testWriteTextFile() throws IOException, URISyntaxException { // Check the output. Set actualLines = Files.lines(Paths.get(new URI(targetUrl))).collect(Collectors.toSet()); Set expectedLines = inputValues.stream().map(d -> String.format("%.2f", d)).collect(Collectors.toSet()); - Assert.assertEquals(expectedLines, actualLines); + assertEquals(expectedLines, actualLines); } @Test - public void testSqlOnJava() throws IOException, SQLException { + void testSqlOnJava() throws IOException, SQLException { // Execute job. final WayangContext wayangCtx = new WayangContext(this.sqlite3Configuration) .with(Java.basicPlugin()) @@ -707,14 +708,14 @@ public void testSqlOnJava() throws IOException, SQLException { .collect(); // Test the outcome. - Assert.assertEquals( + assertEquals( WayangCollections.asSet("John", "Evelyn"), WayangCollections.asSet(outputValues) ); } @Test - public void testSqlOnSqlite3() throws IOException, SQLException { + void testSqlOnSqlite3() throws IOException, SQLException { // Execute job. final WayangContext wayangCtx = new WayangContext(this.sqlite3Configuration) .with(Java.basicPlugin()) @@ -728,7 +729,7 @@ public void testSqlOnSqlite3() throws IOException, SQLException { .collect(); // Test the outcome. - Assert.assertEquals( + assertEquals( WayangCollections.asSet("John", "Evelyn"), WayangCollections.asSet(outputValues) ); diff --git a/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/ApiTest.scala b/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/ApiTest.scala index cc05bd20b..25ef9ac49 100644 --- a/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/ApiTest.scala +++ b/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/ApiTest.scala @@ -24,7 +24,6 @@ import java.nio.file.{Files, Paths} import java.sql.{Connection, Statement} import java.util.function.Consumer -import org.junit.{Assert, Test} import org.apache.wayang.basic.WayangBasics import org.apache.wayang.core.api.{Configuration, WayangContext} import org.apache.wayang.core.function.FunctionDescriptor.ExtendedSerializablePredicate @@ -35,6 +34,8 @@ import org.apache.wayang.java.operators.JavaMapOperator import org.apache.wayang.spark.Spark import org.apache.wayang.sqlite3.Sqlite3 import org.apache.wayang.sqlite3.operators.Sqlite3TableSource +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api.Test /** * Tests the Wayang API. @@ -57,7 +58,7 @@ class ApiTest { // Check the outcome. val expectedOutputValues = inputValues.map(_ + 2) - Assert.assertArrayEquals(expectedOutputValues, outputValues.toArray) + assertArrayEquals(expectedOutputValues, outputValues.toArray) } @Test @@ -87,7 +88,7 @@ class ApiTest { // Check the outcome. val expectedOutputValues = inputValues.map(_ + 2) - Assert.assertArrayEquals(expectedOutputValues, outputValues.toArray) + assertArrayEquals(expectedOutputValues, outputValues.toArray) } @Test @@ -113,7 +114,7 @@ class ApiTest { // Check the outcome. val expectedOutputValues = inputValues.map(_ + 2) - Assert.assertArrayEquals(expectedOutputValues, outputValues.toArray) + assertArrayEquals(expectedOutputValues, outputValues.toArray) } @Test @@ -135,7 +136,7 @@ class ApiTest { val expectedWordCounts = Set(("big", 3), ("is", 2), ("data", 3)) - Assert.assertEquals(expectedWordCounts, wordCounts) + assertEquals(expectedWordCounts, wordCounts) } @Test @@ -157,7 +158,7 @@ class ApiTest { val expectedWordCounts = Set(("big", 3), ("is", 2), ("data", 3)) - Assert.assertEquals(expectedWordCounts, wordCounts) + assertEquals(expectedWordCounts, wordCounts) } @Test @@ -175,8 +176,8 @@ class ApiTest { .collect() // Check the result. - Assert.assertEquals(10, sample.size) - Assert.assertEquals(10, sample.toSet.size) + assertEquals(10, sample.size) + assertEquals(10, sample.toSet.size) } @Test @@ -199,7 +200,7 @@ class ApiTest { .collect().toSet val expectedValues = Set(1, 2, 3, 6, 12, 24, 48, 96, 192) - Assert.assertEquals(expectedValues, values) + assertEquals(expectedValues, values) } @Test @@ -222,7 +223,7 @@ class ApiTest { // initial: 1,2 -> 1st: 2,3 -> 2nd: 6,7 => 3rd: 42,43 val expectedValues = Set(42, 43) - Assert.assertEquals(expectedValues, values) + assertEquals(expectedValues, values) } @Test @@ -256,7 +257,7 @@ class ApiTest { .collect().toSet val expectedValues = Set("Hello", "World") - Assert.assertEquals(expectedValues, values) + assertEquals(expectedValues, values) } @Test @@ -280,7 +281,7 @@ class ApiTest { .collect() val expectedValues = Set(5, 6) - Assert.assertEquals(expectedValues, result.toSet) + assertEquals(expectedValues, result.toSet) } @Test @@ -304,7 +305,7 @@ class ApiTest { .collect() val expectedValues = Set(5) - Assert.assertEquals(expectedValues, result.toSet) + assertEquals(expectedValues, result.toSet) } @Test @@ -324,7 +325,7 @@ class ApiTest { .collect() val expectedValues = Set(("Apple juice", 10), ("Tap water", 0), ("Orange juice", 10)) - Assert.assertEquals(expectedValues, result.toSet) + assertEquals(expectedValues, result.toSet) } @Test @@ -343,7 +344,7 @@ class ApiTest { .collect() val expectedValues = Set(("Apple juice", 10), ("Tap water", 0), ("Orange juice", 10)) - Assert.assertEquals(expectedValues, result.toSet) + assertEquals(expectedValues, result.toSet) } @@ -369,7 +370,7 @@ class ApiTest { (Set(("Cola", 5)), Set()), (Set(("Juice", 10)), Set(("Apple juice", "Juice"), ("Orange juice", "Juice"))) ) - Assert.assertEquals(expectedValues, actualValues) + assertEquals(expectedValues, actualValues) } @Test @@ -388,7 +389,7 @@ class ApiTest { .collect() val expectedValues = Set(2, 3, 4, 5, 7, 8, 9) - Assert.assertEquals(expectedValues, result.toSet) + assertEquals(expectedValues, result.toSet) } @@ -406,7 +407,7 @@ class ApiTest { .collect() val expectedValues = Array(1, 2, 3, 4, 5) - Assert.assertArrayEquals(expectedValues, result.toArray) + assertArrayEquals(expectedValues, result.toArray) } @@ -430,9 +431,9 @@ class ApiTest { print(pageRanks) // Let's not check absolute numbers but only the relative ordering. - Assert.assertTrue(pageRanks(1) > pageRanks(0)) - Assert.assertTrue(pageRanks(0) > pageRanks(2)) - Assert.assertTrue(pageRanks(2) > pageRanks(3)) + assertTrue(pageRanks(1) > pageRanks(0)) + assertTrue(pageRanks(0) > pageRanks(2)) + assertTrue(pageRanks(2) > pageRanks(3)) } @Test @@ -452,7 +453,7 @@ class ApiTest { .reduceByKey(_._1, { case ((kind1, count1), (kind2, count2)) => (kind1, count1 + count2) }) .collect() - Assert.assertEquals(Set(("odd", 2), ("even", 5)), typeCounts.toSet) + assertEquals(Set(("odd", 2), ("even", 5)), typeCounts.toSet) } @Test @@ -474,7 +475,7 @@ class ApiTest { .collect() val expectedValues = Set((42, 100)) - Assert.assertEquals(expectedValues, result.toSet) + assertEquals(expectedValues, result.toSet) } @Test @@ -497,7 +498,7 @@ class ApiTest { }) val expectedLines = inputValues.map(v => f"${v % .2f}").toSet - Assert.assertEquals(expectedLines, lines) + assertEquals(expectedLines, lines) } @Test @@ -535,7 +536,7 @@ class ApiTest { .toSet val expectedValues = Set("John", "Evelyn") - Assert.assertEquals(expectedValues, result) + assertEquals(expectedValues, result) } @Test @@ -573,6 +574,6 @@ class ApiTest { .toSet val expectedValues = Set("John", "Evelyn") - Assert.assertEquals(expectedValues, result) + assertEquals(expectedValues, result) } } diff --git a/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/OperatorSerializationTests.scala b/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/OperatorSerializationTests.scala index 6dff434ba..1f97ce0de 100644 --- a/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/OperatorSerializationTests.scala +++ b/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/OperatorSerializationTests.scala @@ -26,7 +26,7 @@ import org.apache.wayang.postgres.Postgres import org.apache.wayang.postgres.operators.PostgresTableSource import org.apache.wayang.sqlite3.Sqlite3 import org.apache.wayang.sqlite3.operators.Sqlite3TableSource -import org.junit.Test +import org.junit.jupiter.api.Test import java.io.{File, PrintWriter} import java.sql.{Connection, Statement} diff --git a/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/OtherSerializationTests.scala b/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/OtherSerializationTests.scala index 1f01b2f98..5ba562962 100644 --- a/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/OtherSerializationTests.scala +++ b/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/OtherSerializationTests.scala @@ -28,7 +28,8 @@ import org.apache.wayang.core.platform.Platform import org.apache.wayang.core.util.ReflectionUtils import org.apache.wayang.java.Java import org.apache.wayang.spark.Spark -import org.junit.{Assert, Test} +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api.Test import java.nio.file.{Files, Paths} @@ -45,15 +46,15 @@ class OtherSerializationTests extends SerializationTestBase { try { val serializedConfiguration = SerializationUtils.serialize(configuration) val deserializedConfiguration = SerializationUtils.deserialize[Configuration](serializedConfiguration) - Assert.assertEquals(deserializedConfiguration.getStringProperty("spark.master"), "random_master_url_1") - Assert.assertEquals(deserializedConfiguration.getStringProperty("spark.app.name"), "random_app_name_2") + assertEquals(deserializedConfiguration.getStringProperty("spark.master"), "random_master_url_1") + assertEquals(deserializedConfiguration.getStringProperty("spark.app.name"), "random_app_name_2") val serializedMultiContext = SerializationUtils.serialize(multiContext) val deserializedMultiContext = SerializationUtils.deserialize[MultiContext](serializedMultiContext) - Assert.assertEquals(deserializedMultiContext.getConfiguration.getStringProperty("spark.master"), "random_master_url_1") - Assert.assertEquals(deserializedMultiContext.getConfiguration.getStringProperty("spark.app.name"), "random_app_name_2") - Assert.assertEquals(deserializedMultiContext.getSink.get.asInstanceOf[MultiContext.TextFileSink].url, "file:///tmp/out11") - Assert.assertArrayEquals(multiContext.getConfiguration.getPlatformProvider.provideAll().toArray, deserializedMultiContext.getConfiguration.getPlatformProvider.provideAll().toArray) + assertEquals(deserializedMultiContext.getConfiguration.getStringProperty("spark.master"), "random_master_url_1") + assertEquals(deserializedMultiContext.getConfiguration.getStringProperty("spark.app.name"), "random_app_name_2") + assertEquals(deserializedMultiContext.getSink.get.asInstanceOf[MultiContext.TextFileSink].url, "file:///tmp/out11") + assertArrayEquals(multiContext.getConfiguration.getPlatformProvider.provideAll().toArray, deserializedMultiContext.getConfiguration.getPlatformProvider.provideAll().toArray) } catch { case t: Throwable => t.printStackTrace() @@ -76,19 +77,19 @@ class OtherSerializationTests extends SerializationTestBase { try { val serialized = SerializationUtils.serializeAsString(planBuilder) val deserialized = SerializationUtils.deserializeFromString[PlanBuilder](serialized) - // SerializationTestBase.log(SerializationUtils.serializeAsString(deserialized), testName.getMethodName + ".log.json") + // SerializationTestBase.log(SerializationUtils.serializeAsString(deserialized), testName + ".log.json") - Assert.assertEquals( + assertEquals( planBuilder.udfJars, deserialized.udfJars ) - Assert.assertEquals( - deserialized.wayangContext.asInstanceOf[MultiContext].getConfiguration.getStringProperty("spark.master"), - "master1" + assertEquals( + "master1", + deserialized.wayangContext.asInstanceOf[MultiContext].getConfiguration.getStringProperty("spark.master") ) - Assert.assertEquals( + assertEquals( + "file:///tmp/out11", deserialized.wayangContext.asInstanceOf[MultiContext].getSink.get.asInstanceOf[MultiContext.TextFileSink].url, - "file:///tmp/out11" ) } catch { @@ -116,25 +117,25 @@ class OtherSerializationTests extends SerializationTestBase { try { val serialized = SerializationUtils.serializeAsString(multiContextPlanBuilder) val deserialized = SerializationUtils.deserializeFromString[MultiContextPlanBuilder](serialized) - // SerializationTestBase.log(SerializationUtils.serializeAsString(deserialized), testName.getMethodName + ".log.json") + // SerializationTestBase.log(SerializationUtils.serializeAsString(deserialized), testName + ".log.json") - Assert.assertEquals( + assertEquals( multiContextPlanBuilder.udfJars, deserialized.udfJars ) - Assert.assertEquals( + assertEquals( multiContextPlanBuilder.multiContexts(0).getConfiguration.getStringProperty("spark.master"), "master1" ) - Assert.assertEquals( + assertEquals( multiContextPlanBuilder.multiContexts(1).getConfiguration.getStringProperty("spark.master"), "master2" ) - Assert.assertEquals( + assertEquals( multiContextPlanBuilder.multiContexts(0).getSink.get.asInstanceOf[MultiContext.TextFileSink].url, "file:///tmp/out11" ) - Assert.assertEquals( + assertEquals( multiContextPlanBuilder.multiContexts(1).getSink.get.asInstanceOf[MultiContext.ObjectFileSink].url, "file:///tmp/out12" ) @@ -169,7 +170,7 @@ class OtherSerializationTests extends SerializationTestBase { val operator = TempFileUtils.readFromTempFileFromString[Operator](tempfile) // Attach an output sink to deserialized plan - val tempFileOut = s"/tmp/${testName.getMethodName}.out" + val tempFileOut = s"/tmp/$testName.out" val sink = new TextFileSink[AnyRef](s"file://$tempFileOut", classOf[AnyRef]) operator.connectTo(0, sink, 0) @@ -226,7 +227,7 @@ class OtherSerializationTests extends SerializationTestBase { try { val serialized = SerializationUtils.serialize(Java.platform()) val deserialized = SerializationUtils.deserialize[Platform](serialized) - Assert.assertEquals(deserialized.getClass.getName, Java.platform().getClass.getName) + assertEquals(deserialized.getClass.getName, Java.platform().getClass.getName) } catch { case t: Throwable => t.printStackTrace() @@ -250,10 +251,10 @@ class OtherSerializationTests extends SerializationTestBase { try { val serialized = SerializationUtils.serializeAsString(dataQuanta.operator) val deserialized = SerializationUtils.deserializeFromString[Operator](serialized) - Assert.assertEquals(deserialized.getTargetPlatforms.size(), 2) + assertEquals(deserialized.getTargetPlatforms.size(), 2) val deserializedPlatformNames = deserialized.getTargetPlatforms.toArray.map(p => p.getClass.getName) - Assert.assertTrue(deserializedPlatformNames.contains(Spark.platform().getClass.getName)) - Assert.assertTrue(deserializedPlatformNames.contains(Java.platform().getClass.getName)) + assertTrue(deserializedPlatformNames.contains(Spark.platform().getClass.getName)) + assertTrue(deserializedPlatformNames.contains(Java.platform().getClass.getName)) } catch { case t: Throwable => t.printStackTrace() @@ -282,8 +283,8 @@ class OtherSerializationTests extends SerializationTestBase { try { val serialized = SerializationUtils.serializeAsString(dataQuanta.operator) val deserialized = SerializationUtils.deserializeFromString[Operator](serialized) - Assert.assertEquals(deserialized.getTargetPlatforms.size(), 1) - Assert.assertEquals(deserialized.getTargetPlatforms.toArray.toList(0).getClass.getName, Spark.platform().getClass.getName) + assertEquals(deserialized.getTargetPlatforms.size(), 1) + assertEquals(deserialized.getTargetPlatforms.toArray.toList(0).getClass.getName, Spark.platform().getClass.getName) } catch { case t: Throwable => t.printStackTrace() @@ -326,8 +327,8 @@ class OtherSerializationTests extends SerializationTestBase { .getFunctionDescriptor .getLoadProfileEstimator.get().asInstanceOf[NestableLoadProfileEstimator] - Assert.assertEquals(originalLoadProfileEstimator.getConfigurationKeys, deserializedLoadProfileEstimator.getConfigurationKeys) - Assert.assertEquals(originalLoadProfileEstimator.getTemplateKeys, deserializedLoadProfileEstimator.getTemplateKeys) + assertEquals(originalLoadProfileEstimator.getConfigurationKeys, deserializedLoadProfileEstimator.getConfigurationKeys) + assertEquals(originalLoadProfileEstimator.getTemplateKeys, deserializedLoadProfileEstimator.getTemplateKeys) /*// Print the contents of configuration keys array for both the originalLoadProfileEstimator and the deserializedLoadProfileEstimator println("originalLoadProfileEstimator.getConfigurationKeys: " + originalLoadProfileEstimator.getConfigurationKeys.mkString(",")) diff --git a/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/SerializationTestBase.scala b/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/SerializationTestBase.scala index 5b8379817..cabca74db 100644 --- a/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/SerializationTestBase.scala +++ b/wayang-api/wayang-api-scala-java/src/test/scala/org/apache/wayang/api/serialization/SerializationTestBase.scala @@ -23,8 +23,8 @@ import org.apache.wayang.basic.operators.TextFileSink import org.apache.wayang.core.api.WayangContext import org.apache.wayang.core.plan.wayangplan.{LoopHeadOperator, Operator, WayangPlan} import org.apache.wayang.core.util.ReflectionUtils -import org.junit.rules.TestName -import org.junit.{Assert, Rule} +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api.{BeforeEach, TestInfo} import java.io.{File, FileWriter} import java.nio.file.{Files, Paths} @@ -34,19 +34,13 @@ import scala.jdk.CollectionConverters.asScalaBufferConverter trait SerializationTestBase { - // - // Some magic from https://stackoverflow.com/a/36152864/5589918 in order to get the current test name - // - var _testName: TestName = new TestName + var testName: String = _ - @Rule - def testName: TestName = _testName - - def testName_=(aTestName: TestName): Unit = { - _testName = aTestName + @BeforeEach + def setUp(info: TestInfo): Unit = { + testName = info.getTestMethod.orElseThrow().getName } - def serializeDeserializeExecuteAssert(operator: Operator, wayangContext: WayangContext, expectedLines: List[String], log: Boolean = false): Unit = { var tempFileOut: Option[String] = None try { @@ -70,12 +64,12 @@ trait SerializationTestBase { def serializeDeserializeExecute(operator: Operator, wayangContext: WayangContext, log: Boolean = false): String = { try { val serialized = SerializationUtils.serializeAsString(operator) - if (log) SerializationTestBase.log(serialized, testName.getMethodName + ".log.json") + if (log) SerializationTestBase.log(serialized, testName + ".log.json") val deserialized = SerializationUtils.deserializeFromString[Operator](serialized) // Create an output sink val outType = deserialized.getOutput(0).getType.getDataUnitType.getTypeClass - val tempFilenameOut = s"/tmp/${testName.getMethodName}.out" + val tempFilenameOut = s"/tmp/$testName.out" val sink = new TextFileSink(s"file://$tempFilenameOut", outType) // And attach it to the deserialized operator @@ -106,11 +100,11 @@ object SerializationTestBase { val lines = Files.lines(Paths.get(outputFilename)).collect(Collectors.toList[String]).asScala // Assert number of lines - Assert.assertEquals("Number of lines in the file should match", expectedLines.size, lines.size) + assertEquals(expectedLines.size, lines.size, "Number of lines in the file should match") // Assert content of lines lines.zip(expectedLines).foreach { case (actual, expected) => - Assert.assertEquals("Line content should match", expected, actual) + assertEquals(expected, actual, "Line content should match") } } @@ -120,7 +114,7 @@ object SerializationTestBase { val lines = Files.lines(Paths.get(outputFilename)).collect(Collectors.toList[String]).asScala // Assert number of lines - Assert.assertEquals("Number of lines in the file should match", expectedNumberOfLines, lines.size) + assertEquals(expectedNumberOfLines, lines.size, "Number of lines in the file should match") } diff --git a/wayang-api/wayang-api-sql/src/test/java/org/apache/wayang/api/sql/SqlToWayangRelTest.java b/wayang-api/wayang-api-sql/src/test/java/org/apache/wayang/api/sql/SqlToWayangRelTest.java index bd4bca54b..64372c40d 100755 --- a/wayang-api/wayang-api-sql/src/test/java/org/apache/wayang/api/sql/SqlToWayangRelTest.java +++ b/wayang-api/wayang-api-sql/src/test/java/org/apache/wayang/api/sql/SqlToWayangRelTest.java @@ -19,14 +19,12 @@ import org.apache.calcite.jdbc.JavaTypeFactoryImpl; import org.apache.calcite.rel.RelNode; -import org.apache.calcite.rel.externalize.RelWriterImpl; import org.apache.calcite.rel.rules.CoreRules; import org.apache.calcite.rel.type.RelDataType; import org.apache.calcite.rel.type.RelDataTypeFactory; import org.apache.calcite.rex.RexBuilder; import org.apache.calcite.rex.RexCall; import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlExplainLevel; import org.apache.calcite.sql.SqlNode; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.fun.SqlStdOperatorTable; @@ -34,43 +32,33 @@ import org.apache.calcite.sql.type.SqlTypeName; import org.apache.calcite.tools.RuleSet; import org.apache.calcite.tools.RuleSets; - import org.apache.wayang.api.sql.calcite.convention.WayangConvention; import org.apache.wayang.api.sql.calcite.converter.functions.FilterPredicateImpl; import org.apache.wayang.api.sql.calcite.converter.functions.ProjectMapFuncImpl; import org.apache.wayang.api.sql.calcite.optimizer.Optimizer; import org.apache.wayang.api.sql.calcite.rules.WayangRules; import org.apache.wayang.api.sql.calcite.schema.SchemaUtils; -import org.apache.wayang.api.sql.calcite.schema.WayangSchema; -import org.apache.wayang.api.sql.calcite.schema.WayangSchemaBuilder; -import org.apache.wayang.api.sql.calcite.schema.WayangTable; -import org.apache.wayang.api.sql.calcite.schema.WayangTableBuilder; import org.apache.wayang.api.sql.calcite.utils.ModelParser; -import org.apache.wayang.api.sql.calcite.utils.PrintUtils; import org.apache.wayang.api.sql.context.SqlContext; +import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.function.FunctionDescriptor.SerializablePredicate; -import org.apache.wayang.core.plan.wayangplan.Operator; import org.apache.wayang.core.plan.wayangplan.PlanTraversal; import org.apache.wayang.core.plan.wayangplan.WayangPlan; import org.apache.wayang.java.Java; import org.apache.wayang.spark.Spark; -import org.apache.wayang.basic.data.Record; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; @@ -80,20 +68,24 @@ import java.util.Properties; import java.util.stream.Collectors; -public class SqlToWayangRelTest { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class SqlToWayangRelTest { /** * Method for building {@link WayangPlan}s useful for testing, benchmarking and * other * usages where you want to handle the intermediate {@link WayangPlan} - * + * * @param sql sql query string with the {@code ;} cut off * @param udfJars * @return a {@link WayangPlan} of a given sql string * @throws SqlParseException * @throws SQLException */ - public Tuple2, WayangPlan> buildCollectorAndWayangPlan(final SqlContext context, + private Tuple2, WayangPlan> buildCollectorAndWayangPlan(final SqlContext context, final String sql, final String... udfJars) throws SqlParseException, SQLException { final Properties configProperties = Optimizer.ConfigProperties.getDefaults(); final RelDataTypeFactory relDataTypeFactory = new JavaTypeFactoryImpl(); @@ -131,7 +123,7 @@ public Tuple2, WayangPlan> buildCollectorAndWayangPlan(final } @Test - public void javaJoinTest() throws Exception { + void javaJoinTest() throws Exception { final SqlContext sqlContext = this.createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, "SELECT * FROM fs.largeLeftTableIndex JOIN fs.exampleRefToRef ON largeLeftTableIndex.NAMEA = exampleRefToRef.NAMEA"); @@ -139,18 +131,16 @@ public void javaJoinTest() throws Exception { final WayangPlan wayangPlan = t.field1; // except reduce by - PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> { - node.addTargetPlatform(Java.platform()); - }); + PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> node.addTargetPlatform(Java.platform())); sqlContext.execute(wayangPlan); - assert (result.stream() + assertTrue(result.stream() .anyMatch(rec -> rec.equals(new Record("test1", "test1", "test2", "test1", "test1")))); } @Test - public void javaMultiConditionJoin() throws Exception { + void javaMultiConditionJoin() throws Exception { final SqlContext sqlContext = this.createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, "SELECT * FROM fs.largeLeftTableIndex JOIN fs.exampleRefToRef ON largeLeftTableIndex.NAMEB = exampleRefToRef.NAMEB AND largeLeftTableIndex.NAMEC = exampleRefToRef.NAMEB"); @@ -158,20 +148,18 @@ public void javaMultiConditionJoin() throws Exception { final WayangPlan wayangPlan = t.field1; // except reduce by - PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> { - node.addTargetPlatform(Java.platform()); - }); + PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> node.addTargetPlatform(Java.platform())); sqlContext.execute(wayangPlan); final boolean checkEq = result.stream() .allMatch(rec -> rec.equals(new Record("", "test2", "test2", "", "test2"))); - assert (checkEq); + assertTrue(checkEq); } @Test - public void aggregateCountInJavaWithIntegers() throws Exception { + void aggregateCountInJavaWithIntegers() throws Exception { final SqlContext sqlContext = this.createSqlContext("/data/exampleInt.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, "SELECT exampleInt.NAMEC, COUNT(*) FROM fs.exampleInt GROUP BY NAMEC"); @@ -179,19 +167,17 @@ public void aggregateCountInJavaWithIntegers() throws Exception { final WayangPlan wayangPlan = t.field1; // except reduce by - PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> { - node.addTargetPlatform(Java.platform()); - }); + PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> node.addTargetPlatform(Java.platform())); sqlContext.execute(wayangPlan); - final Record rec = result.stream().findFirst().get(); - assert (rec.size() == 2); - assert (rec.getInt(1) == 3); + final Record rec = result.stream().findFirst().orElseThrow(); + assertEquals(2, rec.size()); + assertEquals(3, rec.getInt(1)); } @Test - public void aggregateCountInJava() throws Exception { + void aggregateCountInJava() throws Exception { final SqlContext sqlContext = this.createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, "SELECT largeLeftTableIndex.NAMEC, COUNT(*) FROM fs.largeLeftTableIndex GROUP BY NAMEC"); @@ -199,19 +185,17 @@ public void aggregateCountInJava() throws Exception { final WayangPlan wayangPlan = t.field1; // except reduce by - PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> { - node.addTargetPlatform(Java.platform()); - }); + PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> node.addTargetPlatform(Java.platform())); sqlContext.execute(wayangPlan); - final Record rec = result.stream().findFirst().get(); - assert (rec.size() == 2); - assert (rec.getInt(1) == 3); + final Record rec = result.stream().findFirst().orElseThrow(); + assertEquals(2, rec.size()); + assertEquals(3, rec.getInt(1)); } @Test - public void filterIsNull() throws Exception { + void filterIsNull() throws Exception { final SqlContext sqlContext = this.createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -220,11 +204,11 @@ public void filterIsNull() throws Exception { final Collection result = t.field0; final WayangPlan wayangPlan = t.field1; sqlContext.execute(wayangPlan); - assert (result.size() == 0); + assertTrue(result.isEmpty()); } @Test - public void javaAverage() throws Exception { + void javaAverage() throws Exception { final SqlContext sqlContext = this.createSqlContext("/data/exampleSort.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -235,12 +219,12 @@ public void javaAverage() throws Exception { sqlContext.execute(wayangPlan); - assert (result.size() == 1); - assert (result.stream().findFirst().get().getDouble(0) == 0.875f); + assertEquals(1, result.size()); + assertEquals(0.875f, result.stream().findFirst().orElseThrow().getDouble(0)); } @Test - public void filterNotEqualsValue() throws Exception { + void filterNotEqualsValue() throws Exception { final SqlContext sqlContext = this.createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -252,11 +236,11 @@ public void filterNotEqualsValue() throws Exception { sqlContext.execute(wayangPlan); - assert (!result.stream().anyMatch(record -> record.getField(0).equals("test1"))); + assertTrue(result.stream().noneMatch(rec -> rec.getField(0).equals("test1"))); } @Test - public void filterIsNotNull() throws Exception { + void filterIsNotNull() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -267,11 +251,11 @@ public void filterIsNotNull() throws Exception { final WayangPlan wayangPlan = t.field1; sqlContext.execute(wayangPlan); - assert (!result.stream().anyMatch(record -> record.getField(0).equals(null))); + assertTrue(result.stream().noneMatch(rec -> rec.getField(0) == null)); } @Test - public void javaReduceBy() throws Exception { + void javaReduceBy() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan( @@ -281,17 +265,15 @@ public void javaReduceBy() throws Exception { final Collection result = t.field0; final WayangPlan wayangPlan = t.field1; - PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> { - node.addTargetPlatform(Java.platform()); - }); + PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> node.addTargetPlatform(Java.platform())); sqlContext.execute(wayangPlan); - assert (result.stream().anyMatch(rec -> rec.equals(new Record("item1", 2)))); + assertTrue(result.stream().anyMatch(rec -> rec.equals(new Record("item1", 2)))); } @Test - public void javaCrossJoin() throws Exception { + void javaCrossJoin() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan( @@ -316,11 +298,11 @@ public void javaCrossJoin() throws Exception { final Map shouldBeTally = shouldBe.stream() .collect(Collectors.toMap(rec -> rec, rec -> 1, Integer::sum)); - assert (resultTally.equals(shouldBeTally)); + assertEquals(resultTally, shouldBeTally); } @Test - public void filterWithNotLike() throws Exception { + void filterWithNotLike() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -331,11 +313,11 @@ public void filterWithNotLike() throws Exception { final WayangPlan wayangPlan = t.field1; sqlContext.execute(wayangPlan); - assert (!result.stream().anyMatch(record -> record.getString(0).equals("test1"))); + assertTrue(result.stream().noneMatch(rec -> rec.getString(0).equals("test1"))); } @Test - public void filterWithLike() throws Exception { + void filterWithLike() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -346,11 +328,11 @@ public void filterWithLike() throws Exception { final WayangPlan wayangPlan = t.field1; sqlContext.execute(wayangPlan); - assert (result.stream().anyMatch(rec -> rec.equals(new Record("test1", "test1", "test2")))); + assertTrue(result.stream().anyMatch(rec -> rec.equals(new Record("test1", "test1", "test2")))); } @Test - public void javaLimit() throws Exception { + void javaLimit() throws Exception { final SqlContext sqlContext = createSqlContext("/data/exampleSort.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -361,14 +343,14 @@ public void javaLimit() throws Exception { sqlContext.execute(wayangPlan); - final List result = r.stream().collect(Collectors.toList()); + final List result = new ArrayList<>(r); - assert (result.size() == 1); - assert (result.get(0).equals(new Record(2, "a", "a", 2))); + assertEquals(1, result.size()); + assertEquals(new Record(2, "a", "a", 2), result.get(0)); } @Test - public void javaLimitNoSort() throws Exception { + void javaLimitNoSort() throws Exception { final SqlContext sqlContext = createSqlContext("/data/exampleSort.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -379,13 +361,13 @@ public void javaLimitNoSort() throws Exception { sqlContext.execute(wayangPlan); - final List result = r.stream().collect(Collectors.toList()); + final List result = new ArrayList<>(r); - assert (result.size() == 2); + assertEquals(2, result.size()); } @Test - public void javaSort() throws Exception { + void javaSort() throws Exception { final SqlContext sqlContext = createSqlContext("/data/exampleSort.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -396,19 +378,19 @@ public void javaSort() throws Exception { sqlContext.execute(wayangPlan); - final List result = r.stream().collect(Collectors.toList()); + final List result = new ArrayList<>(r); - assert (result.get(0).equals(new Record(2, "a", "a", 2))); - assert (result.get(1).equals(new Record(1, "a", "b", 1))); - assert (result.get(2).equals(new Record(1, "a", "a", 1))); - assert (result.get(3).equals(new Record(1, "b", "b", 1))); - assert (result.get(4).equals(new Record(0, "a", "b", 1))); - assert (result.get(5).equals(new Record(0, "a", "a", 1))); - assert (result.get(6).equals(new Record(0, "b", "b", 1))); + assertEquals(new Record(2, "a", "a", 2), result.get(0)); + assertEquals(new Record(1, "a", "b", 1), result.get(1)); + assertEquals(new Record(1, "a", "a", 1), result.get(2)); + assertEquals(new Record(1, "b", "b", 1), result.get(3)); + assertEquals(new Record(0, "a", "b", 1), result.get(4)); + assertEquals(new Record(0, "a", "a", 1), result.get(5)); + assertEquals(new Record(0, "b", "b", 1), result.get(6)); } @Test - public void joinWithLargeLeftTableIndexCorrect() throws Exception { + void joinWithLargeLeftTableIndexCorrect() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -429,7 +411,7 @@ public void joinWithLargeLeftTableIndexCorrect() throws Exception { final Map shouldBeTally = shouldBe.stream() .collect(Collectors.toMap(rec -> rec, rec -> 1, Integer::sum)); - assert (resultTally.equals(shouldBeTally)); + assertEquals(resultTally, shouldBeTally); } // Imagine case: l = {item1, item2}, r = {item3,item4}, j = {item1, item2, @@ -439,7 +421,7 @@ public void joinWithLargeLeftTableIndexCorrect() throws Exception { // that it is always ordered as =(lRef,rRef), lRef < rRef. // it may also be =($3,$1) @Test - public void joinWithLargeLeftTableIndexMirrorAlias() throws Exception { + void joinWithLargeLeftTableIndexMirrorAlias() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -460,11 +442,11 @@ public void joinWithLargeLeftTableIndexMirrorAlias() throws Exception { final Map shouldBeTally = shouldBe.stream() .collect(Collectors.toMap(rec -> rec, rec -> 1, Integer::sum)); - assert (resultTally.equals(shouldBeTally)); + assertEquals(resultTally, shouldBeTally); } @Test - public void sparkFilter() throws Exception { + void sparkFilter() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -474,17 +456,15 @@ public void sparkFilter() throws Exception { final Collection result = t.field0; final WayangPlan wayangPlan = t.field1; - PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> { - node.addTargetPlatform(Spark.platform()); - }); + PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> node.addTargetPlatform(Spark.platform())); sqlContext.execute(wayangPlan); - assert (result.stream().anyMatch(rec -> rec.equals(new Record("test1", "test1", "test2")))); + assertTrue(result.stream().anyMatch(rec -> rec.equals(new Record("test1", "test1", "test2")))); } @Test - public void sparkAggregate() throws Exception { + void sparkAggregate() throws Exception { final SqlContext sqlContext = this.createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, "SELECT largeLeftTableIndex.NAMEC, COUNT(*) FROM fs.largeLeftTableIndex GROUP BY NAMEC"); @@ -492,20 +472,18 @@ public void sparkAggregate() throws Exception { final WayangPlan wayangPlan = t.field1; // except reduce by - PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> { - node.addTargetPlatform(Spark.platform()); - }); + PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> node.addTargetPlatform(Spark.platform())); sqlContext.execute(wayangPlan); - final Record rec = result.stream().findFirst().get(); - assert (rec.size() == 2); - assert (rec.getInt(1) == 3); + final Record rec = result.stream().findFirst().orElseThrow(); + assertEquals(2, rec.size()); + assertEquals(3, rec.getInt(1)); } // tests sql-apis ability to serialize projections and joins @Test - public void sparkInnerJoin() throws Exception { + void sparkInnerJoin() throws Exception { final SqlContext sqlContext = createSqlContext("/data/largeLeftTableIndex.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -515,9 +493,7 @@ public void sparkInnerJoin() throws Exception { final Collection result = t.field0; final WayangPlan wayangPlan = t.field1; - PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> { - node.addTargetPlatform(Spark.platform()); - }); + PlanTraversal.upstream().traverse(wayangPlan.getSinks()).getTraversedNodes().forEach(node -> node.addTargetPlatform(Spark.platform())); sqlContext.execute(wayangPlan); @@ -531,11 +507,11 @@ public void sparkInnerJoin() throws Exception { final Map shouldBeTally = shouldBe.stream() .collect(Collectors.toMap(rec -> rec, rec -> 1, Integer::sum)); - assert (resultTally.equals(shouldBeTally)); + assertEquals(resultTally, shouldBeTally); } @Test - public void serializeProjection() throws Exception { + void serializeProjection() throws Exception { final RexBuilder rb = new RexBuilder(new JavaTypeFactoryImpl()); final RelDataTypeFactory typeFactory = rb.getTypeFactory(); @@ -566,10 +542,10 @@ public void serializeProjection() throws Exception { final ObjectInputStream inStream = new ObjectInputStream(byteInStream); final ProjectMapFuncImpl deserializedImpl = (ProjectMapFuncImpl) inStream.readObject(); inStream.close(); - + final Record testRecord = new Record(1,2,3); - assert (impl.apply(testRecord).equals(deserializedImpl.apply(testRecord))); + assertEquals(impl.apply(testRecord), deserializedImpl.apply(testRecord)); } @Test @@ -593,11 +569,11 @@ public void serializeFilter() throws Exception { final Object deserializedObject = objectInputStream.readObject(); objectInputStream.close(); - assert (((FilterPredicateImpl) deserializedObject).test(new Record("test"))); + assertTrue(((FilterPredicateImpl) deserializedObject).test(new Record("test"))); } @Test - public void exampleFilterTableRefToTableRef() throws Exception { + void exampleFilterTableRefToTableRef() throws Exception { final SqlContext sqlContext = createSqlContext("/data/exampleRefToRef.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -608,11 +584,11 @@ public void exampleFilterTableRefToTableRef() throws Exception { final WayangPlan wayangPlan = t.field1; sqlContext.execute(wayangPlan); - assert (result.stream().anyMatch(rec -> rec.equals(new Record("test1", "test1")))); + assertTrue(result.stream().anyMatch(rec -> rec.equals(new Record("test1", "test1")))); } @Test - public void exampleMinWithStrings() throws Exception { + void exampleMinWithStrings() throws Exception { final SqlContext sqlContext = createSqlContext("/data/exampleMin.csv"); final Tuple2, WayangPlan> t = this.buildCollectorAndWayangPlan(sqlContext, @@ -622,7 +598,7 @@ public void exampleMinWithStrings() throws Exception { final WayangPlan wayangPlan = t.field1; sqlContext.execute(wayangPlan); - assert (result.stream().findAny().get().getString(0).equals("AA")); + assertEquals("AA", result.stream().findAny().orElseThrow().getString(0)); } private SqlContext createSqlContext(final String tableResourceName) @@ -646,18 +622,15 @@ private SqlContext createSqlContext(final String tableResourceName) " \"separator\": \";\"\r\n" + // " }\r\n" + // " \r\n" + // - " \r\n" + // - ""; + " \r\n"; final JSONObject calciteModelJSON = (JSONObject) new JSONParser().parse(calciteModel); final Configuration configuration = new ModelParser(new Configuration(), calciteModelJSON) .setProperties(); - assert (configuration != null) - : "Could not get configuration with calcite model: " + calciteModel; + assertNotNull(configuration,"Could not get configuration with calcite model: " + calciteModel); final String dataPath = this.getClass().getResource(tableResourceName).getPath(); - assert (dataPath != null && dataPath != "") - : "Could not get table resource from path: " + tableResourceName; + assertTrue(dataPath != null && !dataPath.isEmpty(), "Could not get table resource from path: " + tableResourceName); configuration.setProperty("wayang.fs.table.url", dataPath); diff --git a/wayang-applications/pom.xml b/wayang-applications/pom.xml index 834879650..dbc3f3263 100644 --- a/wayang-applications/pom.xml +++ b/wayang-applications/pom.xml @@ -52,7 +52,7 @@ 0.8.9 2.10.6 2.4.0 - 5.10.2 + 5.12.2 5.11.0 @@ -113,9 +113,9 @@ - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter + test diff --git a/wayang-benchmark/src/test/java/org/apache/wayang/apps/tpch/data/LineItemTupleTest.java b/wayang-benchmark/src/test/java/org/apache/wayang/apps/tpch/data/LineItemTupleTest.java index 506a0cbdc..e5385f0de 100644 --- a/wayang-benchmark/src/test/java/org/apache/wayang/apps/tpch/data/LineItemTupleTest.java +++ b/wayang-benchmark/src/test/java/org/apache/wayang/apps/tpch/data/LineItemTupleTest.java @@ -18,40 +18,41 @@ package org.apache.wayang.apps.tpch.data; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Calendar; import java.util.GregorianCalendar; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suited for {@link LineItemTuple}. */ -public class LineItemTupleTest { +class LineItemTupleTest { @Test - public void testParser() { + void testParser() { LineItemTuple.Parser parser = new LineItemTuple.Parser(); final LineItemTuple tuple = parser.parse("\"3249925\";\"37271\";\"9775\";\"1\";\"9.00\";\"10874.43\";\"0.10\";" + "\"0.04\";\"N\";\"O\";\"1998-04-19\";\"1998-06-17\";\"1998-04-21\";\"TAKE BACK RETURN \";" + "\"AIR \";\"express instructions among the excuses nag\""); - Assert.assertEquals(3249925, tuple.L_ORDERKEY); - Assert.assertEquals(37271, tuple.L_PARTKEY); - Assert.assertEquals(9775, tuple.L_SUPPKEY); - Assert.assertEquals(1, tuple.L_LINENUMBER); - Assert.assertEquals(9.00, tuple.L_QUANTITY, 0); - Assert.assertEquals(10874.43, tuple.L_EXTENDEDPRICE, 0.001); - Assert.assertEquals(0.10, tuple.L_DISCOUNT, 0.001); - Assert.assertEquals(0.04, tuple.L_TAX, 0.001); - Assert.assertEquals('N', tuple.L_RETURNFLAG); - Assert.assertEquals('O', tuple.L_LINESTATUS); - Assert.assertEquals(this.toDateInteger(1998, 4, 19), tuple.L_SHIPDATE); - Assert.assertEquals(this.toDateInteger(1998, 6, 17), tuple.L_COMMITDATE); - Assert.assertEquals(this.toDateInteger(1998, 4, 21), tuple.L_RECEIPTDATE); - Assert.assertEquals("TAKE BACK RETURN ", tuple.L_SHIPINSTRUCT); - Assert.assertEquals("AIR ", tuple.L_SHIPMODE); - Assert.assertEquals("express instructions among the excuses nag", tuple.L_COMMENT); + assertEquals(3249925, tuple.L_ORDERKEY); + assertEquals(37271, tuple.L_PARTKEY); + assertEquals(9775, tuple.L_SUPPKEY); + assertEquals(1, tuple.L_LINENUMBER); + assertEquals(9.00, tuple.L_QUANTITY, 0); + assertEquals(10874.43, tuple.L_EXTENDEDPRICE, 0.001); + assertEquals(0.10, tuple.L_DISCOUNT, 0.001); + assertEquals(0.04, tuple.L_TAX, 0.001); + assertEquals('N', tuple.L_RETURNFLAG); + assertEquals('O', tuple.L_LINESTATUS); + assertEquals(this.toDateInteger(1998, 4, 19), tuple.L_SHIPDATE); + assertEquals(this.toDateInteger(1998, 6, 17), tuple.L_COMMITDATE); + assertEquals(this.toDateInteger(1998, 4, 21), tuple.L_RECEIPTDATE); + assertEquals("TAKE BACK RETURN ", tuple.L_SHIPINSTRUCT); + assertEquals("AIR ", tuple.L_SHIPMODE); + assertEquals("express instructions among the excuses nag", tuple.L_COMMENT); } private int toDateInteger(int year, int month, int date) { diff --git a/wayang-benchmark/src/test/scala/org/apache/wayang/apps/kmeans/KmeansTest.scala b/wayang-benchmark/src/test/scala/org/apache/wayang/apps/kmeans/KmeansTest.scala index 53d6fead1..8a96a3041 100644 --- a/wayang-benchmark/src/test/scala/org/apache/wayang/apps/kmeans/KmeansTest.scala +++ b/wayang-benchmark/src/test/scala/org/apache/wayang/apps/kmeans/KmeansTest.scala @@ -19,8 +19,8 @@ package org.apache.wayang.apps.kmeans import org.apache.wayang.commons.util.profiledb.model.{Experiment, Subject} -import org.junit.Assert._ -import org.junit.Test +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api.Test; import org.apache.wayang.core.api.Configuration import org.apache.wayang.java.Java import org.apache.wayang.spark.Spark diff --git a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/function/ProjectionDescriptorTest.java b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/function/ProjectionDescriptorTest.java index 453226434..72f60994d 100644 --- a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/function/ProjectionDescriptorTest.java +++ b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/function/ProjectionDescriptorTest.java @@ -18,35 +18,34 @@ package org.apache.wayang.basic.function; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.types.RecordType; +import org.junit.jupiter.api.Test; import java.util.function.Function; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + /** * Tests for the {@link ProjectionDescriptor}. */ -public class ProjectionDescriptorTest { +class ProjectionDescriptorTest { @Test - public void testPojoImplementation() { + void testPojoImplementation() { final ProjectionDescriptor stringDescriptor = new ProjectionDescriptor<>(Pojo.class, String.class, "string"); final Function stringImplementation = stringDescriptor.getJavaImplementation(); final ProjectionDescriptor integerDescriptor = new ProjectionDescriptor<>(Pojo.class, Integer.class, "integer"); final Function integerImplementation = integerDescriptor.getJavaImplementation(); - Assert.assertEquals( + assertEquals( "testValue", stringImplementation.apply(new Pojo("testValue", 1)) ); - Assert.assertEquals( - null, - stringImplementation.apply(new Pojo(null, 1)) - ); - Assert.assertEquals( + assertNull(stringImplementation.apply(new Pojo(null, 1))); + assertEquals( Integer.valueOf(1), integerImplementation.apply(new Pojo("testValue", 1)) ); @@ -54,13 +53,13 @@ public void testPojoImplementation() { } @Test - public void testRecordImplementation() { + void testRecordImplementation() { RecordType inputType = new RecordType("a", "b", "c"); final ProjectionDescriptor descriptor = ProjectionDescriptor.createForRecords(inputType, "c", "a"); - Assert.assertEquals(new RecordType("c", "a"), descriptor.getOutputType()); + assertEquals(new RecordType("c", "a"), descriptor.getOutputType()); final Function javaImplementation = descriptor.getJavaImplementation(); - Assert.assertEquals( + assertEquals( new Record("world", 10), javaImplementation.apply(new Record(10, "hello", "world")) ); diff --git a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/mapping/ReduceByMappingTest.java b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/mapping/ReduceByMappingTest.java index 20d5a63f4..4a3ee742b 100644 --- a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/mapping/ReduceByMappingTest.java +++ b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/mapping/ReduceByMappingTest.java @@ -18,8 +18,7 @@ package org.apache.wayang.basic.mapping; -import org.junit.Assert; -import org.junit.Test; + import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.basic.operators.GroupByOperator; @@ -36,14 +35,18 @@ import org.apache.wayang.core.plan.wayangplan.UnarySource; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; /** * Test suite for the {@link ReduceByMapping}. */ -public class ReduceByMappingTest { +class ReduceByMappingTest { @Test - public void testMapping() { + void testMapping() { // Construct a plan: source -> groupBy -> reduce -> sink. UnarySource> source = new TestSource<>(DataSetType.createDefault(Tuple2.class)); @@ -83,10 +86,10 @@ public void testMapping() { // Check that now we have this plan: source -> reduceBy -> sink. final Operator finalSink = plan.getSinks().iterator().next(); final Operator inputOperator = finalSink.getEffectiveOccupant(0).getOwner(); - Assert.assertTrue(inputOperator instanceof ReduceByOperator); + assertInstanceOf(ReduceByOperator.class, inputOperator); ReduceByOperator reduceBy = (ReduceByOperator) inputOperator; - Assert.assertEquals(keyDescriptor, reduceBy.getKeyDescriptor()); - Assert.assertEquals(reduceDescriptor, reduceBy.getReduceDescriptor()); - Assert.assertEquals(source, reduceBy.getEffectiveOccupant(0).getOwner()); + assertEquals(keyDescriptor, reduceBy.getKeyDescriptor()); + assertEquals(reduceDescriptor, reduceBy.getReduceDescriptor()); + assertEquals(source, reduceBy.getEffectiveOccupant(0).getOwner()); } } diff --git a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/model/op/OpTest.java b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/model/op/OpTest.java index d4af8aa26..3fa46c8a0 100644 --- a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/model/op/OpTest.java +++ b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/model/op/OpTest.java @@ -22,12 +22,12 @@ import org.apache.wayang.basic.model.op.nn.CrossEntropyLoss; import org.apache.wayang.basic.model.op.nn.Linear; import org.apache.wayang.basic.model.op.nn.ReLU; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class OpTest { +class OpTest { @Test - public void testBuild() { + void testBuild() { // model Linear l1 = new Linear(4, 4, true, "l1"); ReLU r1 = new ReLU("r1"); diff --git a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/operators/MaterializedGroupByOperatorTest.java b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/operators/MaterializedGroupByOperatorTest.java index d5f21a791..f165798b4 100644 --- a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/operators/MaterializedGroupByOperatorTest.java +++ b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/operators/MaterializedGroupByOperatorTest.java @@ -18,20 +18,20 @@ package org.apache.wayang.basic.operators; -import org.junit.Test; import org.apache.wayang.core.function.TransformationDescriptor; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; +import org.junit.jupiter.api.Test; import java.util.stream.StreamSupport; /** * Tests for the {@link MaterializedGroupByOperator}. */ -public class MaterializedGroupByOperatorTest { +class MaterializedGroupByOperatorTest { @Test - public void testConnectingToMap() { + void testConnectingToMap() { final MaterializedGroupByOperator materializedGroupByOperator = new MaterializedGroupByOperator<>(String::length, String.class, Integer.class); final MapOperator, Integer> mapOperator = new MapOperator<>( diff --git a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/operators/TextFileSourceTest.java b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/operators/TextFileSourceTest.java index 83b78105c..a41821cc7 100644 --- a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/operators/TextFileSourceTest.java +++ b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/operators/TextFileSourceTest.java @@ -22,8 +22,6 @@ import org.apache.wayang.commons.util.profiledb.instrumentation.StopWatch; import org.apache.wayang.commons.util.profiledb.model.Experiment; import org.apache.wayang.commons.util.profiledb.model.Subject; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; @@ -31,7 +29,7 @@ import org.apache.wayang.core.optimizer.cardinality.CardinalityEstimator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import org.junit.jupiter.api.Test; import java.io.BufferedReader; import java.io.File; @@ -42,18 +40,19 @@ import java.net.URL; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * Test suite for {@link TextFileSource}. */ -public class TextFileSourceTest { +class TextFileSourceTest { private final Logger logger = LogManager.getLogger(this.getClass()); @Test - public void testCardinalityEstimation() throws URISyntaxException, IOException { + void testCardinalityEstimation() throws URISyntaxException, IOException { Job job = mock(Job.class); DefaultOptimizationContext optimizationContext = mock(DefaultOptimizationContext.class); when(job.getOptimizationContext()).thenReturn(optimizationContext); @@ -84,7 +83,7 @@ public void testCardinalityEstimation() throws URISyntaxException, IOException { final Optional cardinalityEstimator = textFileSource .createCardinalityEstimator(0, optimizationContext.getConfiguration()); - Assert.assertTrue(cardinalityEstimator.isPresent()); + assertTrue(cardinalityEstimator.isPresent()); final CardinalityEstimate estimate = cardinalityEstimator.get().estimate(optimizationContext); this.logger.info("Estimated between {} and {} lines in {} and counted {}.", @@ -93,8 +92,8 @@ public void testCardinalityEstimation() throws URISyntaxException, IOException { testFile, numLineFeeds); - Assert.assertTrue(estimate.getLowerEstimate() <= numLineFeeds); - Assert.assertTrue(estimate.getUpperEstimate() >= numLineFeeds); + assertTrue(estimate.getLowerEstimate() <= numLineFeeds); + assertTrue(estimate.getUpperEstimate() >= numLineFeeds); } } diff --git a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/types/RecordTypeTest.java b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/types/RecordTypeTest.java index 9d8b4724e..7fccc2e1b 100644 --- a/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/types/RecordTypeTest.java +++ b/wayang-commons/wayang-basic/src/test/java/org/apache/wayang/basic/types/RecordTypeTest.java @@ -18,29 +18,31 @@ package org.apache.wayang.basic.types; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.core.types.DataSetType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests for the {@link RecordType}. */ -public class RecordTypeTest { +class RecordTypeTest { @Test - public void testSupertype() { + void testSupertype() { DataSetType t1 = DataSetType.createDefault(Record.class); DataSetType t2 = DataSetType.createDefault(new RecordType("a", "b")); DataSetType t3 = DataSetType.createDefault(new RecordType("a", "b", "c")); - Assert.assertTrue(t1.isSupertypeOf(t2)); - Assert.assertFalse(t2.isSupertypeOf(t1)); - Assert.assertTrue(t1.isSupertypeOf(t3)); - Assert.assertFalse(t3.isSupertypeOf(t1)); - Assert.assertTrue(t2.isSupertypeOf(t2)); - Assert.assertFalse(t2.isSupertypeOf(t3)); - Assert.assertTrue(t3.isSupertypeOf(t3)); - Assert.assertFalse(t3.isSupertypeOf(t2)); + assertTrue(t1.isSupertypeOf(t2)); + assertFalse(t2.isSupertypeOf(t1)); + assertTrue(t1.isSupertypeOf(t3)); + assertFalse(t3.isSupertypeOf(t1)); + assertTrue(t2.isSupertypeOf(t2)); + assertFalse(t2.isSupertypeOf(t3)); + assertTrue(t3.isSupertypeOf(t3)); + assertFalse(t3.isSupertypeOf(t2)); } } diff --git a/wayang-commons/wayang-core/pom.xml b/wayang-commons/wayang-core/pom.xml index 784a54187..10157ec72 100644 --- a/wayang-commons/wayang-core/pom.xml +++ b/wayang-commons/wayang-core/pom.xml @@ -124,6 +124,12 @@ httpclient 4.5.13 + + + org.junit.jupiter + junit-jupiter + test + diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/SlotTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/SlotTest.java index ebc8e8af2..112d20ce7 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/SlotTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/SlotTest.java @@ -18,28 +18,31 @@ package org.apache.wayang.core; -import org.junit.Test; import org.apache.wayang.core.plan.wayangplan.Slot; import org.apache.wayang.core.plan.wayangplan.test.TestSink; import org.apache.wayang.core.plan.wayangplan.test.TestSource; import org.apache.wayang.core.test.TestDataUnit; import org.apache.wayang.core.test.TestDataUnit2; import org.apache.wayang.core.types.DataSetType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Test suite for {@link Slot}s. */ -public class SlotTest { +class SlotTest { - @Test(expected = IllegalArgumentException.class) - public void testConnectMismatchingSlotFails() { + @Test + void testConnectMismatchingSlotFails() { TestSink testSink = new TestSink<>(DataSetType.createDefault(TestDataUnit.class)); TestSource testSource = new TestSource<>(DataSetType.createDefault(TestDataUnit2.class)); - testSource.connectTo(0, testSink, 0); + assertThrows(IllegalArgumentException.class, () -> + testSource.connectTo(0, testSink, 0)); } @Test - public void testConnectMatchingSlots() { + void testConnectMatchingSlots() { TestSink testSink = new TestSink<>(DataSetType.createDefault(TestDataUnit.class)); TestSource testSource = new TestSource<>(DataSetType.createDefault(TestDataUnit.class)); testSource.connectTo(0, testSink, 0); diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/OperatorPatternTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/OperatorPatternTest.java index 1cc7101e6..2d03674ff 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/OperatorPatternTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/OperatorPatternTest.java @@ -18,29 +18,31 @@ package org.apache.wayang.core.mapping; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.test.DummyExecutionOperator; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests for {@link OperatorPattern}. */ -public class OperatorPatternTest { +class OperatorPatternTest { @Test - public void testAdditionalTests() { + void testAdditionalTests() { DummyExecutionOperator operator1 = new DummyExecutionOperator(1, 1, true); DummyExecutionOperator operator2 = new DummyExecutionOperator(1, 1, true); OperatorPattern pattern = new OperatorPattern<>("test", operator1, false); // The pattern should, of course, now match the operators. - Assert.assertNotNull(pattern.match(operator1)); - Assert.assertNotNull(pattern.match(operator2)); + assertNotNull(pattern.match(operator1)); + assertNotNull(pattern.match(operator2)); // The following test now should restrict the matching operators to operator1. pattern.withAdditionalTest(op -> op == operator1); - Assert.assertNotNull(pattern.match(operator1)); - Assert.assertNull(pattern.match(operator2)); + assertNotNull(pattern.match(operator1)); + assertNull(pattern.match(operator2)); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/PlanTransformationTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/PlanTransformationTest.java index d98cbb8ce..9b09057b4 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/PlanTransformationTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/PlanTransformationTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.core.mapping; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.mapping.test.TestSinkToTestSink2Factory; import org.apache.wayang.core.plan.wayangplan.Operator; import org.apache.wayang.core.plan.wayangplan.OperatorAlternative; @@ -31,14 +29,18 @@ import org.apache.wayang.core.plan.wayangplan.test.TestSource; import org.apache.wayang.core.test.TestDataUnit; import org.apache.wayang.core.types.DataSetType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; /** * Test suite for the {@link org.apache.wayang.core.mapping.PlanTransformation} class. */ -public class PlanTransformationTest { +class PlanTransformationTest { @Test - public void testReplace() { + void testReplace() { // Build the plan. UnarySource source = new TestSource(DataSetType.createDefault(TestDataUnit.class)); UnarySink sink = new TestSink(DataSetType.createDefault(TestDataUnit.class)); @@ -58,14 +60,14 @@ public void testReplace() { planTransformation.transform(plan, Operator.FIRST_EPOCH + 1); // Check the correctness of the transformation. - Assert.assertEquals(1, plan.getSinks().size()); + assertEquals(1, plan.getSinks().size()); final Operator replacedSink = plan.getSinks().iterator().next(); - Assert.assertTrue(replacedSink instanceof TestSink2); - Assert.assertEquals(source, replacedSink.getEffectiveOccupant(0).getOwner()); + assertInstanceOf(TestSink2.class, replacedSink); + assertEquals(source, replacedSink.getEffectiveOccupant(0).getOwner()); } @Test - public void testIntroduceAlternative() { + void testIntroduceAlternative() { // Build the plan. UnarySource source = new TestSource(DataSetType.createDefault(TestDataUnit.class)); UnarySink sink = new TestSink(DataSetType.createDefault(TestDataUnit.class)); @@ -85,18 +87,18 @@ public void testIntroduceAlternative() { planTransformation.transform(plan, Operator.FIRST_EPOCH + 1); // Check the correctness of the transformation. - Assert.assertEquals(1, plan.getSinks().size()); + assertEquals(1, plan.getSinks().size()); final Operator replacedSink = plan.getSinks().iterator().next(); - Assert.assertTrue(replacedSink instanceof OperatorAlternative); + assertInstanceOf(OperatorAlternative.class, replacedSink); OperatorAlternative operatorAlternative = (OperatorAlternative) replacedSink; - Assert.assertEquals(2, operatorAlternative.getAlternatives().size()); - Assert.assertTrue(operatorAlternative.getAlternatives().get(0).getContainedOperator() instanceof TestSink); - Assert.assertTrue(operatorAlternative.getAlternatives().get(1).getContainedOperator() instanceof TestSink2); - Assert.assertEquals(source, replacedSink.getEffectiveOccupant(0).getOwner()); + assertEquals(2, operatorAlternative.getAlternatives().size()); + assertInstanceOf(TestSink.class, operatorAlternative.getAlternatives().get(0).getContainedOperator()); + assertInstanceOf(TestSink2.class, operatorAlternative.getAlternatives().get(1).getContainedOperator()); + assertEquals(source, replacedSink.getEffectiveOccupant(0).getOwner()); } @Test - public void testFlatAlternatives() { + void testFlatAlternatives() { // Build the plan. UnarySource source = new TestSource(DataSetType.createDefault(TestDataUnit.class)); UnarySink sink = new TestSink(DataSetType.createDefault(TestDataUnit.class)); @@ -117,15 +119,15 @@ public void testFlatAlternatives() { planTransformation.transform(plan, Operator.FIRST_EPOCH + 1); // Check the correctness of the transformation. - Assert.assertEquals(1, plan.getSinks().size()); + assertEquals(1, plan.getSinks().size()); final Operator replacedSink = plan.getSinks().iterator().next(); - Assert.assertTrue(replacedSink instanceof OperatorAlternative); + assertInstanceOf(OperatorAlternative.class, replacedSink); OperatorAlternative operatorAlternative = (OperatorAlternative) replacedSink; - Assert.assertEquals(3, operatorAlternative.getAlternatives().size()); - Assert.assertTrue(operatorAlternative.getAlternatives().get(0).getContainedOperator() instanceof TestSink); - Assert.assertTrue(operatorAlternative.getAlternatives().get(1).getContainedOperator() instanceof TestSink2); - Assert.assertTrue(operatorAlternative.getAlternatives().get(2).getContainedOperator() instanceof TestSink2); - Assert.assertEquals(source, replacedSink.getEffectiveOccupant(0).getOwner()); + assertEquals(3, operatorAlternative.getAlternatives().size()); + assertInstanceOf(TestSink.class, operatorAlternative.getAlternatives().get(0).getContainedOperator()); + assertInstanceOf(TestSink2.class, operatorAlternative.getAlternatives().get(1).getContainedOperator()); + assertInstanceOf(TestSink2.class, operatorAlternative.getAlternatives().get(2).getContainedOperator()); + assertEquals(source, replacedSink.getEffectiveOccupant(0).getOwner()); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/SubplanPatternTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/SubplanPatternTest.java index dec530be0..cfd3b3ece 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/SubplanPatternTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/mapping/SubplanPatternTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.core.mapping; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.plan.wayangplan.Operator; import org.apache.wayang.core.plan.wayangplan.WayangPlan; import org.apache.wayang.core.plan.wayangplan.UnarySink; @@ -28,16 +26,19 @@ import org.apache.wayang.core.plan.wayangplan.test.TestSource; import org.apache.wayang.core.test.TestDataUnit; import org.apache.wayang.core.types.DataSetType; +import org.junit.jupiter.api.Test; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for the {@link SubplanPattern}. */ -public class SubplanPatternTest { +class SubplanPatternTest { @Test - public void testMatchSinkPattern() { + void testMatchSinkPattern() { // Build the plan. UnarySource source = new TestSource(DataSetType.createDefault(TestDataUnit.class)); UnarySink sink = new TestSink(DataSetType.createDefault(TestDataUnit.class)); @@ -53,13 +54,13 @@ public void testMatchSinkPattern() { final List matches = subplanPattern.match(plan, Operator.FIRST_EPOCH); // Evaluate the matches. - Assert.assertEquals(1, matches.size()); + assertEquals(1, matches.size()); final SubplanMatch match = matches.get(0); - Assert.assertEquals(sink, match.getOperatorMatches().get("sink").getOperator()); + assertEquals(sink, match.getOperatorMatches().get("sink").getOperator()); } @Test - public void testMatchSourcePattern() { + void testMatchSourcePattern() { // Build the plan. UnarySource source = new TestSource(DataSetType.createDefault(TestDataUnit.class)); UnarySink sink = new TestSink(DataSetType.createDefault(TestDataUnit.class)); @@ -75,13 +76,13 @@ public void testMatchSourcePattern() { final List matches = subplanPattern.match(plan, Operator.FIRST_EPOCH); // Evaluate the matches. - Assert.assertEquals(1, matches.size()); + assertEquals(1, matches.size()); final SubplanMatch match = matches.get(0); - Assert.assertEquals(source, match.getOperatorMatches().get("source").getOperator()); + assertEquals(source, match.getOperatorMatches().get("source").getOperator()); } @Test - public void testMatchChainedPattern() { + void testMatchChainedPattern() { // Build the plan. UnarySource source = new TestSource(DataSetType.createDefault(TestDataUnit.class)); UnarySink sink = new TestSink(DataSetType.createDefault(TestDataUnit.class)); @@ -99,10 +100,10 @@ public void testMatchChainedPattern() { final List matches = subplanPattern.match(plan, Operator.FIRST_EPOCH); // Evaluate the matches. - Assert.assertEquals(1, matches.size()); + assertEquals(1, matches.size()); final SubplanMatch match = matches.get(0); - Assert.assertEquals(source, match.getOperatorMatches().get("source").getOperator()); - Assert.assertEquals(sink, match.getOperatorMatches().get("sink").getOperator()); + assertEquals(source, match.getOperatorMatches().get("source").getOperator()); + assertEquals(sink, match.getOperatorMatches().get("sink").getOperator()); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/AggregatingCardinalityEstimatorTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/AggregatingCardinalityEstimatorTest.java index e72d942d3..cfac1fe8c 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/AggregatingCardinalityEstimatorTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/AggregatingCardinalityEstimatorTest.java @@ -18,23 +18,23 @@ package org.apache.wayang.core.optimizer.cardinality; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.optimizer.OptimizationContext; +import org.junit.jupiter.api.Test; import java.util.Arrays; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * Test suite for {@link AggregatingCardinalityEstimator}. */ -public class AggregatingCardinalityEstimatorTest { +class AggregatingCardinalityEstimatorTest { @Test - public void testEstimate() { + void testEstimate() { OptimizationContext optimizationContext = mock(OptimizationContext.class); when(optimizationContext.getConfiguration()).thenReturn(new Configuration()); @@ -48,7 +48,7 @@ public void testEstimate() { CardinalityEstimate outputEstimate = estimator.estimate(optimizationContext, inputEstimate); CardinalityEstimate expectedEstimate = new CardinalityEstimate(2 * 10, 2 * 100, 0.3 * 0.9); - Assert.assertEquals(expectedEstimate, outputEstimate); + assertEquals(expectedEstimate, outputEstimate); } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/DefaultCardinalityEstimatorTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/DefaultCardinalityEstimatorTest.java index 44584a32c..fa9e08c59 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/DefaultCardinalityEstimatorTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/DefaultCardinalityEstimatorTest.java @@ -21,9 +21,9 @@ import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.function.FunctionDescriptor; import org.apache.wayang.core.optimizer.OptimizationContext; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -31,10 +31,10 @@ /** * Test suite for the {@link DefaultCardinalityEstimator}. */ -public class DefaultCardinalityEstimatorTest { +class DefaultCardinalityEstimatorTest { @Test - public void testBinaryInputEstimation() { + void testBinaryInputEstimation() { OptimizationContext optimizationContext = mock(OptimizationContext.class); when(optimizationContext.getConfiguration()).thenReturn(new Configuration()); @@ -53,9 +53,9 @@ public void testBinaryInputEstimation() { CardinalityEstimate estimate = estimator.estimate(optimizationContext, inputEstimate1, inputEstimate2); - Assert.assertEquals(0.9 * 0.4, estimate.getCorrectnessProbability(), 0.001); - Assert.assertEquals(singlePointEstimator.applyAsLong(new long[]{50, 10}), estimate.getLowerEstimate()); - Assert.assertEquals(singlePointEstimator.applyAsLong(new long[]{60, 100}), estimate.getUpperEstimate()); + assertEquals(0.9 * 0.4, estimate.getCorrectnessProbability(), 0.001); + assertEquals(singlePointEstimator.applyAsLong(new long[]{50, 10}), estimate.getLowerEstimate()); + assertEquals(singlePointEstimator.applyAsLong(new long[]{60, 100}), estimate.getUpperEstimate()); } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/LoopSubplanCardinalityPusherTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/LoopSubplanCardinalityPusherTest.java index 5a4583e2e..81c08936a 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/LoopSubplanCardinalityPusherTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/LoopSubplanCardinalityPusherTest.java @@ -18,10 +18,9 @@ package org.apache.wayang.core.optimizer.cardinality; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; + import org.apache.wayang.core.api.Configuration; + import org.apache.wayang.core.api.Job; import org.apache.wayang.core.api.configuration.FunctionalKeyValueProvider; import org.apache.wayang.core.api.configuration.KeyValueProvider; @@ -38,18 +37,24 @@ import org.apache.wayang.core.plan.wayangplan.test.TestSource; import org.apache.wayang.core.test.MockFactory; import org.apache.wayang.core.util.WayangCollections; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test suite for {@link LoopSubplanCardinalityPusher}. */ -public class LoopSubplanCardinalityPusherTest { +class LoopSubplanCardinalityPusherTest { private Job job; private Configuration configuration; - @Before - public void setUp() { + @BeforeEach + void setUp() { this.configuration = new Configuration(); KeyValueProvider, CardinalityEstimator> estimatorProvider = new FunctionalKeyValueProvider<>( @@ -66,7 +71,7 @@ public void setUp() { } @Test - public void testWithSingleLoopAndSingleIteration() { + void testWithSingleLoopAndSingleIteration() { TestLoopHead loopHead = new TestLoopHead<>(Integer.class); loopHead.setNumExpectedIterations(1); @@ -78,7 +83,7 @@ public void testWithSingleLoopAndSingleIteration() { inLoopFilter.connectTo("out", loopHead, "loopInput"); final LoopSubplan loop = LoopIsolator.isolate(loopHead); - Assert.assertNotNull(loop); + assertNotNull(loop); OptimizationContext optimizationContext = new DefaultOptimizationContext(this.job, loop); final OptimizationContext.OperatorContext loopCtx = optimizationContext.getOperatorContext(loop); final CardinalityEstimate inputCardinality = new CardinalityEstimate(123, 321, 0.123d); @@ -93,12 +98,12 @@ public void testWithSingleLoopAndSingleIteration() { Math.round(inputCardinality.getUpperEstimate() * filterSelectivity), inputCardinality.getCorrectnessProbability() ); - Assert.assertEquals(expectedCardinality, loopCtx.getOutputCardinality(0)); + assertEquals(expectedCardinality, loopCtx.getOutputCardinality(0)); } @Test - public void testWithSingleLoopAndManyIteration() { + void testWithSingleLoopAndManyIteration() { TestLoopHead loopHead = new TestLoopHead<>(Integer.class); loopHead.setNumExpectedIterations(1000); @@ -110,7 +115,7 @@ public void testWithSingleLoopAndManyIteration() { inLoopFilter.connectTo("out", loopHead, "loopInput"); final LoopSubplan loop = LoopIsolator.isolate(loopHead); - Assert.assertNotNull(loop); + assertNotNull(loop); OptimizationContext optimizationContext = new DefaultOptimizationContext(this.job, loop); final OptimizationContext.OperatorContext loopCtx = optimizationContext.getOperatorContext(loop); final CardinalityEstimate inputCardinality = new CardinalityEstimate(123, 321, 0.123d); @@ -125,12 +130,12 @@ public void testWithSingleLoopAndManyIteration() { Math.round(inputCardinality.getUpperEstimate() * Math.pow(filterSelectivity, 1000)), inputCardinality.getCorrectnessProbability() ); - Assert.assertTrue(expectedCardinality.equalsWithinDelta(loopCtx.getOutputCardinality(0), 0.0001, 1, 1)); + assertTrue(expectedCardinality.equalsWithinDelta(loopCtx.getOutputCardinality(0), 0.0001, 1, 1)); } @Test - public void testWithSingleLoopWithConstantInput() { + void testWithSingleLoopWithConstantInput() { TestSource mainSource = new TestSource<>(Integer.class); TestSource sideSource = new TestSource<>(Integer.class); @@ -146,7 +151,7 @@ public void testWithSingleLoopWithConstantInput() { inLoopJoin.connectTo("out", loopHead, "loopInput"); final LoopSubplan loop = LoopIsolator.isolate(loopHead); - Assert.assertNotNull(loop); + assertNotNull(loop); OptimizationContext optimizationContext = new DefaultOptimizationContext(this.job, loop); final OptimizationContext.OperatorContext loopCtx = optimizationContext.getOperatorContext(loop); @@ -171,13 +176,13 @@ public void testWithSingleLoopWithConstantInput() { * Math.pow(TestJoin.ESTIMATION_CERTAINTY, numIterations) ); final CardinalityEstimate outputCardinality = loopCtx.getOutputCardinality(0); - Assert.assertTrue( - String.format("Expected %s, got %s.", expectedCardinality, outputCardinality), - expectedCardinality.equalsWithinDelta(outputCardinality, 0.0001, 0, 0)); + assertTrue( + expectedCardinality.equalsWithinDelta(outputCardinality, 0.0001, 0, 0), + String.format("Expected %s, got %s.", expectedCardinality, outputCardinality)); } @Test - public void testNestedLoops() { + void testNestedLoops() { TestLoopHead outerLoopHead = new TestLoopHead<>(Integer.class); outerLoopHead.setNumExpectedIterations(100); @@ -197,9 +202,9 @@ public void testNestedLoops() { inInnerLoopFilter.setSelectivity(0.1d); LoopSubplan innerLoop = LoopIsolator.isolate(innerLoopHead); - Assert.assertNotNull(innerLoop); + assertNotNull(innerLoop); LoopSubplan outerLoop = LoopIsolator.isolate(outerLoopHead); - Assert.assertNotNull(outerLoop); + assertNotNull(outerLoop); OptimizationContext optimizationContext = new DefaultOptimizationContext(this.job, outerLoop); final OptimizationContext.OperatorContext loopCtx = optimizationContext.getOperatorContext(outerLoop); @@ -220,7 +225,7 @@ public void testNestedLoops() { Math.round(inputCardinality.getUpperEstimate() * loopSelectivity), inputCardinality.getCorrectnessProbability() ); - Assert.assertTrue(expectedCardinality.equalsWithinDelta(loopCtx.getOutputCardinality(0), 0.0001, 1, 1)); + assertTrue(expectedCardinality.equalsWithinDelta(loopCtx.getOutputCardinality(0), 0.0001, 1, 1)); } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/SubplanCardinalityPusherTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/SubplanCardinalityPusherTest.java index 60b194a06..ebe2fa4fa 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/SubplanCardinalityPusherTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/cardinality/SubplanCardinalityPusherTest.java @@ -18,9 +18,6 @@ package org.apache.wayang.core.optimizer.cardinality; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.api.configuration.FunctionalKeyValueProvider; @@ -35,18 +32,22 @@ import org.apache.wayang.core.plan.wayangplan.test.TestSource; import org.apache.wayang.core.test.MockFactory; import org.apache.wayang.core.types.DataSetType; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test suite for {@link SubplanCardinalityPusher}. */ -public class SubplanCardinalityPusherTest { +class SubplanCardinalityPusherTest { private Job job; private Configuration configuration; - @Before - public void setUp() { + @BeforeEach + void setUp() { this.configuration = new Configuration(); KeyValueProvider, CardinalityEstimator> estimatorProvider = new FunctionalKeyValueProvider<>( @@ -64,7 +65,7 @@ public void setUp() { @Test - public void testSimpleSubplan() { + void testSimpleSubplan() { TestMapOperator op1 = new TestMapOperator<>( DataSetType.createDefault(String.class), DataSetType.createDefault(String.class) @@ -86,11 +87,11 @@ public void testSimpleSubplan() { final CardinalityPusher pusher = SubplanCardinalityPusher.createFor(subplan, this.configuration); pusher.push(subplanCtx, this.configuration); - Assert.assertEquals(inputCardinality, subplanCtx.getOutputCardinality(0)); + assertEquals(inputCardinality, subplanCtx.getOutputCardinality(0)); } @Test - public void testSourceSubplan() { + void testSourceSubplan() { TestSource source = new TestSource<>(DataSetType.createDefault(String.class)); final CardinalityEstimate sourceCardinality = new CardinalityEstimate(123, 321, 0.123d); source.setCardinalityEstimators((optimizationContext, inputEstimates) -> sourceCardinality); @@ -109,12 +110,12 @@ public void testSourceSubplan() { final CardinalityPusher pusher = SubplanCardinalityPusher.createFor(subplan, this.configuration); pusher.push(subplanCtx, this.configuration); - Assert.assertEquals(sourceCardinality, subplanCtx.getOutputCardinality(0)); + assertEquals(sourceCardinality, subplanCtx.getOutputCardinality(0)); } @Test - public void testDAGShapedSubplan() { + void testDAGShapedSubplan() { // _/-\_ // \ / final DataSetType stringDataSetType = DataSetType.createDefault(String.class); @@ -147,7 +148,7 @@ public void testDAGShapedSubplan() { final CardinalityEstimate outputCardinality = subplanCtx.getOutputCardinality(0); final CardinalityEstimate expectedCardinality = new CardinalityEstimate(10 * 10, 100 * 100, 0.9d * 0.7d); - Assert.assertEquals(expectedCardinality, outputCardinality); + assertEquals(expectedCardinality, outputCardinality); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/channels/ChannelConversionGraphTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/channels/ChannelConversionGraphTest.java index 7013c6c99..4866a3400 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/channels/ChannelConversionGraphTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/channels/ChannelConversionGraphTest.java @@ -18,9 +18,6 @@ package org.apache.wayang.core.optimizer.channels; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; @@ -38,14 +35,21 @@ import org.apache.wayang.core.test.DummyReusableChannel; import org.apache.wayang.core.test.MockFactory; import org.apache.wayang.core.util.WayangCollections; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.function.Supplier; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link ChannelConversionGraph}. */ -public class ChannelConversionGraphTest { +class ChannelConversionGraphTest { private static DefaultChannelConversion reusableToNonReusableChannelConversion; @@ -69,8 +73,8 @@ private static Supplier createDummyExecutionOperatorFactory(C }; } - @BeforeClass - public static void initializeChannelConversions() { + @BeforeAll + static void initializeChannelConversions() { reusableToNonReusableChannelConversion = new DefaultChannelConversion( DummyReusableChannel.DESCRIPTOR, DummyNonReusableChannel.DESCRIPTOR, @@ -102,7 +106,7 @@ public static void initializeChannelConversions() { } @Test - public void findDirectConversion() throws Exception { + void findDirectConversion() throws Exception { ChannelConversionGraph channelConversionGraph = new ChannelConversionGraph(configuration); ExecutionOperator sourceOperator = new DummyExecutionOperator(0, 1, false); @@ -128,7 +132,7 @@ public void findDirectConversion() throws Exception { } @Test - public void findIntricateConversion() throws Exception { + void findIntricateConversion() throws Exception { ChannelConversionGraph channelConversionGraph = new ChannelConversionGraph(new Configuration()); channelConversionGraph.add(reusableToNonReusableChannelConversion); channelConversionGraph.add(nonReusableToReusableChannelConversion); @@ -157,7 +161,7 @@ public void findIntricateConversion() throws Exception { } @Test - public void findIntricateConversion2() throws Exception { + void findIntricateConversion2() throws Exception { ChannelConversionGraph channelConversionGraph = new ChannelConversionGraph(new Configuration()); channelConversionGraph.add(reusableToNonReusableChannelConversion); channelConversionGraph.add(nonReusableToReusableChannelConversion); @@ -186,7 +190,7 @@ public void findIntricateConversion2() throws Exception { } @Test - public void updateExistingConversionWithOnlySourceChannel() throws Exception { + void updateExistingConversionWithOnlySourceChannel() throws Exception { ChannelConversionGraph channelConversionGraph = new ChannelConversionGraph(new Configuration()); channelConversionGraph.add(reusableToNonReusableChannelConversion); channelConversionGraph.add(nonReusableToReusableChannelConversion); @@ -215,19 +219,19 @@ public void updateExistingConversionWithOnlySourceChannel() throws Exception { optimizationContext ); - Assert.assertTrue(junction.getSourceChannel() == sourceChannel); + assertSame(junction.getSourceChannel(), sourceChannel); final Channel targetChannel0 = junction.getTargetChannel(0); - Assert.assertTrue(targetChannel0 instanceof DummyReusableChannel); - Assert.assertTrue(OptimizationUtils.getPredecessorChannel(targetChannel0).getOriginal() == sourceChannel); + assertInstanceOf(DummyReusableChannel.class, targetChannel0); + assertSame(OptimizationUtils.getPredecessorChannel(targetChannel0).getOriginal(), sourceChannel); final Channel targetChannel1 = junction.getTargetChannel(1); - Assert.assertTrue(targetChannel1 instanceof DummyExternalReusableChannel); - Assert.assertTrue(OptimizationUtils.getPredecessorChannel(targetChannel1) == targetChannel0); + assertInstanceOf(DummyExternalReusableChannel.class, targetChannel1); + assertSame(OptimizationUtils.getPredecessorChannel(targetChannel1), targetChannel0); } @Test - public void updateExistingConversionWithReachedDestination() throws Exception { + void updateExistingConversionWithReachedDestination() throws Exception { ChannelConversionGraph channelConversionGraph = new ChannelConversionGraph(new Configuration()); channelConversionGraph.add(reusableToNonReusableChannelConversion); channelConversionGraph.add(nonReusableToReusableChannelConversion); @@ -261,20 +265,20 @@ public void updateExistingConversionWithReachedDestination() throws Exception { optimizationContext ); - Assert.assertTrue(junction.getSourceChannel() == sourceChannel); + assertSame(junction.getSourceChannel(), sourceChannel); final Channel targetChannel0 = junction.getTargetChannel(0); - Assert.assertTrue(targetChannel0 == reusableChannel); - Assert.assertTrue(OptimizationUtils.getPredecessorChannel(targetChannel0) == sourceChannel); + assertSame(targetChannel0, reusableChannel); + assertSame(OptimizationUtils.getPredecessorChannel(targetChannel0), sourceChannel); final Channel targetChannel1 = junction.getTargetChannel(1); - Assert.assertTrue(targetChannel1 instanceof DummyExternalReusableChannel); - Assert.assertTrue(OptimizationUtils.getPredecessorChannel(targetChannel1).isCopy()); - Assert.assertTrue(OptimizationUtils.getPredecessorChannel(targetChannel1).getOriginal() == targetChannel0); + assertInstanceOf(DummyExternalReusableChannel.class, targetChannel1); + assertTrue(OptimizationUtils.getPredecessorChannel(targetChannel1).isCopy()); + assertSame(OptimizationUtils.getPredecessorChannel(targetChannel1).getOriginal(), targetChannel0); } @Test - public void updateExistingConversionWithTwoOpenChannels() throws Exception { + void updateExistingConversionWithTwoOpenChannels() throws Exception { ChannelConversionGraph channelConversionGraph = new ChannelConversionGraph(new Configuration()); channelConversionGraph.add(reusableToNonReusableChannelConversion); channelConversionGraph.add(nonReusableToReusableChannelConversion); @@ -305,18 +309,18 @@ public void updateExistingConversionWithTwoOpenChannels() throws Exception { optimizationContext ); - Assert.assertTrue(junction.getSourceChannel() == sourceChannel); + assertSame(junction.getSourceChannel(), sourceChannel); - Assert.assertTrue(sourceChannel.getConsumers().size() == 1); + assertEquals(1, sourceChannel.getConsumers().size()); ExecutionTask consumer = WayangCollections.getAny(sourceChannel.getConsumers()); Channel nextChannel = consumer.getOutputChannel(0); - Assert.assertTrue(nextChannel == reusableChannel); - Assert.assertTrue(junction.getTargetChannel(0).isCopy() && junction.getTargetChannel(0).getOriginal() == nextChannel); + assertSame(nextChannel, reusableChannel); + assertTrue(junction.getTargetChannel(0).isCopy() && junction.getTargetChannel(0).getOriginal() == nextChannel); consumer = WayangCollections.getSingle(nextChannel.getConsumers()); nextChannel = consumer.getOutputChannel(0); - Assert.assertTrue(nextChannel == externalChannel); - Assert.assertTrue(junction.getTargetChannel(1).isCopy() && junction.getTargetChannel(1).getOriginal() == nextChannel); + assertSame(nextChannel, externalChannel); + assertTrue(junction.getTargetChannel(1).isCopy() && junction.getTargetChannel(1).getOriginal() == nextChannel); } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/costs/NestableLoadProfileEstimatorTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/costs/NestableLoadProfileEstimatorTest.java index 62950211b..5fcf292b9 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/costs/NestableLoadProfileEstimatorTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/costs/NestableLoadProfileEstimatorTest.java @@ -18,9 +18,6 @@ package org.apache.wayang.core.optimizer.costs; -import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.optimizer.OptimizationUtils; import org.apache.wayang.core.optimizer.cardinality.CardinalityEstimate; import org.apache.wayang.core.plan.wayangplan.ExecutionOperator; @@ -28,16 +25,20 @@ import org.apache.wayang.core.platform.ChannelDescriptor; import org.apache.wayang.core.platform.Platform; import org.apache.wayang.core.types.DataSetType; +import org.junit.jupiter.api.Test; +import java.util.HashMap; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Tests for the {@link NestableLoadProfileEstimator}. */ -public class NestableLoadProfileEstimatorTest { +class NestableLoadProfileEstimatorTest { @Test - public void testFromJuelSpecification() { + void testFromJuelSpecification() { String specification = "{" + "\"type\":\"juel\"," + "\"in\":2," + @@ -59,18 +60,18 @@ public void testFromJuelSpecification() { 1 )); - Assert.assertEquals(3 * 10 + 2 * 100 + 7 * 200, estimate.getCpuUsage().getLowerEstimate(), 0.01); - Assert.assertEquals(3 * 10 + 2 * 100 + 7 * 300, estimate.getCpuUsage().getUpperEstimate(), 0.01); - Assert.assertEquals( + assertEquals(3 * 10 + 2 * 100 + 7 * 200, estimate.getCpuUsage().getLowerEstimate(), 0.01); + assertEquals(3 * 10 + 2 * 100 + 7 * 300, estimate.getCpuUsage().getUpperEstimate(), 0.01); + assertEquals( OptimizationUtils.logisticGrowth(0.1, 0.1, 10000, 100 + 10), estimate.getResourceUtilization(), 0.000000001 ); - Assert.assertEquals(143, estimate.getOverheadMillis()); + assertEquals(143, estimate.getOverheadMillis()); } @Test - public void testFromMathExSpecification() { + void testFromMathExSpecification() { String specification = "{" + "\"type\":\"mathex\"," + "\"in\":2," + @@ -92,18 +93,18 @@ public void testFromMathExSpecification() { 1 )); - Assert.assertEquals(3 * 10 + 2 * 100 + 7 * 200, estimate.getCpuUsage().getLowerEstimate(), 0.01); - Assert.assertEquals(3 * 10 + 2 * 100 + 7 * 300, estimate.getCpuUsage().getUpperEstimate(), 0.01); - Assert.assertEquals( + assertEquals(3 * 10 + 2 * 100 + 7 * 200, estimate.getCpuUsage().getLowerEstimate(), 0.01); + assertEquals(3 * 10 + 2 * 100 + 7 * 300, estimate.getCpuUsage().getUpperEstimate(), 0.01); + assertEquals( OptimizationUtils.logisticGrowth(0.1, 0.1, 10000, 100 + 10), estimate.getResourceUtilization(), 0.000000001 ); - Assert.assertEquals(143, estimate.getOverheadMillis()); + assertEquals(143, estimate.getOverheadMillis()); } @Test - public void testFromJuelSpecificationWithImport() { + void testFromJuelSpecificationWithImport() { String specification = "{" + "\"in\":2," + "\"out\":1," + @@ -128,18 +129,18 @@ public void testFromJuelSpecificationWithImport() { 1 )); - Assert.assertEquals((3 * 10 + 2 * 100 + 7 * 200) * execOp.getNumIterations(), estimate.getCpuUsage().getLowerEstimate(), 0.01); - Assert.assertEquals((3 * 10 + 2 * 100 + 7 * 300) * execOp.getNumIterations(), estimate.getCpuUsage().getUpperEstimate(), 0.01); - Assert.assertEquals( + assertEquals((3 * 10 + 2 * 100 + 7 * 200) * execOp.getNumIterations(), estimate.getCpuUsage().getLowerEstimate(), 0.01); + assertEquals((3 * 10 + 2 * 100 + 7 * 300) * execOp.getNumIterations(), estimate.getCpuUsage().getUpperEstimate(), 0.01); + assertEquals( OptimizationUtils.logisticGrowth(0.1, 0.1, 10000, 100 + 10), estimate.getResourceUtilization(), 0.000000001 ); - Assert.assertEquals(143, estimate.getOverheadMillis()); + assertEquals(143, estimate.getOverheadMillis()); } @Test - public void testMathExFromSpecificationWithImport() { + void testMathExFromSpecificationWithImport() { String specification = "{" + "\"type\":\"mathex\"," + "\"in\":2," + @@ -165,14 +166,14 @@ public void testMathExFromSpecificationWithImport() { 1 )); - Assert.assertEquals((3 * 10 + 2 * 100 + 7 * 200) * execOp.getNumIterations(), estimate.getCpuUsage().getLowerEstimate(), 0.01); - Assert.assertEquals((3 * 10 + 2 * 100 + 7 * 300) * execOp.getNumIterations(), estimate.getCpuUsage().getUpperEstimate(), 0.01); - Assert.assertEquals( + assertEquals((3 * 10 + 2 * 100 + 7 * 200) * execOp.getNumIterations(), estimate.getCpuUsage().getLowerEstimate(), 0.01); + assertEquals((3 * 10 + 2 * 100 + 7 * 300) * execOp.getNumIterations(), estimate.getCpuUsage().getUpperEstimate(), 0.01); + assertEquals( OptimizationUtils.logisticGrowth(0.1, 0.1, 10000, 100 + 10), estimate.getResourceUtilization(), 0.000000001 ); - Assert.assertEquals(143, estimate.getOverheadMillis()); + assertEquals(143, estimate.getOverheadMillis()); } public static class SomeOperator extends UnaryToUnaryOperator { diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/enumeration/StageAssignmentTraversalTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/enumeration/StageAssignmentTraversalTest.java index 9d3d2ebba..14a6f6759 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/enumeration/StageAssignmentTraversalTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/optimizer/enumeration/StageAssignmentTraversalTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.core.optimizer.enumeration; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.plan.executionplan.Channel; import org.apache.wayang.core.plan.executionplan.ExecutionPlan; import org.apache.wayang.core.plan.executionplan.ExecutionStage; @@ -28,16 +26,19 @@ import org.apache.wayang.core.plan.wayangplan.ExecutionOperator; import org.apache.wayang.core.platform.Platform; import org.apache.wayang.core.test.MockFactory; +import org.junit.jupiter.api.Test; import java.util.Collections; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link StageAssignmentTraversal}. */ -public class StageAssignmentTraversalTest { +class StageAssignmentTraversalTest { @Test - public void testCircularPlatformAssignment() { + void testCircularPlatformAssignment() { final Platform mockedPlatformA = MockFactory.createPlatform("A"); final Platform mockedPlatformB = MockFactory.createPlatform("B"); final Platform mockedPlatformC = MockFactory.createPlatform("C"); @@ -90,19 +91,19 @@ public void testCircularPlatformAssignment() { // Assign platforms. ExecutionTaskFlow executionTaskFlow = new ExecutionTaskFlow(Collections.singleton(sinkTaskA)); final ExecutionPlan executionPlan = StageAssignmentTraversal.assignStages(executionTaskFlow); - Assert.assertEquals(1, executionPlan.getStartingStages().size()); + assertEquals(1, executionPlan.getStartingStages().size()); ExecutionStage stage1 = executionPlan.getStartingStages().stream().findAny().get(); - Assert.assertEquals(1, stage1.getStartTasks().size()); + assertEquals(1, stage1.getStartTasks().size()); ExecutionTask stage1Task1 = stage1.getStartTasks().stream().findAny().get(); - Assert.assertEquals(sourceTaskA, stage1Task1); + assertEquals(sourceTaskA, stage1Task1); - Assert.assertEquals(2, stage1.getSuccessors().size()); + assertEquals(2, stage1.getSuccessors().size()); } @Test - public void testZigZag() { + void testZigZag() { final Platform mockedPlatformA = MockFactory.createPlatform("A"); final Platform mockedPlatformB = MockFactory.createPlatform("B"); @@ -152,15 +153,15 @@ public void testZigZag() { ExecutionTaskFlow executionTaskFlow = new ExecutionTaskFlow(Collections.singleton(sinkTaskA)); final ExecutionPlan executionPlan = StageAssignmentTraversal.assignStages(executionTaskFlow); - Assert.assertEquals(1, executionPlan.getStartingStages().size()); + assertEquals(1, executionPlan.getStartingStages().size()); ExecutionStage stage1 = executionPlan.getStartingStages().stream().findAny().get(); - Assert.assertEquals(1, stage1.getStartTasks().size()); + assertEquals(1, stage1.getStartTasks().size()); ExecutionTask stage1Task1 = stage1.getStartTasks().stream().findAny().get(); - Assert.assertEquals(sourceTaskA, stage1Task1); + assertEquals(sourceTaskA, stage1Task1); - Assert.assertEquals(2, stage1.getSuccessors().size()); + assertEquals(2, stage1.getSuccessors().size()); } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/LoopIsolatorTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/LoopIsolatorTest.java index 6eae42836..d00503eda 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/LoopIsolatorTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/LoopIsolatorTest.java @@ -18,23 +18,25 @@ package org.apache.wayang.core.plan.wayangplan; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.plan.wayangplan.test.TestLoopHead; import org.apache.wayang.core.plan.wayangplan.test.TestMapOperator; import org.apache.wayang.core.plan.wayangplan.test.TestSink; import org.apache.wayang.core.plan.wayangplan.test.TestSource; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + /** * Test suite for the {@link LoopIsolator}. */ -public class LoopIsolatorTest { +class LoopIsolatorTest { @Test - public void testWithSingleLoop() { + void testWithSingleLoop() { TestSource source = new TestSource<>(Integer.class); TestLoopHead loopHead = new TestLoopHead<>(Integer.class); @@ -53,23 +55,23 @@ public void testWithSingleLoop() { // Check the top-level plan. final Operator allegedLoopSubplan = sink.getEffectiveOccupant(0).getOwner(); - Assert.assertSame(LoopSubplan.class, allegedLoopSubplan.getClass()); - Assert.assertSame(source, allegedLoopSubplan.getEffectiveOccupant(0).getOwner()); + assertSame(LoopSubplan.class, allegedLoopSubplan.getClass()); + assertSame(source, allegedLoopSubplan.getEffectiveOccupant(0).getOwner()); // Check the Subplan. LoopSubplan loopSubplan = (LoopSubplan) allegedLoopSubplan; - Assert.assertEquals(1, loopSubplan.getNumOutputs()); - Assert.assertEquals(1, loopSubplan.getNumInputs()); - Assert.assertSame(loopHead.getOutput("finalOutput"), loopSubplan.traceOutput(loopSubplan.getOutput(0))); + assertEquals(1, loopSubplan.getNumOutputs()); + assertEquals(1, loopSubplan.getNumInputs()); + assertSame(loopHead.getOutput("finalOutput"), loopSubplan.traceOutput(loopSubplan.getOutput(0))); List> innerInputs = new ArrayList<>(loopSubplan.followInput(loopSubplan.getInput(0))); - Assert.assertEquals(1, innerInputs.size()); - Assert.assertSame(loopHead.getInput("initialInput"), innerInputs.get(0)); - Assert.assertSame(loopSubplan, loopHead.getParent()); - Assert.assertSame(loopSubplan, inLoopMap.getParent()); + assertEquals(1, innerInputs.size()); + assertSame(loopHead.getInput("initialInput"), innerInputs.get(0)); + assertSame(loopSubplan, loopHead.getParent()); + assertSame(loopSubplan, inLoopMap.getParent()); } @Test - public void testWithSingleLoopWithConstantInput() { + void testWithSingleLoopWithConstantInput() { TestSource mainSource = new TestSource<>(Integer.class); TestSource additionalSource = new TestSource<>(Integer.class); @@ -90,23 +92,23 @@ public void testWithSingleLoopWithConstantInput() { // Check the top-level plan. final Operator allegedLoopSubplan = sink.getEffectiveOccupant(0).getOwner(); - Assert.assertSame(LoopSubplan.class, allegedLoopSubplan.getClass()); - Assert.assertSame(mainSource, allegedLoopSubplan.getEffectiveOccupant(0).getOwner()); + assertSame(LoopSubplan.class, allegedLoopSubplan.getClass()); + assertSame(mainSource, allegedLoopSubplan.getEffectiveOccupant(0).getOwner()); // Check the Subplan. LoopSubplan loopSubplan = (LoopSubplan) allegedLoopSubplan; - Assert.assertEquals(1, loopSubplan.getNumOutputs()); - Assert.assertEquals(2, loopSubplan.getNumInputs()); - Assert.assertSame(loopHead.getOutput("finalOutput"), loopSubplan.traceOutput(loopSubplan.getOutput(0))); + assertEquals(1, loopSubplan.getNumOutputs()); + assertEquals(2, loopSubplan.getNumInputs()); + assertSame(loopHead.getOutput("finalOutput"), loopSubplan.traceOutput(loopSubplan.getOutput(0))); List> innerInputs = new ArrayList<>(loopSubplan.followInput(loopSubplan.getInput(0))); - Assert.assertEquals(1, innerInputs.size()); - Assert.assertSame(loopHead.getInput("initialInput"), innerInputs.get(0)); - Assert.assertSame(loopSubplan, loopHead.getParent()); - Assert.assertSame(loopSubplan, inLoopMap.getParent()); + assertEquals(1, innerInputs.size()); + assertSame(loopHead.getInput("initialInput"), innerInputs.get(0)); + assertSame(loopSubplan, loopHead.getParent()); + assertSame(loopSubplan, inLoopMap.getParent()); } @Test - public void testNestedLoops() { + void testNestedLoops() { TestSource mainSource = new TestSource<>(Integer.class); mainSource.setName("mainSource"); @@ -139,32 +141,32 @@ public void testNestedLoops() { // Check the top-level plan. final Operator allegedOuterLoopSubplan = sink.getEffectiveOccupant(0).getOwner(); - Assert.assertSame(LoopSubplan.class, allegedOuterLoopSubplan.getClass()); - Assert.assertSame(mainSource, allegedOuterLoopSubplan.getEffectiveOccupant(0).getOwner()); + assertSame(LoopSubplan.class, allegedOuterLoopSubplan.getClass()); + assertSame(mainSource, allegedOuterLoopSubplan.getEffectiveOccupant(0).getOwner()); // Check the outer Subplan. LoopSubplan outerSubplan = (LoopSubplan) allegedOuterLoopSubplan; - Assert.assertEquals(1, outerSubplan.getNumOutputs()); - Assert.assertEquals(1, outerSubplan.getNumInputs()); - Assert.assertSame(outerLoopHead.getOutput("finalOutput"), outerSubplan.traceOutput(outerSubplan.getOutput(0))); + assertEquals(1, outerSubplan.getNumOutputs()); + assertEquals(1, outerSubplan.getNumInputs()); + assertSame(outerLoopHead.getOutput("finalOutput"), outerSubplan.traceOutput(outerSubplan.getOutput(0))); List> innerInputs = new ArrayList<>(outerSubplan.followInput(outerSubplan.getInput(0))); - Assert.assertEquals(1, innerInputs.size()); - Assert.assertSame(outerLoopHead.getInput("initialInput"), innerInputs.get(0)); - Assert.assertSame(outerSubplan, outerLoopHead.getParent()); - Assert.assertSame(outerSubplan, inOuterLoopMap.getParent()); + assertEquals(1, innerInputs.size()); + assertSame(outerLoopHead.getInput("initialInput"), innerInputs.get(0)); + assertSame(outerSubplan, outerLoopHead.getParent()); + assertSame(outerSubplan, inOuterLoopMap.getParent()); final Operator allegedInnerLoopSubplan = outerLoopHead.getEffectiveOccupant(outerLoopHead.getInput("loopInput")).getOwner(); - Assert.assertSame(LoopSubplan.class, allegedInnerLoopSubplan.getClass()); + assertSame(LoopSubplan.class, allegedInnerLoopSubplan.getClass()); // Check the inner Subplan. LoopSubplan innerSubplan = (LoopSubplan) allegedInnerLoopSubplan; - Assert.assertEquals(1, innerSubplan.getNumOutputs()); - Assert.assertEquals(1, innerSubplan.getNumInputs()); - Assert.assertSame(innerLoopHead.getOutput("finalOutput"), innerSubplan.traceOutput(innerSubplan.getOutput(0))); + assertEquals(1, innerSubplan.getNumOutputs()); + assertEquals(1, innerSubplan.getNumInputs()); + assertSame(innerLoopHead.getOutput("finalOutput"), innerSubplan.traceOutput(innerSubplan.getOutput(0))); innerInputs = new ArrayList<>(innerSubplan.followInput(innerSubplan.getInput(0))); - Assert.assertEquals(1, innerInputs.size()); - Assert.assertSame(innerLoopHead.getInput("initialInput"), innerInputs.get(0)); - Assert.assertSame(innerSubplan, innerLoopHead.getParent()); - Assert.assertSame(innerSubplan, inInnerLoopMap.getParent()); + assertEquals(1, innerInputs.size()); + assertSame(innerLoopHead.getInput("initialInput"), innerInputs.get(0)); + assertSame(innerSubplan, innerLoopHead.getParent()); + assertSame(innerSubplan, inInnerLoopMap.getParent()); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/OperatorTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/OperatorTest.java index 4018ee10b..70ad20cc9 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/OperatorTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/OperatorTest.java @@ -18,17 +18,18 @@ package org.apache.wayang.core.plan.wayangplan; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.util.ReflectionUtils; import org.apache.wayang.core.util.WayangCollections; +import org.junit.jupiter.api.Test; import java.util.Collection; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for the {@link Operator} class. */ -public class OperatorTest { +class OperatorTest { public class Operator1 extends OperatorBase { @@ -64,23 +65,23 @@ public double getOp2Property() { } @Test - public void testPropertyDetection() { + void testPropertyDetection() { Operator op = new Operator2(0, 1); final Collection estimationContextProperties = op.getEstimationContextProperties(); - Assert.assertEquals( + assertEquals( WayangCollections.asSet("op1Property", "op2Property"), WayangCollections.asSet(estimationContextProperties) ); } @Test - public void testPropertyCollection() { + void testPropertyCollection() { Operator op = new Operator2(0, 1); - Assert.assertEquals( + assertEquals( Double.valueOf(0d), ReflectionUtils.getProperty(op, "op1Property") ); - Assert.assertEquals( + assertEquals( Double.valueOf(1d), ReflectionUtils.getProperty(op, "op2Property") ); diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/SlotMappingTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/SlotMappingTest.java index 6659beba4..345a9b325 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/SlotMappingTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plan/wayangplan/SlotMappingTest.java @@ -18,25 +18,27 @@ package org.apache.wayang.core.plan.wayangplan; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.plan.wayangplan.test.TestSink; import org.apache.wayang.core.plan.wayangplan.test.TestSource; import org.apache.wayang.core.types.DataSetType; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link SlotMapping}. */ -public class SlotMappingTest { +class SlotMappingTest { final DataSetType STRING_TYPE = DataSetType.createDefault(String.class); @Test - public void testSimpleSlotMapping() { + void testSimpleSlotMapping() { SlotMapping slotMapping = new SlotMapping(); OutputSlot innerOutputSlot1 = new OutputSlot<>("innerOutputSlot1", new TestSink<>(this.STRING_TYPE), this.STRING_TYPE); @@ -47,12 +49,12 @@ public void testSimpleSlotMapping() { InputSlot innerInputSlot1 = new InputSlot<>("innerInputSlot1", new TestSource<>(this.STRING_TYPE), this.STRING_TYPE); slotMapping.mapUpstream(innerInputSlot1, outerInputSlot1); - Assert.assertEquals(innerOutputSlot1, slotMapping.resolveUpstream(outerOutputSlot1)); - Assert.assertEquals(outerInputSlot1, slotMapping.resolveUpstream(innerInputSlot1)); + assertEquals(innerOutputSlot1, slotMapping.resolveUpstream(outerOutputSlot1)); + assertEquals(outerInputSlot1, slotMapping.resolveUpstream(innerInputSlot1)); } @Test - public void testOverridingSlotMapping() { + void testOverridingSlotMapping() { SlotMapping slotMapping = new SlotMapping(); OutputSlot innerOutputSlot1 = new OutputSlot<>("innerOutputSlot1", new TestSink<>(this.STRING_TYPE), this.STRING_TYPE); @@ -67,12 +69,12 @@ public void testOverridingSlotMapping() { slotMapping.mapUpstream(innerInputSlot1, outerInputSlot1); slotMapping.mapUpstream(innerInputSlot1, outerInputSlot2); - Assert.assertEquals(innerOutputSlot2, slotMapping.resolveUpstream(outerOutputSlot1)); - Assert.assertEquals(outerInputSlot2, slotMapping.resolveUpstream(innerInputSlot1)); + assertEquals(innerOutputSlot2, slotMapping.resolveUpstream(outerOutputSlot1)); + assertEquals(outerInputSlot2, slotMapping.resolveUpstream(innerInputSlot1)); } @Test - public void testMultiMappings() { + void testMultiMappings() { SlotMapping slotMapping = new SlotMapping(); OutputSlot innerOutputSlot1 = new OutputSlot<>("innerOutputSlot1", new TestSink<>(this.STRING_TYPE), this.STRING_TYPE); @@ -87,19 +89,19 @@ public void testMultiMappings() { slotMapping.mapUpstream(innerInputSlot1, outerInputSlot1); slotMapping.mapUpstream(innerInputSlot2, outerInputSlot1); - Assert.assertEquals(innerOutputSlot1, slotMapping.resolveUpstream(outerOutputSlot1)); - Assert.assertEquals(innerOutputSlot1, slotMapping.resolveUpstream(outerOutputSlot2)); + assertEquals(innerOutputSlot1, slotMapping.resolveUpstream(outerOutputSlot1)); + assertEquals(innerOutputSlot1, slotMapping.resolveUpstream(outerOutputSlot2)); final Collection> outerOutputSlots = slotMapping.resolveDownstream(innerOutputSlot1); final List> expectedOuterOutputSlots = Arrays.asList(outerOutputSlot1, outerOutputSlot2); - Assert.assertEquals(expectedOuterOutputSlots.size(), outerOutputSlots.size()); - Assert.assertTrue(expectedOuterOutputSlots.containsAll(outerOutputSlots)); + assertEquals(expectedOuterOutputSlots.size(), outerOutputSlots.size()); + assertTrue(expectedOuterOutputSlots.containsAll(outerOutputSlots)); - Assert.assertEquals(outerInputSlot1, slotMapping.resolveUpstream(innerInputSlot1)); - Assert.assertEquals(outerInputSlot1, slotMapping.resolveUpstream(innerInputSlot2)); + assertEquals(outerInputSlot1, slotMapping.resolveUpstream(innerInputSlot1)); + assertEquals(outerInputSlot1, slotMapping.resolveUpstream(innerInputSlot2)); final Collection> innerInputSlots = slotMapping.resolveDownstream(outerInputSlot1); final List> expectedInnerInputSlots = Arrays.asList(innerInputSlot1, innerInputSlot2); - Assert.assertEquals(expectedInnerInputSlots.size(), innerInputSlots.size()); - Assert.assertTrue(expectedInnerInputSlots.containsAll(innerInputSlots)); + assertEquals(expectedInnerInputSlots.size(), innerInputSlots.size()); + assertTrue(expectedInnerInputSlots.containsAll(innerInputSlots)); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/platform/PartialExecutionTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/platform/PartialExecutionTest.java index bf28c9469..b3ff7d33b 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/platform/PartialExecutionTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/platform/PartialExecutionTest.java @@ -19,8 +19,7 @@ package org.apache.wayang.core.platform; import org.apache.wayang.core.util.json.WayangJsonObj; -import org.junit.Assert; -import org.junit.Test; + import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.configuration.KeyValueProvider; import org.apache.wayang.core.optimizer.OptimizationContext; @@ -33,19 +32,22 @@ import org.apache.wayang.core.test.SerializableDummyExecutionOperator; import org.apache.wayang.core.util.JsonSerializables; import org.apache.wayang.core.util.WayangCollections; +import org.junit.jupiter.api.Test; import java.util.Arrays; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * Test suites for {@link PartialExecution}s. */ -public class PartialExecutionTest { +class PartialExecutionTest { @Test - public void testJsonSerialization() { + void testJsonSerialization() { // Create first OperatorContext with non-serializable ExecutionOperator. final OptimizationContext.OperatorContext operatorContext1 = mock(OptimizationContext.OperatorContext.class); when(operatorContext1.getOperator()).thenReturn(new DummyExecutionOperator(1, 1, false)); @@ -76,10 +78,10 @@ public void testJsonSerialization() { final WayangJsonObj wayangJsonObj = JsonSerializables.serialize(original, false, serializer); final PartialExecution loaded = JsonSerializables.deserialize(wayangJsonObj, serializer, PartialExecution.class); - Assert.assertEquals(original.getMeasuredExecutionTime(), loaded.getMeasuredExecutionTime()); - Assert.assertEquals(2, loaded.getAtomicExecutionGroups().size()); - Assert.assertEquals(1, loaded.getInitializedPlatforms().size()); - Assert.assertSame(DummyPlatform.getInstance(), WayangCollections.getAny(loaded.getInitializedPlatforms())); + assertEquals(original.getMeasuredExecutionTime(), loaded.getMeasuredExecutionTime()); + assertEquals(2, loaded.getAtomicExecutionGroups().size()); + assertEquals(1, loaded.getInitializedPlatforms().size()); + assertSame(DummyPlatform.getInstance(), WayangCollections.getAny(loaded.getInitializedPlatforms())); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plugin/DynamicPluginTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plugin/DynamicPluginTest.java index 6fd6b390a..ab580b553 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plugin/DynamicPluginTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/plugin/DynamicPluginTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.core.plugin; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.mapping.Mapping; import org.apache.wayang.core.mapping.test.TestSinkMapping; @@ -30,11 +28,13 @@ import org.apache.wayang.core.test.DummyPlatform; import org.apache.wayang.core.util.ReflectionUtils; import org.apache.wayang.core.util.WayangCollections; +import org.junit.jupiter.api.Test; import java.util.Collection; import java.util.Collections; import java.util.Set; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; /** @@ -49,83 +49,83 @@ public class DynamicPluginTest { ); @Test - public void testLoadYaml() { + void testLoadYaml() { final DynamicPlugin plugin = DynamicPlugin.loadYaml(ReflectionUtils.getResourceURL("test-plugin.yaml").toString()); Set expectedPlatforms = WayangCollections.asSet(DummyPlatform.getInstance()); - Assert.assertEquals(expectedPlatforms, WayangCollections.asSet(plugin.getRequiredPlatforms())); + assertEquals(expectedPlatforms, WayangCollections.asSet(plugin.getRequiredPlatforms())); Set expectedExcludedPlatforms = Collections.emptySet(); - Assert.assertEquals(expectedExcludedPlatforms, WayangCollections.asSet(plugin.getExcludedRequiredPlatforms())); + assertEquals(expectedExcludedPlatforms, WayangCollections.asSet(plugin.getExcludedRequiredPlatforms())); Set expectedMappings = WayangCollections.asSet(new TestSinkMapping()); - Assert.assertEquals(expectedMappings, WayangCollections.asSet(plugin.getMappings())); + assertEquals(expectedMappings, WayangCollections.asSet(plugin.getMappings())); Set expectedExcludedMappings = WayangCollections.asSet(); - Assert.assertEquals(expectedExcludedMappings, WayangCollections.asSet(plugin.getExcludedMappings())); + assertEquals(expectedExcludedMappings, WayangCollections.asSet(plugin.getExcludedMappings())); Set expectedConversions = WayangCollections.asSet(); - Assert.assertEquals(expectedConversions, WayangCollections.asSet(plugin.getChannelConversions())); + assertEquals(expectedConversions, WayangCollections.asSet(plugin.getChannelConversions())); Set expectedExcludedConversions = WayangCollections.asSet(CHANNEL_CONVERSIONS); - Assert.assertEquals(expectedExcludedConversions, WayangCollections.asSet(plugin.getExcludedChannelConversions())); + assertEquals(expectedExcludedConversions, WayangCollections.asSet(plugin.getExcludedChannelConversions())); Configuration configuration = new Configuration(); plugin.setProperties(configuration); - Assert.assertEquals(51.3d, configuration.getDoubleProperty("org.apache.wayang.test.float"), 0.000001); - Assert.assertEquals("abcdef", configuration.getStringProperty("org.apache.wayang.test.string")); - Assert.assertEquals(1234567890123456789L, configuration.getLongProperty("org.apache.wayang.test.long")); + assertEquals(51.3d, configuration.getDoubleProperty("org.apache.wayang.test.float"), 0.000001); + assertEquals("abcdef", configuration.getStringProperty("org.apache.wayang.test.string")); + assertEquals(1234567890123456789L, configuration.getLongProperty("org.apache.wayang.test.long")); } @Test - public void testPartialYaml() { + void testPartialYaml() { final DynamicPlugin plugin = DynamicPlugin.loadYaml(ReflectionUtils.getResourceURL("partial-plugin.yaml").toString()); Set expectedPlatforms = WayangCollections.asSet(DummyPlatform.getInstance()); - Assert.assertEquals(expectedPlatforms, WayangCollections.asSet(plugin.getRequiredPlatforms())); + assertEquals(expectedPlatforms, WayangCollections.asSet(plugin.getRequiredPlatforms())); Set expectedExcludedPlatforms = Collections.emptySet(); - Assert.assertEquals(expectedExcludedPlatforms, WayangCollections.asSet(plugin.getExcludedRequiredPlatforms())); + assertEquals(expectedExcludedPlatforms, WayangCollections.asSet(plugin.getExcludedRequiredPlatforms())); Set expectedMappings = WayangCollections.asSet(); - Assert.assertEquals(expectedMappings, WayangCollections.asSet(plugin.getMappings())); + assertEquals(expectedMappings, WayangCollections.asSet(plugin.getMappings())); Set expectedExcludedMappings = WayangCollections.asSet(new TestSinkMapping()); - Assert.assertEquals(expectedExcludedMappings, WayangCollections.asSet(plugin.getExcludedMappings())); + assertEquals(expectedExcludedMappings, WayangCollections.asSet(plugin.getExcludedMappings())); Set expectedConversions = WayangCollections.asSet(); - Assert.assertEquals(expectedConversions, WayangCollections.asSet(plugin.getChannelConversions())); + assertEquals(expectedConversions, WayangCollections.asSet(plugin.getChannelConversions())); Set expectedExcludedConversions = WayangCollections.asSet(); - Assert.assertEquals(expectedExcludedConversions, WayangCollections.asSet(plugin.getExcludedChannelConversions())); + assertEquals(expectedExcludedConversions, WayangCollections.asSet(plugin.getExcludedChannelConversions())); } @Test - public void testEmptyYaml() { + void testEmptyYaml() { final DynamicPlugin plugin = DynamicPlugin.loadYaml(ReflectionUtils.getResourceURL("empty-plugin.yaml").toString()); Set expectedPlatforms = Collections.emptySet(); - Assert.assertEquals(expectedPlatforms, WayangCollections.asSet(plugin.getRequiredPlatforms())); + assertEquals(expectedPlatforms, WayangCollections.asSet(plugin.getRequiredPlatforms())); Set expectedMappings = Collections.emptySet(); - Assert.assertEquals(expectedMappings, WayangCollections.asSet(plugin.getMappings())); + assertEquals(expectedMappings, WayangCollections.asSet(plugin.getMappings())); Set expectedConversions = Collections.emptySet(); - Assert.assertEquals(expectedConversions, WayangCollections.asSet(plugin.getChannelConversions())); + assertEquals(expectedConversions, WayangCollections.asSet(plugin.getChannelConversions())); } @Test - public void testExclusion() { + void testExclusion() { final TestSinkMapping mapping = new TestSinkMapping(); Configuration configuration = new Configuration(); final DynamicPlugin plugin1 = new DynamicPlugin(); plugin1.addMapping(mapping); plugin1.configure(configuration); - Assert.assertEquals( + assertEquals( WayangCollections.asSet(mapping), WayangCollections.asSet(configuration.getMappingProvider().provideAll()) ); @@ -133,7 +133,7 @@ public void testExclusion() { final DynamicPlugin plugin2 = new DynamicPlugin(); plugin2.excludeMapping(mapping); plugin2.configure(configuration); - Assert.assertEquals( + assertEquals( WayangCollections.asSet(), WayangCollections.asSet(configuration.getMappingProvider().provideAll()) ); diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/BitmaskTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/BitmaskTest.java index 7fcbf48ac..5396ce693 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/BitmaskTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/BitmaskTest.java @@ -18,13 +18,17 @@ package org.apache.wayang.core.util; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test suite for {@link Bitmask}s. */ -public class BitmaskTest { +class BitmaskTest { private static Bitmask createBitmask(int capacity, int... bitIndices) { Bitmask bitmask = new Bitmask(capacity); @@ -35,21 +39,21 @@ private static Bitmask createBitmask(int capacity, int... bitIndices) { } @Test - public void testEquals() { + void testEquals() { Bitmask bitmask1 = createBitmask(64, 0, 3); Bitmask bitmask2 = createBitmask(256, 0, 3); Bitmask bitmask3 = createBitmask(256, 0, 3, 68); - Assert.assertEquals(bitmask1, bitmask2); - Assert.assertEquals(bitmask2, bitmask1); - Assert.assertNotEquals(bitmask1, bitmask3); - Assert.assertNotEquals(bitmask3, bitmask1); - Assert.assertNotEquals(bitmask2, bitmask3); - Assert.assertNotEquals(bitmask3, bitmask2); + assertEquals(bitmask1, bitmask2); + assertEquals(bitmask2, bitmask1); + assertNotEquals(bitmask1, bitmask3); + assertNotEquals(bitmask3, bitmask1); + assertNotEquals(bitmask2, bitmask3); + assertNotEquals(bitmask3, bitmask2); } @Test - public void testFlip() { + void testFlip() { testFlip(0, 256); testFlip(32, 256); testFlip(32, 224); @@ -67,51 +71,48 @@ private void testFlip(int from, int to) { boolean isInFlipRanks = from <= i && i < to; boolean isExpectSetBit = isEven ^ isInFlipRanks; boolean isSetBit = bitmask.get(i); - Assert.assertTrue( - String.format("Incorrect bit at %d in %s", i, bitmask), - isSetBit == isExpectSetBit - ); + assertEquals(isSetBit, isExpectSetBit, String.format("Incorrect bit at %d in %s", i, bitmask)); } } @Test - public void testIsSubmaskOf() { - Assert.assertTrue(createBitmask(0).isSubmaskOf(createBitmask(1, 0))); - Assert.assertTrue(createBitmask(1).isSubmaskOf(createBitmask(1, 0))); - Assert.assertFalse(createBitmask(1, 0).isSubmaskOf(createBitmask(0))); - Assert.assertTrue(createBitmask(0, 1, 65).isSubmaskOf(createBitmask(0, 1, 65, 129))); - Assert.assertTrue(createBitmask(0, 1, 129).isSubmaskOf(createBitmask(0, 1, 65, 129))); - Assert.assertTrue(createBitmask(0, 1, 129).isSubmaskOf(createBitmask(0, 1, 65, 66, 129))); - Assert.assertFalse(createBitmask(0, 1, 65, 66, 129).isSubmaskOf(createBitmask(0, 1, 65, 129))); - Assert.assertTrue(createBitmask(0, 1, 129).isSubmaskOf(createBitmask(0, 1, 129))); + void testIsSubmaskOf() { + assertTrue(createBitmask(0).isSubmaskOf(createBitmask(1, 0))); + assertTrue(createBitmask(1).isSubmaskOf(createBitmask(1, 0))); + assertFalse(createBitmask(1, 0).isSubmaskOf(createBitmask(0))); + assertTrue(createBitmask(0, 1, 65).isSubmaskOf(createBitmask(0, 1, 65, 129))); + assertTrue(createBitmask(0, 1, 129).isSubmaskOf(createBitmask(0, 1, 65, 129))); + assertTrue(createBitmask(0, 1, 129).isSubmaskOf(createBitmask(0, 1, 65, 66, 129))); + assertFalse(createBitmask(0, 1, 65, 66, 129).isSubmaskOf(createBitmask(0, 1, 65, 129))); + assertTrue(createBitmask(0, 1, 129).isSubmaskOf(createBitmask(0, 1, 129))); } @Test - public void testCardinality() { - Assert.assertEquals(0, createBitmask(0).orInPlace(createBitmask(0)).cardinality()); - Assert.assertEquals(1, createBitmask(0, 65).orInPlace(createBitmask(0)).cardinality()); - Assert.assertEquals(2, createBitmask(0, 65, 66).orInPlace(createBitmask(0)).cardinality()); - Assert.assertEquals(3, createBitmask(0, 65, 66, 128).orInPlace(createBitmask(0)).cardinality()); + void testCardinality() { + assertEquals(0, createBitmask(0).orInPlace(createBitmask(0)).cardinality()); + assertEquals(1, createBitmask(0, 65).orInPlace(createBitmask(0)).cardinality()); + assertEquals(2, createBitmask(0, 65, 66).orInPlace(createBitmask(0)).cardinality()); + assertEquals(3, createBitmask(0, 65, 66, 128).orInPlace(createBitmask(0)).cardinality()); } @Test - public void testOr() { - Assert.assertEquals(createBitmask(0, 0), createBitmask(0).or(createBitmask(0, 0))); - Assert.assertEquals(createBitmask(0, 0, 1), createBitmask(0, 1).or(createBitmask(0, 0))); - Assert.assertEquals(createBitmask(0, 0, 1, 65, 128), createBitmask(0, 1, 128).or(createBitmask(0, 0, 65))); - Assert.assertEquals(createBitmask(0, 0, 1, 65, 128), createBitmask(0, 0, 65).or(createBitmask(0, 1, 128))); + void testOr() { + assertEquals(createBitmask(0, 0), createBitmask(0).or(createBitmask(0, 0))); + assertEquals(createBitmask(0, 0, 1), createBitmask(0, 1).or(createBitmask(0, 0))); + assertEquals(createBitmask(0, 0, 1, 65, 128), createBitmask(0, 1, 128).or(createBitmask(0, 0, 65))); + assertEquals(createBitmask(0, 0, 1, 65, 128), createBitmask(0, 0, 65).or(createBitmask(0, 1, 128))); } @Test - public void testAndNot() { - Assert.assertEquals(createBitmask(0), createBitmask(0).andNot(createBitmask(0, 0))); - Assert.assertEquals(createBitmask(0, 1), createBitmask(0, 0, 1).andNot(createBitmask(0, 0))); - Assert.assertEquals(createBitmask(0, 1, 128), createBitmask(0, 1, 128).andNot(createBitmask(0, 0, 65))); - Assert.assertEquals(createBitmask(0, 65), createBitmask(0, 1, 65, 128).andNot(createBitmask(0, 1, 128))); + void testAndNot() { + assertEquals(createBitmask(0), createBitmask(0).andNot(createBitmask(0, 0))); + assertEquals(createBitmask(0, 1), createBitmask(0, 0, 1).andNot(createBitmask(0, 0))); + assertEquals(createBitmask(0, 1, 128), createBitmask(0, 1, 128).andNot(createBitmask(0, 0, 65))); + assertEquals(createBitmask(0, 65), createBitmask(0, 1, 65, 128).andNot(createBitmask(0, 1, 128))); } @Test - public void testNextSetBit() { + void testNextSetBit() { testSetBits(); testSetBits(0); testSetBits(1); @@ -127,11 +128,11 @@ private void testSetBits(int... setBits) { int i = 0; int nextBit = bitmask.nextSetBit(0); while (i < setBits.length) { - Assert.assertEquals(setBits[i], nextBit); + assertEquals(setBits[i], nextBit); i++; nextBit = bitmask.nextSetBit(nextBit + 1); } - Assert.assertEquals(-1, nextBit); + assertEquals(-1, nextBit); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/ConsumerIteratorAdapterTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/ConsumerIteratorAdapterTest.java index 5b1faa11b..08562c0b9 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/ConsumerIteratorAdapterTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/ConsumerIteratorAdapterTest.java @@ -18,21 +18,24 @@ package org.apache.wayang.core.util; -import org.junit.Assert; -import org.junit.Test; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import java.util.Iterator; import java.util.function.Consumer; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for the {@link ConsumerIteratorAdapter}. */ -public class ConsumerIteratorAdapterTest { +class ConsumerIteratorAdapterTest { @Test - public void testCriticalLoad() { + void testCriticalLoad() { final int maxI = 50000000; final ConsumerIteratorAdapter adapter = new ConsumerIteratorAdapter<>(maxI / 1000); @@ -51,11 +54,11 @@ public void testCriticalLoad() { Logger logger = LogManager.getLogger(this.getClass()); for (int i = 0; i < maxI; i++) { - Assert.assertTrue(iterator.hasNext()); - Assert.assertEquals(i, iterator.next().intValue()); + assertTrue(iterator.hasNext()); + assertEquals(i, iterator.next().intValue()); if (i > 0 && i % 10000000 == 0) logger.info("Put through {} elements.", i); } - Assert.assertFalse(iterator.hasNext()); + assertFalse(iterator.hasNext()); } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/CrossProductIterableTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/CrossProductIterableTest.java index 021d5c8a3..800660fee 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/CrossProductIterableTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/CrossProductIterableTest.java @@ -18,21 +18,22 @@ package org.apache.wayang.core.util; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link CrossProductIterable}. */ -public class CrossProductIterableTest { +class CrossProductIterableTest { @Test - public void test2x3() { + void test2x3() { List> matrix = Arrays.asList( Arrays.asList(1, 2 ,3), Arrays.asList(4, 5, 6) @@ -53,11 +54,11 @@ public void test2x3() { Arrays.asList(3, 6) ); - Assert.assertEquals(expectedCrossProduct, crossProduct); + assertEquals(expectedCrossProduct, crossProduct); } @Test - public void test3x2() { + void test3x2() { List> matrix = Arrays.asList( Arrays.asList(1, 4), Arrays.asList(2, 5), @@ -78,11 +79,11 @@ public void test3x2() { Arrays.asList(4, 5, 6) ); - Assert.assertEquals(expectedCrossProduct, crossProduct); + assertEquals(expectedCrossProduct, crossProduct); } @Test - public void test1x3() { + void test1x3() { List> matrix = Arrays.asList( Arrays.asList(1), Arrays.asList(2), @@ -96,11 +97,11 @@ public void test1x3() { Arrays.asList(1, 2, 3) ); - Assert.assertEquals(expectedCrossProduct, crossProduct); + assertEquals(expectedCrossProduct, crossProduct); } @Test - public void test3x1() { + void test3x1() { List> matrix = Arrays.asList( Arrays.asList(1, 2, 3) ); @@ -114,11 +115,11 @@ public void test3x1() { Arrays.asList(3) ); - Assert.assertEquals(expectedCrossProduct, crossProduct); + assertEquals(expectedCrossProduct, crossProduct); } @Test - public void test1x1() { + void test1x1() { List> matrix = Arrays.asList( Arrays.asList(1) ); @@ -130,11 +131,11 @@ public void test1x1() { Arrays.asList(1) ); - Assert.assertEquals(expectedCrossProduct, crossProduct); + assertEquals(expectedCrossProduct, crossProduct); } @Test - public void test0x0() { + void test0x0() { List> matrix = Arrays.asList( ); final Iterable> crossProductStream = WayangCollections.streamedCrossProduct(matrix); @@ -144,11 +145,11 @@ public void test0x0() { List> expectedCrossProduct = Arrays.asList( ); - Assert.assertEquals(expectedCrossProduct, crossProduct); + assertEquals(expectedCrossProduct, crossProduct); } @Test - public void test2and0() { + void test2and0() { List> matrix = Arrays.asList( Arrays.asList(1, 2), Arrays.asList() @@ -160,6 +161,6 @@ public void test2and0() { List> expectedCrossProduct = Arrays.asList( ); - Assert.assertEquals(expectedCrossProduct, crossProduct); + assertEquals(expectedCrossProduct, crossProduct); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/LimitedInputStreamTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/LimitedInputStreamTest.java index f757d792c..47d466266 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/LimitedInputStreamTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/LimitedInputStreamTest.java @@ -18,19 +18,20 @@ package org.apache.wayang.core.util; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for the {@link LimitedInputStream}. */ -public class LimitedInputStreamTest { +class LimitedInputStreamTest { @Test - public void testLimitation() throws IOException { + void testLimitation() throws IOException { // Generate test data. byte[] testData = new byte[(int) Byte.MAX_VALUE + 1]; for (int b = 0; b <= Byte.MAX_VALUE; b++) { @@ -43,12 +44,12 @@ public void testLimitation() throws IOException { LimitedInputStream lis = new LimitedInputStream(bais, limit); for (int i = 0; i < limit; i++) { - Assert.assertEquals(i, lis.getNumReadBytes()); - Assert.assertEquals(i, lis.read()); + assertEquals(i, lis.getNumReadBytes()); + assertEquals(i, lis.read()); } - Assert.assertEquals(42, lis.getNumReadBytes()); - Assert.assertEquals(-1, lis.read()); - Assert.assertEquals(42, lis.getNumReadBytes()); + assertEquals(42, lis.getNumReadBytes()); + assertEquals(-1, lis.read()); + assertEquals(42, lis.getNumReadBytes()); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/ReflectionUtilsTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/ReflectionUtilsTest.java index 380b2502a..3288e3b66 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/ReflectionUtilsTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/ReflectionUtilsTest.java @@ -18,13 +18,14 @@ package org.apache.wayang.core.util; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link ReflectionUtils}. */ @@ -39,21 +40,21 @@ public static int testInt() { } @Test - public void testEvaluateWithInstantiation() { + void testEvaluateWithInstantiation() { final Object val = ReflectionUtils.evaluate("new java.lang.String()"); - Assert.assertEquals("", val); + assertEquals("", val); } @Test - public void testEvaluateWithStaticVariable() { + void testEvaluateWithStaticVariable() { final Object val = ReflectionUtils.evaluate("org.apache.wayang.core.util.ReflectionUtilsTest.TEST_INT"); - Assert.assertEquals(42, val); + assertEquals(42, val); } @Test - public void testEvaluateWithStaticMethod() { + void testEvaluateWithStaticMethod() { final Object val = ReflectionUtils.evaluate("org.apache.wayang.core.util.ReflectionUtilsTest.testInt()"); - Assert.assertEquals(23, val); + assertEquals(23, val); } public interface MyParameterizedInterface { } @@ -68,7 +69,7 @@ public static class MyParameterizedClassC implements MyParameterizedInterface myParameterizedObject = new MyParameterizedClassB() { }; Map expectedTypeParameters = new HashMap<>(); @@ -80,11 +81,11 @@ public void testGetTypeParametersWithReusedTypeParameters() { MyParameterizedClassA.class ); - Assert.assertEquals(expectedTypeParameters, typeParameters); + assertEquals(expectedTypeParameters, typeParameters); } @Test - public void testGetTypeParametersWithIndirectTypeParameters() { + void testGetTypeParametersWithIndirectTypeParameters() { MyParameterizedClassC myParameterizedObject = new MyParameterizedClassC() { }; Map expectedTypeParameters = new HashMap<>(); @@ -95,7 +96,7 @@ public void testGetTypeParametersWithIndirectTypeParameters() { MyParameterizedInterface.class ); - Assert.assertEquals(expectedTypeParameters, typeParameters); + assertEquals(expectedTypeParameters, typeParameters); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/WayangCollectionsTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/WayangCollectionsTest.java index 210e83135..6f8c0e042 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/WayangCollectionsTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/WayangCollectionsTest.java @@ -18,23 +18,25 @@ package org.apache.wayang.core.util; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link WayangCollections}. */ -public class WayangCollectionsTest { +class WayangCollectionsTest { @Test - public void testCreatePowerList() { + void testCreatePowerList() { final List list = WayangArrays.asList(0, 1, 2, 3, 4); final Collection> powerList = WayangCollections.createPowerList(list, 3); - Assert.assertEquals(1 + 5 + 10 + 10, powerList.size()); + assertEquals(1 + 5 + 10 + 10, powerList.size()); List> expectedPowerSetMembers = Arrays.asList( WayangArrays.asList(), WayangArrays.asList(0), WayangArrays.asList(1), WayangArrays.asList(2), WayangArrays.asList(3), WayangArrays.asList(4), @@ -44,7 +46,7 @@ public void testCreatePowerList() { WayangArrays.asList(0, 3, 4), WayangArrays.asList(1, 2, 3), WayangArrays.asList(1, 2, 4), WayangArrays.asList(1, 3, 4), WayangArrays.asList(2, 3, 4) ); for (List expectedPowerSetMember : expectedPowerSetMembers) { - Assert.assertTrue(String.format("%s is not contained in %s.", expectedPowerSetMember, powerList), powerList.contains(expectedPowerSetMember)); + assertTrue(powerList.contains(expectedPowerSetMember), String.format("%s is not contained in %s.", expectedPowerSetMember, powerList)); } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/mathex/ExpressionBuilderTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/mathex/ExpressionBuilderTest.java index 05c9a977a..71c3eef38 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/mathex/ExpressionBuilderTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/mathex/ExpressionBuilderTest.java @@ -18,21 +18,21 @@ package org.apache.wayang.core.util.mathex; - -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.util.mathex.exceptions.ParseException; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for the class {@link ExpressionBuilder}. */ -public class ExpressionBuilderTest { +class ExpressionBuilderTest { @Test - public void shouldNotFailOnValidInput() { + void shouldNotFailOnValidInput() { Collection expressions = Arrays.asList( "x", "f(x)", @@ -48,7 +48,7 @@ public void shouldNotFailOnValidInput() { } @Test - public void shouldFailOnInvalidInput() { + void shouldFailOnInvalidInput() { Collection expressions = Arrays.asList( // TODO: For some reason this is not failing on my machine //"2x", @@ -65,7 +65,7 @@ public void shouldFailOnInvalidInput() { } catch (ParseException e) { isFailed = true; } finally { - Assert.assertTrue(isFailed); + assertTrue(isFailed); } } } diff --git a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/mathex/ExpressionTest.java b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/mathex/ExpressionTest.java index b2ac236e2..0d11cc856 100644 --- a/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/mathex/ExpressionTest.java +++ b/wayang-commons/wayang-core/src/test/java/org/apache/wayang/core/util/mathex/ExpressionTest.java @@ -18,40 +18,44 @@ package org.apache.wayang.core.util.mathex; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.util.mathex.exceptions.EvaluationException; import org.apache.wayang.core.util.mathex.model.CompiledFunction; import org.apache.wayang.core.util.mathex.model.Constant; import org.apache.wayang.core.util.mathex.model.NamedFunction; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Test suite for the {@link Expression} subclasses. */ -public class ExpressionTest { +class ExpressionTest { @Test - public void testSingletonExpressions() { + void testSingletonExpressions() { DefaultContext context = new DefaultContext(Context.baseContext); context.setVariable("x", 42); - Assert.assertEquals(23d, Expression.evaluate("23"), 0d); - Assert.assertEquals(-23d, Expression.evaluate("-23"), 0d); + assertEquals(23d, Expression.evaluate("23"), 0d); + assertEquals(-23d, Expression.evaluate("-23"), 0d); - Assert.assertEquals(42d, Expression.evaluate("x", context), 0d); - Assert.assertEquals(-42d, Expression.evaluate("-x", context), 0d); + assertEquals(42d, Expression.evaluate("x", context), 0d); + assertEquals(-42d, Expression.evaluate("-x", context), 0d); - Assert.assertEquals(Math.E, Expression.evaluate("e", context), 0d); - Assert.assertEquals(Math.PI, Expression.evaluate("pi", context), 0d); + assertEquals(Math.E, Expression.evaluate("e", context), 0d); + assertEquals(Math.PI, Expression.evaluate("pi", context), 0d); - Assert.assertEquals(2d, Expression.evaluate("log(100, 10)", context), 0.000001); + assertEquals(2d, Expression.evaluate("log(100, 10)", context), 0.000001); } @Test - public void testFailsOnMissingContext() { + void testFailsOnMissingContext() { Collection faultyExpressions = Arrays.asList( "x", "myFunction(23)", @@ -66,14 +70,14 @@ public void testFailsOnMissingContext() { } catch (EvaluationException e) { isFailed = true; } catch (Throwable t) { - Assert.fail(String.format("Unexpected %s.", t)); + fail(String.format("Unexpected %s.", t)); } - Assert.assertTrue(String.format("Evaluating \"%s\" did not fail.", faultyExpression), isFailed); + assertTrue(isFailed, String.format("Evaluating \"%s\" did not fail.", faultyExpression)); } } @Test - public void testComplexExpressions() { + void testComplexExpressions() { { final Expression expression = ExpressionBuilder.parse(" (2 *a + 3* b + 5.3 * c0) + 3*abcdef"); DefaultContext ctx = new DefaultContext(); @@ -82,7 +86,7 @@ public void testComplexExpressions() { ctx.setVariable("c0", -23); ctx.setVariable("abcdef", 821.23); - Assert.assertEquals( + assertEquals( (2*5.1 + 3*3 + 5.3*(-23) + 3*821.23), expression.evaluate(ctx), 0.0001 @@ -91,19 +95,19 @@ public void testComplexExpressions() { } @Test - public void testSpecification() { + void testSpecification() { { final Expression expression = ExpressionBuilder.parse("ln(x)"); - Assert.assertTrue(expression instanceof NamedFunction); + assertInstanceOf(NamedFunction.class, expression); final Expression specifiedExpression = expression.specify(Context.baseContext); - Assert.assertTrue(specifiedExpression instanceof CompiledFunction); + assertInstanceOf(CompiledFunction.class, specifiedExpression); } { final Expression expression = ExpressionBuilder.parse("ln(e)"); - Assert.assertTrue(expression instanceof NamedFunction); + assertInstanceOf(NamedFunction.class, expression); final Expression specifiedExpression = expression.specify(Context.baseContext); - Assert.assertTrue(specifiedExpression instanceof Constant); - Assert.assertEquals(1d, specifiedExpression.evaluate(new DefaultContext()), 0.00001d); + assertInstanceOf(Constant.class, specifiedExpression); + assertEquals(1d, specifiedExpression.evaluate(new DefaultContext()), 0.00001d); } } diff --git a/wayang-commons/wayang-utils-profile-db/src/test/java/org/apache/wayang/commons/util/profiledb/ProfileDBTest.java b/wayang-commons/wayang-utils-profile-db/src/test/java/org/apache/wayang/commons/util/profiledb/ProfileDBTest.java index f5c9f94a9..bb7843e60 100644 --- a/wayang-commons/wayang-utils-profile-db/src/test/java/org/apache/wayang/commons/util/profiledb/ProfileDBTest.java +++ b/wayang-commons/wayang-utils-profile-db/src/test/java/org/apache/wayang/commons/util/profiledb/ProfileDBTest.java @@ -14,8 +14,7 @@ import org.apache.wayang.commons.util.profiledb.model.Measurement; import org.apache.wayang.commons.util.profiledb.model.Subject; import org.apache.wayang.commons.util.profiledb.storage.FileStorage; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -24,10 +23,13 @@ import java.nio.file.Files; import java.util.*; -public class ProfileDBTest { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ProfileDBTest { @Test - public void testPolymorphSaveAndLoad() throws IOException { + void testPolymorphSaveAndLoad() throws IOException { File tempDir = Files.createTempDirectory("profiledb").toFile(); File file = new File(tempDir, "new-profiledb.json"); file.createNewFile(); @@ -59,21 +61,21 @@ public void testPolymorphSaveAndLoad() throws IOException { Collection loadedExperiments = profileDB.load(bis); // Compare the experiments. - Assert.assertEquals(1, loadedExperiments.size()); + assertEquals(1, loadedExperiments.size()); Experiment loadedExperiment = loadedExperiments.iterator().next(); - Assert.assertEquals(experiment, loadedExperiment); + assertEquals(experiment, loadedExperiment); // Compare the measurements. - Assert.assertEquals(2, loadedExperiment.getMeasurements().size()); + assertEquals(2, loadedExperiment.getMeasurements().size()); Set expectedMeasurements = new HashSet<>(2); expectedMeasurements.add(timeMeasurement); expectedMeasurements.add(memoryMeasurement); Set loadedMeasurements = new HashSet<>(loadedExperiment.getMeasurements()); - Assert.assertEquals(expectedMeasurements, loadedMeasurements); + assertEquals(expectedMeasurements, loadedMeasurements); } @Test - public void testRecursiveSaveAndLoad() throws IOException { + void testRecursiveSaveAndLoad() throws IOException { File tempDir = Files.createTempDirectory("profiledb").toFile(); File file = new File(tempDir, "new-profiledb.json"); file.createNewFile(); @@ -103,18 +105,18 @@ public void testRecursiveSaveAndLoad() throws IOException { Collection loadedExperiments = profileDB.load(bis); // Compare the experiments. - Assert.assertEquals(1, loadedExperiments.size()); + assertEquals(1, loadedExperiments.size()); Experiment loadedExperiment = loadedExperiments.iterator().next(); - Assert.assertEquals(experiment, loadedExperiment); + assertEquals(experiment, loadedExperiment); // Compare the measurements. - Assert.assertEquals(1, loadedExperiment.getMeasurements().size()); + assertEquals(1, loadedExperiment.getMeasurements().size()); final Measurement loadedMeasurement = loadedExperiment.getMeasurements().iterator().next(); - Assert.assertEquals(topLevelMeasurement, loadedMeasurement); + assertEquals(topLevelMeasurement, loadedMeasurement); } @Test - public void testFileOperations() throws IOException { + void testFileOperations() throws IOException { File tempDir = Files.createTempDirectory("profiledb").toFile(); File file = new File(tempDir, "profiledb.json"); file.createNewFile(); @@ -141,12 +143,12 @@ public void testFileOperations() throws IOException { // Load and compare. final Set loadedExperiments = new HashSet<>(profileDB.load()); final List expectedExperiments = Arrays.asList(experiment1, experiment2, experiment3); - Assert.assertEquals(expectedExperiments.size(), loadedExperiments.size()); - Assert.assertEquals(new HashSet<>(expectedExperiments), new HashSet<>(loadedExperiments)); + assertEquals(expectedExperiments.size(), loadedExperiments.size()); + assertEquals(new HashSet<>(expectedExperiments), new HashSet<>(loadedExperiments)); } @Test - public void testAppendOnNonExistentFile() throws IOException { + void testAppendOnNonExistentFile() throws IOException { File tempDir = Files.createTempDirectory("profiledb").toFile(); File file = new File(tempDir, "new-profiledb.json"); @@ -163,7 +165,7 @@ public void testAppendOnNonExistentFile() throws IOException { experiment1.addMeasurement(new TestTimeMeasurement("exec-time", 1L)); // Save the experiments. - Assert.assertTrue(!file.exists() || file.delete()); + assertTrue(!file.exists() || file.delete()); profileDB.append(experiment1); Files.lines(file.toPath()).forEach(System.out::println); @@ -171,8 +173,8 @@ public void testAppendOnNonExistentFile() throws IOException { // Load and compare. final Set loadedExperiments = new HashSet<>(profileDB.load()); final List expectedExperiments = Collections.singletonList(experiment1); - Assert.assertEquals(expectedExperiments.size(), loadedExperiments.size()); - Assert.assertEquals(new HashSet<>(expectedExperiments), new HashSet<>(loadedExperiments)); + assertEquals(expectedExperiments.size(), loadedExperiments.size()); + assertEquals(new HashSet<>(expectedExperiments), new HashSet<>(loadedExperiments)); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCartesianOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCartesianOperatorTest.java index 6c3c5e66b..2d267fbce 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCartesianOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCartesianOperatorTest.java @@ -22,19 +22,20 @@ import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkCartesianOperator}. */ -public class FlinkCartesianOperatorTest extends FlinkOperatorTestBase { +class FlinkCartesianOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input0 = this.createDataSetChannelInstance(Arrays.asList(1, 2)); DataSetChannel.Instance input1 = this.createDataSetChannelInstance(Arrays.asList("a", "b", "c")); @@ -55,8 +56,8 @@ public void testExecution() throws Exception { // Verify the outcome. final List> result = output.>provideDataSet().collect(); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(result.get(0), new Tuple2(1, "a")); + assertEquals(6, result.size()); + assertEquals(new Tuple2(1, "a"), result.get(0)); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCoGroupOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCoGroupOperatorTest.java index 26cd6e224..b395a4d45 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCoGroupOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCoGroupOperatorTest.java @@ -26,18 +26,20 @@ import org.apache.wayang.core.util.Tuple; import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.*; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Test suite for {@link FlinkCoGroupOperator}. */ -public class FlinkCoGroupOperatorTest extends FlinkOperatorTestBase { +class FlinkCoGroupOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input0 = this.createDataSetChannelInstance(Arrays.asList( new Tuple2<>(1, "b"), new Tuple2<>(1, "c"), new Tuple2<>(2, "d"), new Tuple2<>(3, "e"))); @@ -99,11 +101,11 @@ public void testExecution() throws Exception { continue ResultLoop; } } - Assert.fail(String.format("Unexpected group: %s", resultCoGroup)); + fail(String.format("Unexpected group: %s", resultCoGroup)); } - Assert.assertTrue( - String.format("Missing groups: %s", expectedGroups), - expectedGroups.isEmpty() + assertTrue( + expectedGroups.isEmpty(), + String.format("Missing groups: %s", expectedGroups) ); } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCollectionSourceTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCollectionSourceTest.java index a983ea542..63f18bbfa 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCollectionSourceTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCollectionSourceTest.java @@ -21,20 +21,21 @@ import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for the {@link FlinkCollectionSource}. */ -public class FlinkCollectionSourceTest extends FlinkOperatorTestBase{ +class FlinkCollectionSourceTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { Set inputValues = new HashSet<>(Arrays.asList(1, 2, 3)); FlinkCollectionSource collectionSource = new FlinkCollectionSource( inputValues, @@ -49,6 +50,6 @@ public void testExecution() throws Exception { this.evaluate(collectionSource, inputs, outputs); final Set outputValues = new HashSet<>(output.provideDataSet().collect()); - Assert.assertEquals(outputValues, inputValues); + assertEquals(outputValues, inputValues); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCountOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCountOperatorTest.java index 577b7d5e4..98fdede01 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCountOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkCountOperatorTest.java @@ -18,26 +18,22 @@ package org.apache.wayang.flink.operators; -import org.apache.flink.api.java.DataSet; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; -import org.apache.wayang.core.util.Tuple; import org.apache.wayang.flink.channels.DataSetChannel; -import org.apache.wayang.java.channels.CollectionChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import javax.xml.crypto.Data; import java.util.Arrays; -import java.util.Collection; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkCountOperator}. */ -public class FlinkCountOperatorTest extends FlinkOperatorTestBase{ +class FlinkCountOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input = this.createDataSetChannelInstance(Arrays.asList(1, 2, 3, 4, 5)); DataSetChannel.Instance output = this.createDataSetChannelInstance(); @@ -55,8 +51,8 @@ public void testExecution() throws Exception { // Verify the outcome. final List result = output.provideDataSet().collect(); - Assert.assertEquals(1,result.size()); - Assert.assertEquals(Long.valueOf(5),result.iterator().next()); + assertEquals(1,result.size()); + assertEquals(Long.valueOf(5),result.iterator().next()); } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkDistinctOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkDistinctOperatorTest.java index 80f749f7e..86d21db40 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkDistinctOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkDistinctOperatorTest.java @@ -21,21 +21,21 @@ import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import javax.xml.crypto.Data; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkDistinctOperator}. */ //The test assert error expected 4, actual 1 -public class FlinkDistinctOperatorTest extends FlinkOperatorTestBase{ +class FlinkDistinctOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. List inputData = Arrays.asList(0, 1, 1, 6, 2, 2, 6, 6); @@ -55,9 +55,9 @@ public void testExecution() throws Exception { // Verify the outcome. final List result = ((DataSetChannel.Instance) outputs[0]).provideDataSet().collect(); - Assert.assertEquals(4, result.size()); + assertEquals(4, result.size()); result.sort((a, b) -> a - b); - Assert.assertEquals(Arrays.asList(0, 1, 2, 6), result); + assertEquals(Arrays.asList(0, 1, 2, 6), result); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkFilterOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkFilterOperatorTest.java index 65cbb6268..f4f1b9345 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkFilterOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkFilterOperatorTest.java @@ -22,19 +22,20 @@ import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkFilterOperator}. */ -public class FlinkFilterOperatorTest extends FlinkOperatorTestBase{ +class FlinkFilterOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input = this.createDataSetChannelInstance(Arrays.asList(0, 1, 1, 2, 6)); DataSetChannel.Instance output = this.createDataSetChannelInstance(); @@ -55,8 +56,8 @@ public void testExecution() throws Exception { // Verify the outcome. final List result = output.provideDataSet().collect(); - Assert.assertEquals(4, result.size()); - Assert.assertEquals(Arrays.asList(1, 1, 2, 6), result); + assertEquals(4, result.size()); + assertEquals(Arrays.asList(1, 1, 2, 6), result); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkFlatMapOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkFlatMapOperatorTest.java index 7a7b53f37..6801d7709 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkFlatMapOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkFlatMapOperatorTest.java @@ -22,18 +22,19 @@ import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkFlatMapOperator}. */ -public class FlinkFlatMapOperatorTest extends FlinkOperatorTestBase{ +class FlinkFlatMapOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input = this.createDataSetChannelInstance(Arrays.asList("one phrase", "two sentences", "three lines")); DataSetChannel.Instance output = this.createDataSetChannelInstance(); @@ -53,8 +54,8 @@ public void testExecution() throws Exception { // Verify the outcome. final List result = output.provideDataSet().collect(); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(Arrays.asList("one", "phrase", "two", "sentences", "three", "lines"), result); + assertEquals(6, result.size()); + assertEquals(Arrays.asList("one", "phrase", "two", "sentences", "three", "lines"), result); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkGlobalMaterializedGroupOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkGlobalMaterializedGroupOperatorTest.java index 1bb836215..884cdc943 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkGlobalMaterializedGroupOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkGlobalMaterializedGroupOperatorTest.java @@ -20,22 +20,21 @@ import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; -import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test suite for {@link FlinkGlobalMaterializedGroupOperator}. */ -public class FlinkGlobalMaterializedGroupOperatorTest extends FlinkOperatorTestBase{ +class FlinkGlobalMaterializedGroupOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. Collection inputCollection = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); @@ -53,8 +52,8 @@ public void testExecution() throws Exception { // Verify the outcome. final Collection> result = ((DataSetChannel.Instance) outputs[0]).>provideDataSet().collect(); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(inputCollection, result.iterator().next()); + assertEquals(1, result.size()); + assertEquals(inputCollection, result.iterator().next()); } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkGlobalReduceOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkGlobalReduceOperatorTest.java index db51b1024..43adaae4e 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkGlobalReduceOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkGlobalReduceOperatorTest.java @@ -26,21 +26,22 @@ import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.flink.channels.DataSetChannel; import org.apache.wayang.java.channels.CollectionChannel; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkGlobalReduceOperator}. */ -public class FlinkGlobalReduceOperatorTest extends FlinkOperatorTestBase { +class FlinkGlobalReduceOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input = this.createDataSetChannelInstance(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); DataSetChannel.Instance output = this.createDataSetChannelInstance(); @@ -64,14 +65,14 @@ public void testExecution() throws Exception { // Verify the outcome. final List result = output.provideDataSet().collect(); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(Integer.valueOf((10 + 1) * (10 / 2)), result.get(0)); // Props to Gauss! + assertEquals(1, result.size()); + assertEquals(Integer.valueOf((10 + 1) * (10 / 2)), result.get(0)); // Props to Gauss! } - @Ignore("Flink cannot reduce empty collections.") + @Disabled("Flink cannot reduce empty collections.") @Test - public void testExecutionWithoutData() throws Exception { + void testExecutionWithoutData() throws Exception { // Prepare test data. DataSetChannel.Instance input = this.createDataSetChannelInstance(Collections.emptyList()); CollectionChannel.Instance output = this.createCollectionChannelInstance(); @@ -95,8 +96,8 @@ public void testExecutionWithoutData() throws Exception { // Verify the outcome. final List result = WayangCollections.asList(output.provideCollection()); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(Integer.valueOf(0), result.get(0)); + assertEquals(1, result.size()); + assertEquals(Integer.valueOf(0), result.get(0)); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkJoinOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkJoinOperatorTest.java index db703b9e7..8275e092c 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkJoinOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkJoinOperatorTest.java @@ -24,17 +24,17 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test suite for {@link FlinkJoinOperator}. */ -public class FlinkJoinOperatorTest extends FlinkOperatorTestBase{ +class FlinkJoinOperatorTest extends FlinkOperatorTestBase { //TODO: Validate FlinkJoinOperator implementation // it is required to validate the implementation of FlinkJoinOperator @@ -42,7 +42,7 @@ public class FlinkJoinOperatorTest extends FlinkOperatorTestBase{ // implementation of the implementation in the operator // labels:flink,bug @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input0 = this.createDataSetChannelInstance(Arrays.asList( new Tuple2<>(1, "b"), new Tuple2<>(1, "c"), new Tuple2<>(2, "d"), new Tuple2<>(3, "e"))); @@ -74,12 +74,12 @@ public void testExecution() throws Exception { // Verify the outcome. final List, Tuple2>> result = output., Tuple2>>provideDataSet().collect(); - Assert.assertEquals(5, result.size()); - Assert.assertEquals(result.get(0), new Tuple2<>(new Tuple2<>(1, "b"), new Tuple2<>("x", 1))); - Assert.assertEquals(result.get(1), new Tuple2<>(new Tuple2<>(1, "b"), new Tuple2<>("y", 1))); - Assert.assertEquals(result.get(2), new Tuple2<>(new Tuple2<>(1, "c"), new Tuple2<>("x", 1))); - Assert.assertEquals(result.get(3), new Tuple2<>(new Tuple2<>(1, "c"), new Tuple2<>("y", 1))); - Assert.assertEquals(result.get(4), new Tuple2<>(new Tuple2<>(2, "d"), new Tuple2<>("z", 2))); + assertEquals(5, result.size()); + assertEquals(new Tuple2<>(new Tuple2<>(1, "b"), new Tuple2<>("x", 1)), result.get(0)); + assertEquals(new Tuple2<>(new Tuple2<>(1, "b"), new Tuple2<>("y", 1)), result.get(1)); + assertEquals(new Tuple2<>(new Tuple2<>(1, "c"), new Tuple2<>("x", 1)), result.get(2)); + assertEquals(new Tuple2<>(new Tuple2<>(1, "c"), new Tuple2<>("y", 1)), result.get(3)); + assertEquals(new Tuple2<>(new Tuple2<>(2, "d"), new Tuple2<>("z", 2)), result.get(4)); } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkMapPartitionsOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkMapPartitionsOperatorTest.java index 18ed5019f..6ee942777 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkMapPartitionsOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkMapPartitionsOperatorTest.java @@ -22,21 +22,22 @@ import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; import java.util.LinkedList; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkMapPartitionsOperator}. */ -public class FlinkMapPartitionsOperatorTest extends FlinkOperatorTestBase { +class FlinkMapPartitionsOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input = this.createDataSetChannelInstance(Arrays.asList(0, 1, 1, 2, 6)); DataSetChannel.Instance output = this.createDataSetChannelInstance(); @@ -64,8 +65,8 @@ public void testExecution() throws Exception { // Verify the outcome. final List result = output.provideDataSet().collect(); - Assert.assertEquals(5, result.size()); - Assert.assertEquals(Arrays.asList(1, 2, 2, 3, 7), result); + assertEquals(5, result.size()); + assertEquals(Arrays.asList(1, 2, 2, 3, 7), result); } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkMaterializedGroupByOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkMaterializedGroupByOperatorTest.java index bae54f4c1..02a2c7d92 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkMaterializedGroupByOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkMaterializedGroupByOperatorTest.java @@ -24,8 +24,7 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -34,14 +33,18 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Test suite for {@link FlinkMaterializedGroupByOperator}. */ -public class FlinkMaterializedGroupByOperatorTest extends FlinkOperatorTestBase { +class FlinkMaterializedGroupByOperatorTest extends FlinkOperatorTestBase { @Test @SuppressWarnings("unchecked") - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. AtomicInteger counter = new AtomicInteger(0); DataSetChannel.Instance input = this.createDataSetChannelInstance(Arrays.stream("abcaba".split("")) @@ -71,7 +74,7 @@ public void testExecution() throws Exception { } catch (Exception e){ e.printStackTrace(); - Assert.fail(); + fail(); } // Verify the outcome. @@ -87,8 +90,8 @@ public void testExecution() throws Exception { Arrays.asList(new Tuple2<>("c", 2)) }; Arrays.stream(expectedResults) - .forEach(expected -> Assert.assertTrue("Not contained: " + expected, result.contains(expected))); - Assert.assertEquals(expectedResults.length, result.size()); + .forEach(expected -> assertTrue(result.contains(expected), "Not contained: " + expected)); + assertEquals(expectedResults.length, result.size()); } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkOperatorTestBase.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkOperatorTestBase.java index 6bf1a0ef7..bf0672d20 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkOperatorTestBase.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkOperatorTestBase.java @@ -18,7 +18,6 @@ package org.apache.wayang.flink.operators; -import org.junit.Before; import org.apache.flink.api.java.ExecutionEnvironment; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; @@ -34,6 +33,7 @@ import org.apache.wayang.flink.test.ChannelFactory; import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.flink.operators.FlinkExecutionOperator; +import org.junit.jupiter.api.BeforeEach; import java.util.Collection; @@ -49,8 +49,8 @@ public class FlinkOperatorTestBase { protected FlinkExecutor flinkExecutor; - @Before - public void setUp(){ + @BeforeEach + void setUp(){ this.configuration = new Configuration(); if(flinkExecutor == null) this.flinkExecutor = (FlinkExecutor) FlinkPlatform.getInstance().getExecutorFactory().create(this.mockJob()); diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkReduceByOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkReduceByOperatorTest.java index 0214d7953..ed6682b4f 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkReduceByOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkReduceByOperatorTest.java @@ -25,8 +25,7 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.HashSet; @@ -34,10 +33,14 @@ import java.util.Set; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Test suite for {@link FlinkReduceByOperator}. */ -public class FlinkReduceByOperatorTest extends FlinkOperatorTestBase{ +class FlinkReduceByOperatorTest extends FlinkOperatorTestBase { //TODO: Validate FlinkReduceByOperator implementation // it is required to validate the implementation of FlinkReduceByOperator @@ -45,7 +48,7 @@ public class FlinkReduceByOperatorTest extends FlinkOperatorTestBase{ // implementation of the implementation in the operator // labels:flink,bug @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. List> inputList = Arrays.stream("aaabbccccdeefff".split("")) .map(string -> new Tuple2<>(string, 1)) @@ -80,7 +83,7 @@ public void testExecution() throws Exception { } catch (Exception e) { e.printStackTrace(); - Assert.fail(); + fail(); } // Verify the outcome. @@ -96,8 +99,8 @@ public void testExecution() throws Exception { new Tuple2<>("f", 3) }; Arrays.stream(expectedResults) - .forEach(expected -> Assert.assertTrue("Not contained: " + expected, resultSet.contains(expected))); - Assert.assertEquals(expectedResults.length, resultSet.size()); + .forEach(expected -> assertTrue(resultSet.contains(expected), "Not contained: " + expected)); + assertEquals(expectedResults.length, resultSet.size()); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkSortOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkSortOperatorTest.java index a10c935af..0845dd07a 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkSortOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkSortOperatorTest.java @@ -22,19 +22,20 @@ import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkSortOperator}. */ -public class FlinkSortOperatorTest extends FlinkOperatorTestBase { +class FlinkSortOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input = this.createDataSetChannelInstance(Arrays.asList(6, 0, 1, 1, 5, 2)); DataSetChannel.Instance output = this.createDataSetChannelInstance(); @@ -56,8 +57,8 @@ public void testExecution() throws Exception { // Verify the outcome. final List result = output.provideDataSet().collect(); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(Arrays.asList(0, 1, 1, 2, 5, 6), result); + assertEquals(6, result.size()); + assertEquals(Arrays.asList(0, 1, 1, 2, 5, 6), result); } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkUnionAllOperatorTest.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkUnionAllOperatorTest.java index fff9f1c59..86934face 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkUnionAllOperatorTest.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/operators/FlinkUnionAllOperatorTest.java @@ -18,23 +18,23 @@ package org.apache.wayang.flink.operators; -import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.flink.channels.DataSetChannel; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link FlinkUnionAllOperator}. */ -public class FlinkUnionAllOperatorTest extends FlinkOperatorTestBase { +class FlinkUnionAllOperatorTest extends FlinkOperatorTestBase { @Test - public void testExecution() throws Exception { + void testExecution() throws Exception { // Prepare test data. DataSetChannel.Instance input0 = this.createDataSetChannelInstance(Arrays.asList(6, 0, 1, 1, 5, 2)); DataSetChannel.Instance input1 = this.createDataSetChannelInstance(Arrays.asList(1, 1, 9)); @@ -56,7 +56,7 @@ public void testExecution() throws Exception { // Verify the outcome. final List result = output.provideDataSet().collect(); // final List result = ((DataSetChannel.Instance) outputs[0]).provideDataSet().collect(); - Assert.assertEquals(9, result.size()); - Assert.assertEquals(Arrays.asList(6, 0, 1, 1, 5, 2, 1, 1, 9), result); + assertEquals(9, result.size()); + assertEquals(Arrays.asList(6, 0, 1, 1, 5, 2, 1, 1, 9), result); } } diff --git a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/test/ChannelFactory.java b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/test/ChannelFactory.java index 2bb07de3e..1c49ed10e 100644 --- a/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/test/ChannelFactory.java +++ b/wayang-platforms/wayang-flink/src/test/java/org/apache/wayang/flink/test/ChannelFactory.java @@ -24,7 +24,7 @@ import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.flink.channels.DataSetChannel; import org.apache.wayang.java.channels.CollectionChannel; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.apache.wayang.flink.execution.FlinkExecutor; import java.util.Collection; @@ -38,8 +38,8 @@ public class ChannelFactory { private static FlinkExecutor flinkExecutor; - @Before - public void setUp() { + @BeforeEach + void setUp() { flinkExecutor = mock(FlinkExecutor.class); } diff --git a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java index 436c7119a..ced4cc7cc 100644 --- a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java +++ b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.giraph.operators; -import org.junit.Before; -import org.junit.Test; import org.apache.wayang.basic.channels.FileChannel; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; @@ -33,6 +31,9 @@ import org.apache.wayang.giraph.execution.GiraphExecutor; import org.apache.wayang.giraph.platform.GiraphPlatform; import org.apache.wayang.java.channels.StreamChannel; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.IOException; @@ -42,17 +43,19 @@ /** * Test For GiraphPageRank */ -public class GiraphPagaRankOperatorTest { +class GiraphPagaRankOperatorTest { private static GiraphExecutor giraphExecutor; - @Before - public void setUp() { + @BeforeEach + void setUp() { giraphExecutor = mock(GiraphExecutor.class); } - //TODO Validate the mock of GiraphExecutor @Test - public void testExecution() throws IOException { + //TODO Validate the mock of GiraphExecutor + @Disabled + @Test + void testExecution() throws IOException { // Ensure that the GraphChiPlatform is initialized. GiraphPlatform.getInstance(); final Configuration configuration = new Configuration(); diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/execution/JavaExecutorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/execution/JavaExecutorTest.java index 39f76f486..9b79ce2e5 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/execution/JavaExecutorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/execution/JavaExecutorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.java.execution; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.api.WayangContext; import org.apache.wayang.core.function.ExecutionContext; import org.apache.wayang.core.function.FunctionDescriptor; @@ -33,18 +31,21 @@ import org.apache.wayang.java.operators.JavaDoWhileOperator; import org.apache.wayang.java.operators.JavaLocalCallbackSink; import org.apache.wayang.java.operators.JavaMapOperator; +import org.junit.jupiter.api.Test; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for the {@link JavaExecutor}. */ -public class JavaExecutorTest { +class JavaExecutorTest { @Test - public void testLazyExecutionResourceHandling() { + void testLazyExecutionResourceHandling() { // The JavaExecutor should not dispose resources that are consumed by lazily executed ExecutionOperators until // execution. JavaCollectionSource source1 = new JavaCollectionSource<>( @@ -125,7 +126,7 @@ public void open(ExecutionContext ctx) { final WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); wayangContext.execute(new WayangPlan(sink)); - Assert.assertEquals(WayangArrays.asList(6, 7, 8), collector); + assertEquals(WayangArrays.asList(6, 7, 8), collector); } } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCartesianOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCartesianOperatorTest.java index 05c8e7fcb..627502aff 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCartesianOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCartesianOperatorTest.java @@ -18,24 +18,25 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaCartesianOperator}. */ -public class JavaCartesianOperatorTest extends JavaExecutionOperatorTestBase { +class JavaCartesianOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream inputStream0 = Arrays.asList(1, 2).stream(); Stream inputStream1 = Arrays.asList("a", "b", "c").stream(); @@ -57,8 +58,8 @@ public void testExecution() { // Verify the outcome. final List> result = outputs[0].>provideStream() .collect(Collectors.toList()); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(result.get(0), new Tuple2(1, "a")); + assertEquals(6, result.size()); + assertEquals(new Tuple2(1, "a"), result.get(0)); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCoGroupOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCoGroupOperatorTest.java index 64b7451bc..5a81b5ca7 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCoGroupOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCoGroupOperatorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.core.types.DataSetType; @@ -28,6 +26,7 @@ import org.apache.wayang.core.util.Tuple; import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; @@ -35,13 +34,16 @@ import java.util.Collections; import java.util.Iterator; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Test suite for {@link JavaJoinOperator}. */ -public class JavaCoGroupOperatorTest extends JavaExecutionOperatorTestBase { +class JavaCoGroupOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. CollectionChannel.Instance input0 = createCollectionChannelInstance(Arrays.asList( new Tuple2<>(1, "b"), @@ -104,11 +106,11 @@ public void testExecution() { continue ResultLoop; } } - Assert.fail(String.format("Unexpected group: %s", resultCoGroup)); + fail(String.format("Unexpected group: %s", resultCoGroup)); } - Assert.assertTrue( - String.format("Missing groups: %s", expectedGroups), - expectedGroups.isEmpty() + assertTrue( + expectedGroups.isEmpty(), + String.format("Missing groups: %s", expectedGroups) ); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCollectionSourceTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCollectionSourceTest.java index 44464306f..d6762adb5 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCollectionSourceTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCollectionSourceTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for the {@link JavaCollectionSource}. */ -public class JavaCollectionSourceTest extends JavaExecutionOperatorTestBase { +class JavaCollectionSourceTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { Set inputValues = new HashSet<>(Arrays.asList(1, 2, 3)); JavaCollectionSource collectionSource = new JavaCollectionSource( inputValues, @@ -45,7 +46,7 @@ public void testExecution() { evaluate(collectionSource, inputs, outputs); final Set outputValues = outputs[0].provideStream().collect(Collectors.toSet()); - Assert.assertEquals(outputValues, inputValues); + assertEquals(outputValues, inputValues); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCountOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCountOperatorTest.java index a7af4adb7..d5045fb9f 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCountOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaCountOperatorTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaCountOperator}. */ -public class JavaCountOperatorTest extends JavaExecutionOperatorTestBase { +class JavaCountOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream inputStream = Arrays.asList(1, 2, 3, 4, 5).stream(); @@ -51,8 +52,8 @@ public void testExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(Long.valueOf(5), result.get(0)); + assertEquals(1, result.size()); + assertEquals(Long.valueOf(5), result.get(0)); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaDistinctOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaDistinctOperatorTest.java index 6c9632b0f..ea9e0bf46 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaDistinctOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaDistinctOperatorTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaDistinctOperator}. */ -public class JavaDistinctOperatorTest extends JavaExecutionOperatorTestBase { +class JavaDistinctOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream inputStream = Arrays.asList(0, 1, 1, 2, 2, 6, 6).stream(); @@ -51,8 +52,8 @@ public void testExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(4, result.size()); - Assert.assertEquals(Arrays.asList(0, 1, 2, 6), result); + assertEquals(4, result.size()); + assertEquals(Arrays.asList(0, 1, 2, 6), result); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaExecutionOperatorTestBase.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaExecutionOperatorTestBase.java index 67c7ab48e..a3cb92e95 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaExecutionOperatorTestBase.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaExecutionOperatorTestBase.java @@ -18,7 +18,6 @@ package org.apache.wayang.java.operators; -import org.junit.BeforeClass; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; @@ -33,6 +32,7 @@ import org.apache.wayang.java.execution.JavaExecutor; import org.apache.wayang.java.platform.JavaPlatform; import org.apache.wayang.java.test.ChannelFactory; +import org.junit.jupiter.api.BeforeAll; import java.util.Collection; import java.util.stream.Stream; @@ -49,8 +49,8 @@ public class JavaExecutionOperatorTestBase { protected static Job job; - @BeforeClass - public static void init() { + @BeforeAll + static void init() { configuration = new Configuration(); job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaFilterOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaFilterOperatorTest.java index 504d9c90d..68f2427c9 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaFilterOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaFilterOperatorTest.java @@ -18,24 +18,25 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.function.PredicateDescriptor; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaFilterOperator}. */ -public class JavaFilterOperatorTest extends JavaExecutionOperatorTestBase { +class JavaFilterOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream inputStream = Arrays.asList(0, 1, 1, 2, 6).stream(); @@ -52,8 +53,8 @@ public void testExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(4, result.size()); - Assert.assertEquals(Arrays.asList(1, 1, 2, 6), result); + assertEquals(4, result.size()); + assertEquals(Arrays.asList(1, 1, 2, 6), result); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaGlobalMaterializedGroupOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaGlobalMaterializedGroupOperatorTest.java index b63b623c4..7a8ab41c7 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaGlobalMaterializedGroupOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaGlobalMaterializedGroupOperatorTest.java @@ -18,23 +18,25 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link JavaGlobalReduceOperator}. */ -public class JavaGlobalMaterializedGroupOperatorTest extends JavaExecutionOperatorTestBase { +class JavaGlobalMaterializedGroupOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Collection inputCollection = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); @@ -52,13 +54,13 @@ public void testExecution() { // Verify the outcome. final Collection> result = ((CollectionChannel.Instance) outputs[0]).provideCollection(); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(inputCollection, result.iterator().next()); + assertEquals(1, result.size()); + assertEquals(inputCollection, result.iterator().next()); } @Test - public void testExecutionWithoutData() { + void testExecutionWithoutData() { // Prepare test data. Collection inputCollection = Collections.emptyList(); @@ -76,7 +78,7 @@ public void testExecutionWithoutData() { // Verify the outcome. final Collection> result = ((CollectionChannel.Instance) outputs[0]).provideCollection(); - Assert.assertEquals(1, result.size()); - Assert.assertTrue(result.iterator().next().isEmpty()); + assertEquals(1, result.size()); + assertTrue(result.iterator().next().isEmpty()); } } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaGlobalReduceOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaGlobalReduceOperatorTest.java index 54023f12b..e16436f52 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaGlobalReduceOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaGlobalReduceOperatorTest.java @@ -18,26 +18,27 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.function.ReduceDescriptor; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaGlobalReduceOperator}. */ -public class JavaGlobalReduceOperatorTest extends JavaExecutionOperatorTestBase { +class JavaGlobalReduceOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream inputStream = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).stream(); @@ -58,13 +59,13 @@ public void testExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(Integer.valueOf((10 + 1) * (10 / 2)), result.get(0)); // Props to Gauss! + assertEquals(1, result.size()); + assertEquals(Integer.valueOf((10 + 1) * (10 / 2)), result.get(0)); // Props to Gauss! } @Test - public void testExecutionWithoutData() { + void testExecutionWithoutData() { // Prepare test data. Stream inputStream = Arrays.asList().stream(); @@ -85,7 +86,7 @@ public void testExecutionWithoutData() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(0, result.size()); + assertEquals(0, result.size()); } } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaJoinOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaJoinOperatorTest.java index 65cb5f7a0..039da7a10 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaJoinOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaJoinOperatorTest.java @@ -18,13 +18,12 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; @@ -32,13 +31,15 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaJoinOperator}. */ -public class JavaJoinOperatorTest extends JavaExecutionOperatorTestBase { +class JavaJoinOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream> inputStream0 = Arrays.asList( new Tuple2<>(1, "b"), new Tuple2<>(1, "c"), new Tuple2<>(2, "d"), new Tuple2<>(3, "e") @@ -94,7 +95,7 @@ public void testExecution() { new Tuple2<>(new Tuple2<>(2, "d"), new Tuple2<>("z", 2)) ); - Assert.assertEquals(expectedResult, result); + assertEquals(expectedResult, result); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaKafkaTopicSinkTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaKafkaTopicSinkTest.java index 4f309fac0..1a418d4b0 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaKafkaTopicSinkTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaKafkaTopicSinkTest.java @@ -18,49 +18,37 @@ package org.apache.wayang.java.operators; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.function.TransformationDescriptor; import org.apache.wayang.core.optimizer.OptimizationContext; import org.apache.wayang.core.plan.wayangplan.OutputSlot; import org.apache.wayang.core.platform.ChannelInstance; -import org.apache.wayang.core.util.fs.LocalFileSystem; import org.apache.wayang.java.channels.StreamChannel; import org.apache.wayang.java.execution.JavaExecutor; import org.apache.wayang.java.platform.JavaPlatform; - import org.apache.wayang.basic.operators.KafkaTopicSource; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.text.DecimalFormatSymbols; -import java.text.NumberFormat; -import java.util.Arrays; -import java.util.List; import java.util.Locale; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.Properties; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Test suite for {@link JavaKafkaTopicSink}. */ -public class JavaKafkaTopicSinkTest extends JavaExecutionOperatorTestBase { +class JavaKafkaTopicSinkTest extends JavaExecutionOperatorTestBase { private static final Logger logger = LoggerFactory.getLogger(JavaTextFileSinkTest.class); @@ -71,21 +59,21 @@ public class JavaKafkaTopicSinkTest extends JavaExecutionOperatorTestBase { * Therefore we ensure it's run in a pre-defined locale and we make sure it's * reset after the test. */ - @Before - public void setupTest() { + @BeforeEach + void setupTest() { defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.US); } - @After - public void teardownTest() { + @AfterEach + void teardownTest() { Locale.setDefault(defaultLocale); } - - //@Test - public void testWritingToKafkaTopic() throws Exception { + @Disabled + @Test + void testWritingToKafkaTopic() throws Exception { Configuration configuration = new Configuration(); @@ -107,9 +95,9 @@ public void testWritingToKafkaTopic() throws Exception { props.list(System.out); logger.info("> 2 ... "); - + JavaExecutor javaExecutor = null; - + try { JavaKafkaTopicSink sink = new JavaKafkaTopicSink<>( @@ -121,7 +109,7 @@ public void testWritingToKafkaTopic() throws Exception { ); logger.info("> 3 ... "); - + Job job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); javaExecutor = (JavaExecutor) JavaPlatform.getInstance().createExecutor(job); @@ -136,16 +124,16 @@ public void testWritingToKafkaTopic() throws Exception { } catch (Exception ex ) { - + ex.printStackTrace(); logger.info("##5## ... "); - Assert.fail(); - + fail(); + } - Assert.assertTrue( true ); + assertTrue( true ); logger.info("> *6*"); diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaKafkaTopicSourceTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaKafkaTopicSourceTest.java index 8008a8015..75d9263db 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaKafkaTopicSourceTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaKafkaTopicSourceTest.java @@ -20,25 +20,20 @@ import org.apache.wayang.basic.operators.KafkaTopicSource; import org.apache.wayang.java.channels.JavaChannelInstance; import org.apache.wayang.java.execution.JavaExecutor; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.time.Duration; -import java.util.Arrays; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + import java.util.List; import java.util.Locale; import java.util.Properties; import java.util.stream.Collectors; -import org.apache.kafka.clients.consumer.ConsumerConfig; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.apache.kafka.clients.consumer.ConsumerRecords; -import org.apache.kafka.clients.consumer.KafkaConsumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +41,7 @@ /** * Test suite for {@link JavaKafkaTopicSource}. */ -public class JavaKafkaTopicSourceTest extends JavaExecutionOperatorTestBase { +class JavaKafkaTopicSourceTest extends JavaExecutionOperatorTestBase { private static final Logger logger = LoggerFactory.getLogger(JavaKafkaTopicSourceTest.class); @@ -57,27 +52,28 @@ public class JavaKafkaTopicSourceTest extends JavaExecutionOperatorTestBase { * Therefore we ensure it's run in a pre-defined locale and we make sure it's * reset after the test. */ - @Before - public void setupTest() { + @BeforeEach + void setupTest() { defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.US); logger.info(">>> Test SETUP()"); } - @After - public void teardownTest() { + @AfterEach + void teardownTest() { logger.info(">>> Test TEARDOWN()"); Locale.setDefault(defaultLocale); } @Test - public void testA() throws Exception { - Assert.assertEquals(3, 3); + void testA() throws Exception { + assertEquals(3, 3); logger.info(">>> Test A"); } - //@Test - public void testReadFromKafkaTopic() { + @Test + @Disabled + void testReadFromKafkaTopic() { logger.info(">>> Test: testReadFromKafkaTopic()"); @@ -92,7 +88,7 @@ public void testReadFromKafkaTopic() { logger.info("> 1 ... "); Properties props = KafkaTopicSource.getDefaultProperties(); - + logger.info("> 2 ... "); props.list(System.out); @@ -117,8 +113,8 @@ public void testReadFromKafkaTopic() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertNotNull(jks); - Assert.assertNotNull(result); + assertNotNull(jks); + assertNotNull(result); logger.info("> 6 ... "); diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaLocalCallbackSinkTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaLocalCallbackSinkTest.java index fd23e4975..6fe9bcf16 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaLocalCallbackSinkTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaLocalCallbackSinkTest.java @@ -18,22 +18,23 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaLocalCallbackSink}. */ -public class JavaLocalCallbackSinkTest extends JavaExecutionOperatorTestBase { +class JavaLocalCallbackSinkTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. List inputValues = Arrays.asList(1, 2, 3); @@ -47,6 +48,6 @@ public void testExecution() { evaluate(sink, inputs, outputs); // Verify the outcome. - Assert.assertEquals(collector, inputValues); + assertEquals(collector, inputValues); } } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaMaterializedGroupByOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaMaterializedGroupByOperatorTest.java index 4aa76d65a..ed41836fa 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaMaterializedGroupByOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaMaterializedGroupByOperatorTest.java @@ -18,13 +18,12 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -32,13 +31,16 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link JavaReduceByOperator}. */ -public class JavaMaterializedGroupByOperatorTest extends JavaExecutionOperatorTestBase { +class JavaMaterializedGroupByOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. AtomicInteger counter = new AtomicInteger(0); Stream> inputStream = Arrays.stream("abcaba".split("")) @@ -69,8 +71,8 @@ public void testExecution() { Arrays.asList(new Tuple2<>("c", 2)) }; Arrays.stream(expectedResults) - .forEach(expected -> Assert.assertTrue("Not contained: " + expected, result.contains(expected))); - Assert.assertEquals(expectedResults.length, result.size()); + .forEach(expected -> assertTrue(result.contains(expected), "Not contained: " + expected)); + assertEquals(expectedResults.length, result.size()); } } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaObjectFileSinkTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaObjectFileSinkTest.java index e23cfae07..0717b41c6 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaObjectFileSinkTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaObjectFileSinkTest.java @@ -19,10 +19,10 @@ package org.apache.wayang.java.operators; import org.apache.commons.lang3.Validate; -import org.junit.Test; import org.apache.wayang.basic.channels.FileChannel; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.Files; @@ -34,12 +34,12 @@ /** * Test suite for {@link JavaObjectFileSink}. */ -public class JavaObjectFileSinkTest extends JavaExecutionOperatorTestBase { +class JavaObjectFileSinkTest extends JavaExecutionOperatorTestBase { // If this test fails, make sure you have Hadoop installed and it's HADOOP_HOME is set. // Also, if on Windows: Make sure you installed the winutils binaries (https://github.com/cdarlint/winutils) @Test - public void testWritingDoesNotFail() throws IOException { + void testWritingDoesNotFail() throws IOException { // Prepare the sink. Path tempDir = Files.createTempDirectory("wayang-java"); tempDir.toFile().deleteOnExit(); diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaObjectFileSourceTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaObjectFileSourceTest.java index d5fdd5509..f3cd42f5b 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaObjectFileSourceTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaObjectFileSourceTest.java @@ -19,11 +19,10 @@ package org.apache.wayang.java.operators; import org.apache.commons.lang3.Validate; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; import org.apache.wayang.java.execution.JavaExecutor; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URL; @@ -33,13 +32,16 @@ import java.util.Set; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link JavaObjectFileSource}. */ -public class JavaObjectFileSourceTest extends JavaExecutionOperatorTestBase { +class JavaObjectFileSourceTest extends JavaExecutionOperatorTestBase { @Test - public void testReading() throws IOException { + void testReading() throws IOException { JavaExecutor javaExecutor = null; try { // Prepare the source. @@ -59,9 +61,9 @@ public void testReading() throws IOException { final List result = outputs[0].provideStream() .collect(Collectors.toList()); for (Object value : result) { - Assert.assertTrue("Value: " + value, expectedValues.remove(value)); + assertTrue(expectedValues.remove(value), "Value: " + value); } - Assert.assertEquals(0, expectedValues.size()); + assertEquals(0, expectedValues.size()); } finally { if (javaExecutor != null) javaExecutor.dispose(); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaRandomSampleOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaRandomSampleOperatorTest.java index d8e9cd0f0..1589454ed 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaRandomSampleOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaRandomSampleOperatorTest.java @@ -18,10 +18,9 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; @@ -29,13 +28,15 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaRandomSampleOperator}. */ -public class JavaRandomSampleOperatorTest extends JavaExecutionOperatorTestBase { +class JavaRandomSampleOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Collection inputCollection = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); final int sampleSize = 3; @@ -56,12 +57,12 @@ public void testExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(sampleSize, result.size()); + assertEquals(sampleSize, result.size()); } @Test - public void testUDFExecution() { + void testUDFExecution() { // Prepare test data. Stream inputStream = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); @@ -82,12 +83,12 @@ public void testUDFExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(2, result.size()); + assertEquals(2, result.size()); } @Test - public void testLargerSampleExecution() { + void testLargerSampleExecution() { // Prepare test data. Stream inputStream = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); @@ -108,7 +109,7 @@ public void testLargerSampleExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(10, result.size()); + assertEquals(10, result.size()); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaReduceByOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaReduceByOperatorTest.java index 225f397a2..1ce7deee0 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaReduceByOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaReduceByOperatorTest.java @@ -18,27 +18,29 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.core.function.ReduceDescriptor; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link JavaReduceByOperator}. */ -public class JavaReduceByOperatorTest extends JavaExecutionOperatorTestBase { +class JavaReduceByOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream> inputStream = Arrays.stream("aaabbccccdeefff".split("")) .map(string -> new Tuple2<>(string, 1)); @@ -77,8 +79,8 @@ public void testExecution() { new Tuple2<>("f", 3) }; Arrays.stream(expectedResults) - .forEach(expected -> Assert.assertTrue("Not contained: " + expected, result.contains(expected))); - Assert.assertEquals(expectedResults.length, result.size()); + .forEach(expected -> assertTrue(result.contains(expected), "Not contained: " + expected)); + assertEquals(expectedResults.length, result.size()); } } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaReservoirSampleOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaReservoirSampleOperatorTest.java index 66d56a584..79f93271b 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaReservoirSampleOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaReservoirSampleOperatorTest.java @@ -18,22 +18,23 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaReservoirSampleOperator}. */ -public class JavaReservoirSampleOperatorTest extends JavaExecutionOperatorTestBase { +class JavaReservoirSampleOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream inputStream = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); final int sampleSize = 5; @@ -55,11 +56,11 @@ public void testExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(sampleSize, result.size()); + assertEquals(sampleSize, result.size()); } @Test - public void testLargerSampleExecution() { + void testLargerSampleExecution() { // Prepare test data. Stream inputStream = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); @@ -80,7 +81,7 @@ public void testLargerSampleExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(10, result.size()); + assertEquals(10, result.size()); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaSortOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaSortOperatorTest.java index 3483ab56e..d5dda3b08 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaSortOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaSortOperatorTest.java @@ -18,24 +18,25 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.function.TransformationDescriptor; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaSortOperator}. */ -public class JavaSortOperatorTest extends JavaExecutionOperatorTestBase { +class JavaSortOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream inputStream = Arrays.asList(6, 0, 1, 1, 5, 2).stream(); @@ -54,8 +55,8 @@ public void testExecution() { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(Arrays.asList(0, 1, 1, 2, 5, 6), result); + assertEquals(6, result.size()); + assertEquals(Arrays.asList(0, 1, 1, 2, 5, 6), result); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSinkTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSinkTest.java index d56d24165..5450ad503 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSinkTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSinkTest.java @@ -18,10 +18,6 @@ package org.apache.wayang.java.operators; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.function.TransformationDescriptor; @@ -32,6 +28,9 @@ import org.apache.wayang.java.channels.StreamChannel; import org.apache.wayang.java.execution.JavaExecutor; import org.apache.wayang.java.platform.JavaPlatform; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -39,14 +38,13 @@ import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; -import java.text.DecimalFormatSymbols; -import java.text.NumberFormat; import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -56,7 +54,7 @@ /** * Test suite for {@link JavaTextFileSink}. */ -public class JavaTextFileSinkTest extends JavaExecutionOperatorTestBase { +class JavaTextFileSinkTest extends JavaExecutionOperatorTestBase { private static final Logger logger = LoggerFactory.getLogger(JavaTextFileSinkTest.class); @@ -67,20 +65,20 @@ public class JavaTextFileSinkTest extends JavaExecutionOperatorTestBase { * Therefore we ensure it's run in a pre-defined locale and we make sure it's * reset after the test. */ - @Before - public void setupTest() { + @BeforeEach + void setupTest() { defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.US); } - @After - public void teardownTest() { + @AfterEach + void teardownTest() { Locale.setDefault(defaultLocale); } @Test - public void testWritingLocalFile() throws IOException, URISyntaxException { + void testWritingLocalFile() throws IOException, URISyntaxException { Configuration configuration = new Configuration(); final File tempDir = LocalFileSystem.findTempDir(); @@ -105,7 +103,7 @@ public void testWritingLocalFile() throws IOException, URISyntaxException { final List lines = Files.lines(Paths.get(new URI(targetUrl))).collect(Collectors.toList()); - Assert.assertEquals( + assertEquals( Arrays.asList("1.12", "-0.10", "3.00"), lines ); diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSourceTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSourceTest.java index 7dacdb6b4..8204b4667 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSourceTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSourceTest.java @@ -18,42 +18,25 @@ package org.apache.wayang.java.operators; -import org.apache.wayang.core.api.Configuration; -import org.apache.wayang.core.api.Job; -import org.apache.wayang.core.function.TransformationDescriptor; -import org.apache.wayang.core.optimizer.OptimizationContext; -import org.apache.wayang.core.plan.wayangplan.OutputSlot; -import org.apache.wayang.core.platform.ChannelInstance; -import org.apache.wayang.core.types.DataSetType; -import org.apache.wayang.core.util.fs.LocalFileSystem; import org.apache.wayang.java.channels.JavaChannelInstance; -import org.apache.wayang.java.channels.StreamChannel; import org.apache.wayang.java.execution.JavaExecutor; -import org.apache.wayang.java.platform.JavaPlatform; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.Ignore; - -import java.io.File; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + import java.io.IOException; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test suite for {@link JavaTextFileSource}. */ -public class JavaTextFileSourceTest extends JavaExecutionOperatorTestBase { +class JavaTextFileSourceTest extends JavaExecutionOperatorTestBase { private Locale defaultLocale; @@ -62,19 +45,19 @@ public class JavaTextFileSourceTest extends JavaExecutionOperatorTestBase { * Therefore we ensure it's run in a pre-defined locale and we make sure it's * reset after the test. */ - @Before - public void setupTest() { + @BeforeEach + void setupTest() { defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.US); } - @After - public void teardownTest() { + @AfterEach + void teardownTest() { Locale.setDefault(defaultLocale); } @Test - public void testReadLocalFile() throws IOException, URISyntaxException { + void testReadLocalFile() throws IOException, URISyntaxException { final String testFileName = "/banking-tx-small.csv"; JavaExecutor javaExecutor = null; @@ -92,20 +75,21 @@ public void testReadLocalFile() throws IOException, URISyntaxException { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(63, result.size()); + assertEquals(63, result.size()); } finally { if (javaExecutor != null) javaExecutor.dispose(); } } - @Ignore /** * Requires a local HTTP Server running, in the project root ... * * With Python 3: python -m http.server * With Python 2: python -m SimpleHTTPServer */ - public void testReadRemoteFileHTTP() throws IOException, URISyntaxException { + @Disabled + @Test + void testReadRemoteFileHTTP() throws IOException, URISyntaxException { final String testFileURL = "http://localhost:8000/LICENSE"; JavaExecutor javaExecutor = null; @@ -123,14 +107,15 @@ public void testReadRemoteFileHTTP() throws IOException, URISyntaxException { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(225, result.size()); + assertEquals(225, result.size()); } finally { if (javaExecutor != null) javaExecutor.dispose(); } } - @Ignore - public void testReadRemoteFileHTTPS() throws IOException, URISyntaxException { + @Disabled + @Test + void testReadRemoteFileHTTPS() throws IOException, URISyntaxException { final String testFileURL = "https://kamir.solidcommunity.net/public/ecolytiq-sustainability-profile/profile2.ttl"; JavaExecutor javaExecutor = null; @@ -148,7 +133,7 @@ public void testReadRemoteFileHTTPS() throws IOException, URISyntaxException { // Verify the outcome. final List result = outputs[0].provideStream().collect(Collectors.toList()); - Assert.assertEquals(23, result.size()); + assertEquals(23, result.size()); } finally { if (javaExecutor != null) javaExecutor.dispose(); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaUnionAllOperatorTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaUnionAllOperatorTest.java index 7f61545f7..a3dcce312 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaUnionAllOperatorTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaUnionAllOperatorTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.java.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaUnionAllOperator}. */ -public class JavaUnionAllOperatorTest extends JavaExecutionOperatorTestBase { +class JavaUnionAllOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Stream inputStream0 = Arrays.asList(6, 0, 1, 1, 5, 2).stream(); Stream inputStream1 = Arrays.asList(1, 1, 9).stream(); @@ -54,8 +55,8 @@ public void testExecution() { // Verify the outcome. final List result = outputs[0].provideStream() .collect(Collectors.toList()); - Assert.assertEquals(9, result.size()); - Assert.assertEquals(Arrays.asList(6, 0, 1, 1, 5, 2, 1, 1, 9), result); + assertEquals(9, result.size()); + assertEquals(Arrays.asList(6, 0, 1, 1, 5, 2, 1, 1, 9), result); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/test/ChannelFactory.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/test/ChannelFactory.java index 87ee27810..b8d36d3fc 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/test/ChannelFactory.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/test/ChannelFactory.java @@ -18,12 +18,12 @@ package org.apache.wayang.java.test; -import org.junit.Before; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.plan.executionplan.Channel; import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.java.channels.StreamChannel; import org.apache.wayang.java.execution.JavaExecutor; +import org.junit.jupiter.api.BeforeEach; import java.util.Collection; import java.util.stream.Stream; @@ -37,8 +37,8 @@ public class ChannelFactory { private static JavaExecutor executor; - @Before - public void setUp() { + @BeforeEach + void setUp() { executor = mock(JavaExecutor.class); } diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/test/KafkaClientTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/test/KafkaClientTest.java index 1bdc6b51c..deaf53f9b 100644 --- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/test/KafkaClientTest.java +++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/test/KafkaClientTest.java @@ -17,19 +17,15 @@ */ package org.apache.wayang.java.test; -import java.time.Duration; -import java.util.Arrays; import java.util.Properties; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; /** * What is this test testin? @@ -42,10 +38,11 @@ * in the main branch. * */ -public class KafkaClientTest { +class KafkaClientTest { - //@Test - public void testReadFromKafkaTopic() { + @Test + @Disabled + void testReadFromKafkaTopic() { final String topicName1 = "banking-tx-small-csv"; diff --git a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/execution/JdbcExecutorTest.java b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/execution/JdbcExecutorTest.java index 0a6e952e7..0dfd8b698 100644 --- a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/execution/JdbcExecutorTest.java +++ b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/execution/JdbcExecutorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.jdbc.execution; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; @@ -38,20 +36,22 @@ import org.apache.wayang.jdbc.test.HsqldbPlatform; import org.apache.wayang.jdbc.test.HsqldbProjectionOperator; import org.apache.wayang.jdbc.test.HsqldbTableSource; +import org.junit.jupiter.api.Test; import java.sql.SQLException; import java.util.Collections; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * Test suite for {@link JdbcExecutor}. */ -public class JdbcExecutorTest { +class JdbcExecutorTest { @Test - public void testExecuteWithPlainTableSource() throws SQLException { + void testExecuteWithPlainTableSource() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); @@ -80,14 +80,14 @@ public void testExecuteWithPlainTableSource() throws SQLException { SqlQueryChannel.Instance sqlQueryChannelInstance = (SqlQueryChannel.Instance) job.getCrossPlatformExecutor().getChannelInstance(sqlToStreamTask.getInputChannel(0)); - Assert.assertEquals( + assertEquals( "SELECT * FROM customer;", sqlQueryChannelInstance.getSqlQuery() ); } @Test - public void testExecuteWithFilter() throws SQLException { + void testExecuteWithFilter() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); @@ -129,14 +129,14 @@ public void testExecuteWithFilter() throws SQLException { SqlQueryChannel.Instance sqlQueryChannelInstance = (SqlQueryChannel.Instance) job.getCrossPlatformExecutor().getChannelInstance(sqlToStreamTask.getInputChannel(0)); - Assert.assertEquals( + assertEquals( "SELECT * FROM customer WHERE age >= 18;", sqlQueryChannelInstance.getSqlQuery() ); } @Test - public void testExecuteWithProjection() throws SQLException { + void testExecuteWithProjection() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); @@ -171,14 +171,14 @@ public void testExecuteWithProjection() throws SQLException { SqlQueryChannel.Instance sqlQueryChannelInstance = (SqlQueryChannel.Instance) job.getCrossPlatformExecutor().getChannelInstance(sqlToStreamTask.getInputChannel(0)); - Assert.assertEquals( + assertEquals( "SELECT name, age FROM customer;", sqlQueryChannelInstance.getSqlQuery() ); } @Test - public void testExecuteWithProjectionAndFilters() throws SQLException { + void testExecuteWithProjectionAndFilters() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); @@ -239,7 +239,7 @@ public void testExecuteWithProjectionAndFilters() throws SQLException { SqlQueryChannel.Instance sqlQueryChannelInstance = (SqlQueryChannel.Instance) job.getCrossPlatformExecutor().getChannelInstance(sqlToStreamTask.getInputChannel(0)); - Assert.assertEquals( + assertEquals( "SELECT name, age FROM customer WHERE age >= 18 AND name IS NOT NULL;", sqlQueryChannelInstance.getSqlQuery() ); diff --git a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcJoinOperatorTest.java b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcJoinOperatorTest.java index c997639ff..63e41fea3 100644 --- a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcJoinOperatorTest.java +++ b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcJoinOperatorTest.java @@ -18,23 +18,13 @@ package org.apache.wayang.jdbc.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; -import org.apache.wayang.core.function.PredicateDescriptor; -import org.apache.wayang.core.optimizer.OptimizationContext; import org.apache.wayang.core.plan.executionplan.ExecutionTask; import org.apache.wayang.core.plan.executionplan.ExecutionStage; import org.apache.wayang.core.plan.wayangplan.ExecutionOperator; -import org.apache.wayang.core.plan.wayangplan.OutputSlot; -import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.platform.CrossPlatformExecutor; -import org.apache.wayang.core.profiling.FullInstrumentationStrategy; -import org.apache.wayang.java.channels.StreamChannel; -import org.apache.wayang.java.execution.JavaExecutor; -import org.apache.wayang.java.platform.JavaPlatform; import org.apache.wayang.jdbc.channels.SqlQueryChannel; import org.apache.wayang.jdbc.test.HsqldbJoinOperator; import org.apache.wayang.jdbc.test.HsqldbPlatform; @@ -43,24 +33,23 @@ import org.apache.wayang.jdbc.execution.JdbcExecutor; import org.apache.wayang.core.profiling.NoInstrumentationStrategy; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; +import org.junit.jupiter.api.Test; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; import java.util.Collections; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * Test suite for {@link SqlToStreamOperator}. */ -public class JdbcJoinOperatorTest extends OperatorTestBase { +class JdbcJoinOperatorTest extends OperatorTestBase { @Test - public void testWithHsqldb() throws SQLException { + void testWithHsqldb() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); @@ -129,7 +118,7 @@ public void testWithHsqldb() throws SQLException { System.out.println(); - Assert.assertEquals( + assertEquals( "SELECT * FROM testA JOIN testA ON testB.a=testA.a;", sqlQueryChannelInstance.getSqlQuery() ); diff --git a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcTableSourceTest.java b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcTableSourceTest.java index aea6fc19c..301ac85d6 100644 --- a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcTableSourceTest.java +++ b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcTableSourceTest.java @@ -22,8 +22,6 @@ import org.apache.wayang.commons.util.profiledb.instrumentation.StopWatch; import org.apache.wayang.commons.util.profiledb.model.Experiment; import org.apache.wayang.commons.util.profiledb.model.Subject; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; @@ -31,21 +29,23 @@ import org.apache.wayang.core.optimizer.cardinality.CardinalityEstimator; import org.apache.wayang.jdbc.test.HsqldbPlatform; import org.apache.wayang.jdbc.test.HsqldbTableSource; +import org.junit.jupiter.api.Test; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * Test suite for {@link SqlToStreamOperator}. */ -public class JdbcTableSourceTest { +class JdbcTableSourceTest { @Test - public void testCardinalityEstimator() throws SQLException { + void testCardinalityEstimator() throws SQLException { Job job = mock(Job.class); DefaultOptimizationContext optimizationContext = mock(DefaultOptimizationContext.class); when(job.getOptimizationContext()).thenReturn(optimizationContext); @@ -69,7 +69,7 @@ public void testCardinalityEstimator() throws SQLException { final CardinalityEstimate estimate = cardinalityEstimator.estimate(optimizationContext); - Assert.assertEquals( + assertEquals( new CardinalityEstimate(3, 3, 1d), estimate ); diff --git a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/OperatorTestBase.java b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/OperatorTestBase.java index af62419ea..1867f5a8a 100644 --- a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/OperatorTestBase.java +++ b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/OperatorTestBase.java @@ -33,7 +33,7 @@ import org.apache.wayang.spark.execution.SparkExecutor; import org.apache.wayang.spark.operators.SparkExecutionOperator; import org.apache.wayang.spark.platform.SparkPlatform; -import org.junit.BeforeClass; +import org.junit.jupiter.api.BeforeAll; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -45,8 +45,8 @@ public class OperatorTestBase { protected static Configuration configuration; - @BeforeClass - public static void init() { + @BeforeAll + static void init() { configuration = new Configuration(); } diff --git a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/SqlToRddOperatorTest.java b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/SqlToRddOperatorTest.java index 55b34a990..1acfd426d 100644 --- a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/SqlToRddOperatorTest.java +++ b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/SqlToRddOperatorTest.java @@ -35,8 +35,7 @@ import org.apache.wayang.spark.channels.RddChannel; import org.apache.wayang.spark.execution.SparkExecutor; import org.apache.wayang.spark.platform.SparkPlatform; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.sql.Connection; import java.sql.SQLException; @@ -44,13 +43,15 @@ import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class SqlToRddOperatorTest extends OperatorTestBase { +class SqlToRddOperatorTest extends OperatorTestBase { @Test - public void testWithHsqldb() throws SQLException { + void testWithHsqldb() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); @@ -108,11 +109,11 @@ public void testWithHsqldb() throws SQLException { new Record(2, "two") ); - Assert.assertEquals(expected, output); + assertEquals(expected, output); } @Test - public void testWithEmptyHsqldb() throws SQLException { + void testWithEmptyHsqldb() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); @@ -161,7 +162,7 @@ public void testWithEmptyHsqldb() throws SQLException { ); List output = rddChannelInstance.provideRdd().collect(); - Assert.assertTrue(output.isEmpty()); + assertTrue(output.isEmpty()); } } diff --git a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/SqlToStreamOperatorTest.java b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/SqlToStreamOperatorTest.java index affd2363f..da3a96dd1 100644 --- a/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/SqlToStreamOperatorTest.java +++ b/wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/SqlToStreamOperatorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.jdbc.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; @@ -37,6 +35,7 @@ import org.apache.wayang.jdbc.channels.SqlQueryChannel; import org.apache.wayang.jdbc.test.HsqldbFilterOperator; import org.apache.wayang.jdbc.test.HsqldbPlatform; +import org.junit.jupiter.api.Test; import java.sql.Connection; import java.sql.SQLException; @@ -45,16 +44,18 @@ import java.util.List; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * Test suite for {@link SqlToStreamOperator}. */ -public class SqlToStreamOperatorTest extends OperatorTestBase { +class SqlToStreamOperatorTest extends OperatorTestBase { @Test - public void testWithHsqldb() throws SQLException { + void testWithHsqldb() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); @@ -112,11 +113,11 @@ public void testWithHsqldb() throws SQLException { new Record(2, "two") ); - Assert.assertEquals(expected, output); + assertEquals(expected, output); } @Test - public void testWithEmptyHsqldb() throws SQLException { + void testWithEmptyHsqldb() throws SQLException { Configuration configuration = new Configuration(); Job job = mock(Job.class); @@ -165,7 +166,7 @@ public void testWithEmptyHsqldb() throws SQLException { ); List output = streamChannelInstance.provideStream().collect(Collectors.toList()); - Assert.assertTrue(output.isEmpty()); + assertTrue(output.isEmpty()); } } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkBernoulliSampleOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkBernoulliSampleOperatorTest.java index 4de83a04c..9dbb04803 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkBernoulliSampleOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkBernoulliSampleOperatorTest.java @@ -18,25 +18,26 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; import org.apache.wayang.basic.operators.SampleOperator; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkBernoulliSampleOperator}. */ -public class SparkBernoulliSampleOperatorTest extends SparkOperatorTestBase { +class SparkBernoulliSampleOperatorTest extends SparkOperatorTestBase { - @Ignore("Cannot check this, because the sample size returned is not always exact.") + @Disabled("Cannot check this, because the sample size returned is not always exact.") @Test - public void testExecution() { + void testExecution() { // Prepare test data. List inputData = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); @@ -57,11 +58,11 @@ public void testExecution() { // Verify the outcome. final List result = ((RddChannel.Instance) outputs[0]).provideRdd().collect(); - Assert.assertEquals(5, result.size()); + assertEquals(5, result.size()); } @Test - public void testDoesNotFail() { + void testDoesNotFail() { // Prepare test data. List inputData = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCartesianOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCartesianOperatorTest.java index 9d6c4b2b6..e9372e87c 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCartesianOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCartesianOperatorTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkCartesianOperator}. */ -public class SparkCartesianOperatorTest extends SparkOperatorTestBase { +class SparkCartesianOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input0 = this.createRddChannelInstance(Arrays.asList(1, 2)); RddChannel.Instance input1 = this.createRddChannelInstance(Arrays.asList("a", "b", "c")); @@ -55,8 +56,8 @@ public void testExecution() { // Verify the outcome. final List> result = output.>provideRdd().collect(); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(result.get(0), new Tuple2(1, "a")); + assertEquals(6, result.size()); + assertEquals(new Tuple2(1, "a"), result.get(0)); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCoGroupOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCoGroupOperatorTest.java index 5ff68c4de..fc35e9605 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCoGroupOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCoGroupOperatorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.core.platform.ChannelInstance; @@ -28,6 +26,7 @@ import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.core.util.Tuple; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; @@ -36,13 +35,16 @@ import java.util.Iterator; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Test suite for {@link SparkJoinOperator}. */ -public class SparkCoGroupOperatorTest extends SparkOperatorTestBase { +class SparkCoGroupOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input0 = this.createRddChannelInstance(Arrays.asList( new Tuple2<>(1, "b"), new Tuple2<>(1, "c"), new Tuple2<>(2, "d"), new Tuple2<>(3, "e"))); @@ -104,11 +106,11 @@ public void testExecution() { continue ResultLoop; } } - Assert.fail(String.format("Unexpected group: %s", resultCoGroup)); + fail(String.format("Unexpected group: %s", resultCoGroup)); } - Assert.assertTrue( - String.format("Missing groups: %s", expectedGroups), - expectedGroups.isEmpty() + assertTrue( + expectedGroups.isEmpty(), + String.format("Missing groups: %s", expectedGroups) ); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCollectionSourceTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCollectionSourceTest.java index 52205cb81..5126f277a 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCollectionSourceTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCollectionSourceTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for the {@link SparkCollectionSource}. */ -public class SparkCollectionSourceTest extends SparkOperatorTestBase { +class SparkCollectionSourceTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { Set inputValues = new HashSet<>(Arrays.asList(1, 2, 3)); SparkCollectionSource collectionSource = new SparkCollectionSource<>( inputValues, @@ -49,6 +50,6 @@ public void testExecution() { this.evaluate(collectionSource, inputs, outputs); final Set outputValues = new HashSet<>(output.provideRdd().collect()); - Assert.assertEquals(outputValues, inputValues); + assertEquals(outputValues, inputValues); } } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCountOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCountOperatorTest.java index 9d1317c94..239a394fb 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCountOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkCountOperatorTest.java @@ -18,24 +18,25 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkCountOperator}. */ -public class SparkCountOperatorTest extends SparkOperatorTestBase { +class SparkCountOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(1, 2, 3, 4, 5)); CollectionChannel.Instance output = this.createCollectionChannelInstance(); @@ -53,8 +54,8 @@ public void testExecution() { // Verify the outcome. final Collection result = output.provideCollection(); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(Long.valueOf(5), result.iterator().next()); + assertEquals(1, result.size()); + assertEquals(Long.valueOf(5), result.iterator().next()); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkDecisionTreeClassificationOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkDecisionTreeClassificationOperatorTest.java index 849bdbdae..bc74759bb 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkDecisionTreeClassificationOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkDecisionTreeClassificationOperatorTest.java @@ -25,13 +25,14 @@ import org.apache.wayang.spark.channels.RddChannel; import org.apache.wayang.spark.operators.ml.SparkDecisionTreeClassificationOperator; import org.apache.wayang.spark.operators.ml.SparkPredictOperator; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class SparkDecisionTreeClassificationOperatorTest extends SparkOperatorTestBase { public static List trainingX = Arrays.asList( @@ -73,13 +74,13 @@ public DecisionTreeClassificationModel getModel() { } @Test - public void testTraining() { + void testTraining() { final DecisionTreeClassificationModel model = getModel(); - Assert.assertEquals(model.getDepth(), 2); + assertEquals(2, model.getDepth()); } @Test - public void testInference() { + void testInference() { // Prepare test data. CollectionChannel.Instance input1 = this.createCollectionChannelInstance(Collections.singletonList(getModel())); RddChannel.Instance input2 = this.createRddChannelInstance(inferenceData); @@ -96,9 +97,9 @@ public void testInference() { // Verify the outcome. final List results = output.provideRdd().collect(); - Assert.assertEquals(3, results.size()); - Assert.assertEquals(0, results.get(0).intValue()); - Assert.assertEquals(1, results.get(1).intValue()); - Assert.assertEquals(2, results.get(2).intValue()); + assertEquals(3, results.size()); + assertEquals(0, results.get(0).intValue()); + assertEquals(1, results.get(1).intValue()); + assertEquals(2, results.get(2).intValue()); } } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkDistinctOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkDistinctOperatorTest.java index 157490a55..c3599fc49 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkDistinctOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkDistinctOperatorTest.java @@ -18,22 +18,23 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkDistinctOperator}. */ -public class SparkDistinctOperatorTest extends SparkOperatorTestBase { +class SparkDistinctOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. List inputData = Arrays.asList(0, 1, 1, 6, 2, 2, 6, 6); @@ -52,8 +53,8 @@ public void testExecution() { // Verify the outcome. final List result = ((RddChannel.Instance) outputs[0]).provideRdd().collect(); - Assert.assertEquals(4, result.size()); - Assert.assertEquals(Arrays.asList(0, 1, 6, 2), result); + assertEquals(4, result.size()); + assertEquals(Arrays.asList(0, 1, 6, 2), result); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkFilterOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkFilterOperatorTest.java index 8aacc543a..6b7e45a5b 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkFilterOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkFilterOperatorTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.function.PredicateDescriptor; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkFilterOperator}. */ -public class SparkFilterOperatorTest extends SparkOperatorTestBase { +class SparkFilterOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(0, 1, 1, 2, 6)); RddChannel.Instance output = this.createRddChannelInstance(); @@ -55,8 +56,8 @@ public void testExecution() { // Verify the outcome. final List result = output.provideRdd().collect(); - Assert.assertEquals(4, result.size()); - Assert.assertEquals(Arrays.asList(1, 1, 2, 6), result); + assertEquals(4, result.size()); + assertEquals(Arrays.asList(1, 1, 2, 6), result); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkFlatMapOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkFlatMapOperatorTest.java index 246a24f57..f38a868f6 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkFlatMapOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkFlatMapOperatorTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.function.FlatMapDescriptor; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkFilterOperator}. */ -public class SparkFlatMapOperatorTest extends SparkOperatorTestBase { +class SparkFlatMapOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList("one phrase", "two sentences", "three lines")); RddChannel.Instance output = this.createRddChannelInstance(); @@ -54,8 +55,8 @@ public void testExecution() { // Verify the outcome. final List result = output.provideRdd().collect(); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(Arrays.asList("one", "phrase", "two", "sentences", "three", "lines"), result); + assertEquals(6, result.size()); + assertEquals(Arrays.asList("one", "phrase", "two", "sentences", "three", "lines"), result); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkGlobalMaterializedGroupOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkGlobalMaterializedGroupOperatorTest.java index 4cfcbbdf7..b2481d7f4 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkGlobalMaterializedGroupOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkGlobalMaterializedGroupOperatorTest.java @@ -18,24 +18,26 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + /** * Test suite for {@link SparkGlobalMaterializedGroupOperator}. */ -public class SparkGlobalMaterializedGroupOperatorTest extends SparkOperatorTestBase { +class SparkGlobalMaterializedGroupOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. Collection inputCollection = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); @@ -53,13 +55,13 @@ public void testExecution() { // Verify the outcome. final Collection> result = ((RddChannel.Instance) outputs[0]).>provideRdd().collect(); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(inputCollection, result.iterator().next()); + assertEquals(1, result.size()); + assertEquals(inputCollection, result.iterator().next()); } @Test - public void testExecutionWithoutData() { + void testExecutionWithoutData() { // Prepare test data. Collection inputCollection = Collections.emptyList(); @@ -77,7 +79,7 @@ public void testExecutionWithoutData() { // Verify the outcome. final Collection> result = ((RddChannel.Instance) outputs[0]).>provideRdd().collect(); - Assert.assertEquals(1, result.size()); - Assert.assertFalse(WayangCollections.getSingle(result).iterator().hasNext()); + assertEquals(1, result.size()); + assertFalse(WayangCollections.getSingle(result).iterator().hasNext()); } } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkGlobalReduceOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkGlobalReduceOperatorTest.java index 9f0e72e28..232c982de 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkGlobalReduceOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkGlobalReduceOperatorTest.java @@ -18,9 +18,6 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.function.ReduceDescriptor; import org.apache.wayang.core.platform.ChannelInstance; @@ -29,18 +26,22 @@ import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkGlobalReduceOperator}. */ -public class SparkGlobalReduceOperatorTest extends SparkOperatorTestBase { +class SparkGlobalReduceOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); CollectionChannel.Instance output = this.createCollectionChannelInstance(); @@ -64,14 +65,14 @@ public void testExecution() { // Verify the outcome. final List result = WayangCollections.asList(output.provideCollection()); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(Integer.valueOf((10 + 1) * (10 / 2)), result.get(0)); // Props to Gauss! + assertEquals(1, result.size()); + assertEquals(Integer.valueOf((10 + 1) * (10 / 2)), result.get(0)); // Props to Gauss! } - @Ignore("Spark cannot reduce empty collections.") + @Disabled("Spark cannot reduce empty collections.") @Test - public void testExecutionWithoutData() { + void testExecutionWithoutData() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Collections.emptyList()); CollectionChannel.Instance output = this.createCollectionChannelInstance(); @@ -95,8 +96,8 @@ public void testExecutionWithoutData() { // Verify the outcome. final List result = WayangCollections.asList(output.provideCollection()); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(Integer.valueOf(0), result.get(0)); + assertEquals(1, result.size()); + assertEquals(Integer.valueOf(0), result.get(0)); } } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkJoinOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkJoinOperatorTest.java index ab651502a..99fbd2bf9 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkJoinOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkJoinOperatorTest.java @@ -18,25 +18,26 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkJoinOperator}. */ -public class SparkJoinOperatorTest extends SparkOperatorTestBase { +class SparkJoinOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input0 = this.createRddChannelInstance(Arrays.asList( new Tuple2<>(1, "b"), new Tuple2<>(1, "c"), new Tuple2<>(2, "d"), new Tuple2<>(3, "e"))); @@ -68,12 +69,12 @@ public void testExecution() { // Verify the outcome. final List, Tuple2>> result = output., Tuple2>>provideRdd().collect(); - Assert.assertEquals(5, result.size()); - Assert.assertEquals(result.get(0), new Tuple2<>(new Tuple2<>(1, "b"), new Tuple2<>("x", 1))); - Assert.assertEquals(result.get(1), new Tuple2<>(new Tuple2<>(1, "b"), new Tuple2<>("y", 1))); - Assert.assertEquals(result.get(2), new Tuple2<>(new Tuple2<>(1, "c"), new Tuple2<>("x", 1))); - Assert.assertEquals(result.get(3), new Tuple2<>(new Tuple2<>(1, "c"), new Tuple2<>("y", 1))); - Assert.assertEquals(result.get(4), new Tuple2<>(new Tuple2<>(2, "d"), new Tuple2<>("z", 2))); + assertEquals(5, result.size()); + assertEquals(new Tuple2<>(new Tuple2<>(1, "b"), new Tuple2<>("x", 1)), result.get(0)); + assertEquals(new Tuple2<>(new Tuple2<>(1, "b"), new Tuple2<>("y", 1)), result.get(1)); + assertEquals(new Tuple2<>(new Tuple2<>(1, "c"), new Tuple2<>("x", 1)), result.get(2)); + assertEquals(new Tuple2<>(new Tuple2<>(1, "c"), new Tuple2<>("y", 1)), result.get(3)); + assertEquals(new Tuple2<>(new Tuple2<>(2, "d"), new Tuple2<>("z", 2)), result.get(4)); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkKMeansOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkKMeansOperatorTest.java index d0b516cf7..f298f3121 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkKMeansOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkKMeansOperatorTest.java @@ -25,8 +25,7 @@ import org.apache.wayang.spark.channels.RddChannel; import org.apache.wayang.spark.operators.ml.SparkKMeansOperator; import org.apache.wayang.spark.operators.ml.SparkPredictOperator; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; @@ -34,6 +33,9 @@ import java.util.List; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class SparkKMeansOperatorTest extends SparkOperatorTestBase { public static List data = Arrays.asList( @@ -61,18 +63,18 @@ public KMeansModel getModel() { } @Test - public void testTraining() { + void testTraining() { final KMeansModel model = getModel(); - Assert.assertEquals(2, model.getK()); + assertEquals(2, model.getK()); List centers = Arrays.stream(model.getClusterCenters()) .sorted(Comparator.comparingDouble(a -> a[0])) .collect(Collectors.toList()); - Assert.assertArrayEquals(centers.get(0), new double[]{-1.0, -2.0, -3.0}, 0.1); - Assert.assertArrayEquals(centers.get(1), new double[]{1.5, 3.0, 4.5}, 0.1); + assertArrayEquals(new double[]{-1.0, -2.0, -3.0}, centers.get(0), 0.1); + assertArrayEquals(new double[]{1.5, 3.0, 4.5}, centers.get(1), 0.1); } @Test - public void testInference() { + void testInference() { // Prepare test data. CollectionChannel.Instance input1 = this.createCollectionChannelInstance(Collections.singletonList(getModel())); RddChannel.Instance input2 = this.createRddChannelInstance(data); @@ -89,8 +91,8 @@ public void testInference() { // Verify the outcome. final List results = output.provideRdd().collect(); - Assert.assertEquals(3, results.size()); - Assert.assertEquals( + assertEquals(3, results.size()); + assertEquals( results.get(0), results.get(2) ); diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkLinearRegressionOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkLinearRegressionOperatorTest.java index b11e7ef9e..ade451714 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkLinearRegressionOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkLinearRegressionOperatorTest.java @@ -25,13 +25,15 @@ import org.apache.wayang.spark.channels.RddChannel; import org.apache.wayang.spark.operators.ml.SparkLinearRegressionOperator; import org.apache.wayang.spark.operators.ml.SparkPredictOperator; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class SparkLinearRegressionOperatorTest extends SparkOperatorTestBase { // y = x1 + x2 + 1 @@ -70,14 +72,14 @@ public LinearRegressionModel getModel() { } @Test - public void testTraining() { + void testTraining() { final LinearRegressionModel model = getModel(); - Assert.assertArrayEquals(new double[]{1, 1}, model.getCoefficients(), 1e-6); - Assert.assertEquals(1, model.getIntercept(), 1e-6); + assertArrayEquals(new double[]{1, 1}, model.getCoefficients(), 1e-6); + assertEquals(1, model.getIntercept(), 1e-6); } @Test - public void testInference() { + void testInference() { // Prepare test data. CollectionChannel.Instance input1 = this.createCollectionChannelInstance(Collections.singletonList(getModel())); RddChannel.Instance input2 = this.createRddChannelInstance(inferenceData); @@ -94,8 +96,8 @@ public void testInference() { // Verify the outcome. final List results = output.provideRdd().collect(); - Assert.assertEquals(2, results.size()); - Assert.assertEquals(4, results.get(0), 1e-6); - Assert.assertEquals(0, results.get(1), 1e-6); + assertEquals(2, results.size()); + assertEquals(4, results.get(0), 1e-6); + assertEquals(0, results.get(1), 1e-6); } } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkMapPartitionsOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkMapPartitionsOperatorTest.java index dee490c30..bbb16b735 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkMapPartitionsOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkMapPartitionsOperatorTest.java @@ -18,24 +18,25 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.function.MapPartitionsDescriptor; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; import java.util.LinkedList; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkFilterOperator}. */ -public class SparkMapPartitionsOperatorTest extends SparkOperatorTestBase { +class SparkMapPartitionsOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(0, 1, 1, 2, 6)); RddChannel.Instance output = this.createRddChannelInstance(); @@ -61,8 +62,8 @@ public void testExecution() { // Verify the outcome. final List result = output.provideRdd().collect(); - Assert.assertEquals(5, result.size()); - Assert.assertEquals(Arrays.asList(1, 2, 2, 3, 7), result); + assertEquals(5, result.size()); + assertEquals(Arrays.asList(1, 2, 2, 3, 7), result); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkMaterializedGroupByOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkMaterializedGroupByOperatorTest.java index 8886cb74a..5a2a3ceb4 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkMaterializedGroupByOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkMaterializedGroupByOperatorTest.java @@ -18,14 +18,13 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -34,14 +33,17 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link SparkMaterializedGroupByOperator}. */ -public class SparkMaterializedGroupByOperatorTest extends SparkOperatorTestBase { +class SparkMaterializedGroupByOperatorTest extends SparkOperatorTestBase { @Test @SuppressWarnings("unchecked") - public void testExecution() { + void testExecution() { // Prepare test data. AtomicInteger counter = new AtomicInteger(0); RddChannel.Instance input = this.createRddChannelInstance(Arrays.stream("abcaba".split("")) @@ -80,8 +82,8 @@ public void testExecution() { Arrays.asList(new Tuple2<>("c", 2)) }; Arrays.stream(expectedResults) - .forEach(expected -> Assert.assertTrue("Not contained: " + expected, result.contains(expected))); - Assert.assertEquals(expectedResults.length, result.size()); + .forEach(expected -> assertTrue(result.contains(expected), "Not contained: " + expected)); + assertEquals(expectedResults.length, result.size()); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkObjectFileSinkTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkObjectFileSinkTest.java index c9a8e2ff7..ad180d81e 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkObjectFileSinkTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkObjectFileSinkTest.java @@ -19,12 +19,12 @@ package org.apache.wayang.spark.operators; import org.apache.commons.lang3.Validate; -import org.junit.Test; import org.apache.wayang.basic.channels.FileChannel; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; import org.apache.wayang.spark.execution.SparkExecutor; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.Files; @@ -35,12 +35,12 @@ /** * Test suite for {@link SparkObjectFileSink}. */ -public class SparkObjectFileSinkTest extends SparkOperatorTestBase { +class SparkObjectFileSinkTest extends SparkOperatorTestBase { // If this test fails, make sure you have Hadoop installed and it's HADOOP_HOME is set. // Also, if on Windows: Make sure you installed the winutils binaries (https://github.com/cdarlint/winutils) @Test - public void testWritingDoesNotFail() throws IOException { + void testWritingDoesNotFail() throws IOException { SparkExecutor sparkExecutor = null; try { diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkObjectFileSourceTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkObjectFileSourceTest.java index 20b7dbab1..55c66d811 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkObjectFileSourceTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkObjectFileSourceTest.java @@ -19,12 +19,11 @@ package org.apache.wayang.spark.operators; import org.apache.commons.lang3.Validate; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; import org.apache.wayang.spark.execution.SparkExecutor; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URL; @@ -33,13 +32,16 @@ import java.util.List; import java.util.Set; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link SparkObjectFileSource}. */ -public class SparkObjectFileSourceTest extends SparkOperatorTestBase { +class SparkObjectFileSourceTest extends SparkOperatorTestBase { @Test - public void testWritingDoesNotFail() throws IOException { + void testWritingDoesNotFail() throws IOException { SparkExecutor sparkExecutor = null; try { @@ -60,9 +62,9 @@ public void testWritingDoesNotFail() throws IOException { Set expectedValues = new HashSet<>(SparkObjectFileSourceTest.enumerateRange(10000)); final List rddList = output.provideRdd().collect(); for (Integer rddValue : rddList) { - Assert.assertTrue("Value: " + rddValue, expectedValues.remove(rddValue)); + assertTrue(expectedValues.remove(rddValue), "Value: " + rddValue); } - Assert.assertEquals(0, expectedValues.size()); + assertEquals(0, expectedValues.size()); } finally { if (sparkExecutor != null) sparkExecutor.dispose(); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkOperatorTestBase.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkOperatorTestBase.java index 7265ccc05..222954da9 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkOperatorTestBase.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkOperatorTestBase.java @@ -19,7 +19,6 @@ package org.apache.wayang.spark.operators; import org.apache.spark.api.java.JavaSparkContext; -import org.junit.Before; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; @@ -33,6 +32,7 @@ import org.apache.wayang.spark.execution.SparkExecutor; import org.apache.wayang.spark.platform.SparkPlatform; import org.apache.wayang.spark.test.ChannelFactory; +import org.junit.jupiter.api.BeforeEach; import java.util.Collection; @@ -42,14 +42,14 @@ /** * Test base for {@link SparkExecutionOperator} tests. */ -public class SparkOperatorTestBase { +class SparkOperatorTestBase { protected Configuration configuration; protected SparkExecutor sparkExecutor; - @Before - public void setUp() { + @BeforeEach + void setUp() { this.configuration = new Configuration(); if(sparkExecutor == null) this.sparkExecutor = (SparkExecutor) SparkPlatform.getInstance().getExecutorFactory().create(this.mockJob()); diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkRandomPartitionSampleOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkRandomPartitionSampleOperatorTest.java index 8e4da0557..abe69df26 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkRandomPartitionSampleOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkRandomPartitionSampleOperatorTest.java @@ -18,24 +18,25 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkRandomPartitionSampleOperator}. */ -public class SparkRandomPartitionSampleOperatorTest extends SparkOperatorTestBase { +class SparkRandomPartitionSampleOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. final int sampleSize = 3; RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); @@ -58,12 +59,12 @@ public void testExecution() { // Verify the outcome. final List result = WayangCollections.asList(output.provideCollection()); - Assert.assertEquals(sampleSize, result.size()); + assertEquals(sampleSize, result.size()); } @Test - public void testUDFExecution() { + void testUDFExecution() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); CollectionChannel.Instance output = this.createCollectionChannelInstance(); @@ -87,7 +88,7 @@ public void testUDFExecution() { // Verify the outcome. final List result = WayangCollections.asList(output.provideCollection()); System.out.println(result); - Assert.assertEquals(2, result.size()); + assertEquals(2, result.size()); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkReduceByOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkReduceByOperatorTest.java index ff97e7d9e..d523a02b7 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkReduceByOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkReduceByOperatorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.function.ProjectionDescriptor; import org.apache.wayang.core.function.ReduceDescriptor; @@ -27,6 +25,7 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.HashSet; @@ -34,13 +33,16 @@ import java.util.Set; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test suite for {@link SparkReduceByOperator}. */ -public class SparkReduceByOperatorTest extends SparkOperatorTestBase { +class SparkReduceByOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. List> inputList = Arrays.stream("aaabbccccdeefff".split("")) .map(string -> new Tuple2<>(string, 1)) @@ -85,8 +87,8 @@ public void testExecution() { new Tuple2<>("f", 3) }; Arrays.stream(expectedResults) - .forEach(expected -> Assert.assertTrue("Not contained: " + expected, resultSet.contains(expected))); - Assert.assertEquals(expectedResults.length, resultSet.size()); + .forEach(expected -> assertTrue(resultSet.contains(expected), "Not contained: " + expected)); + assertEquals(expectedResults.length, resultSet.size()); } } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkShufflePartitionSampleOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkShufflePartitionSampleOperatorTest.java index ee0ec5270..811043f65 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkShufflePartitionSampleOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkShufflePartitionSampleOperatorTest.java @@ -18,24 +18,25 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkShufflePartitionSampleOperator}. */ -public class SparkShufflePartitionSampleOperatorTest extends SparkOperatorTestBase { +class SparkShufflePartitionSampleOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); CollectionChannel.Instance output = this.createCollectionChannelInstance(); @@ -60,12 +61,12 @@ public void testExecution() { // Verify the outcome. final List result = WayangCollections.asList(output.provideCollection()); System.out.println(result); - Assert.assertEquals(sampleSize, result.size()); + assertEquals(sampleSize, result.size()); } @Test - public void testExecutionWithUnknownDatasetSize() { + void testExecutionWithUnknownDatasetSize() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); CollectionChannel.Instance output = this.createCollectionChannelInstance(); @@ -88,7 +89,7 @@ public void testExecutionWithUnknownDatasetSize() { // Verify the outcome. final List result = WayangCollections.asList(output.provideCollection()); System.out.println(result); - Assert.assertEquals(sampleSize, result.size()); + assertEquals(sampleSize, result.size()); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkSortOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkSortOperatorTest.java index 6109fe767..9332fd6c6 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkSortOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkSortOperatorTest.java @@ -18,23 +18,24 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.function.TransformationDescriptor; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkSortOperator}. */ -public class SparkSortOperatorTest extends SparkOperatorTestBase { +class SparkSortOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input = this.createRddChannelInstance(Arrays.asList(6, 0, 1, 1, 5, 2)); RddChannel.Instance output = this.createRddChannelInstance(); @@ -56,8 +57,8 @@ public void testExecution() { // Verify the outcome. final List result = output.provideRdd().collect(); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(Arrays.asList(0, 1, 1, 2, 5, 6), result); + assertEquals(6, result.size()); + assertEquals(Arrays.asList(0, 1, 1, 2, 5, 6), result); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkTextFileSinkTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkTextFileSinkTest.java index 57523ba9d..98a3319cd 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkTextFileSinkTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkTextFileSinkTest.java @@ -18,10 +18,10 @@ package org.apache.wayang.spark.operators; -import org.junit.Test; import org.apache.wayang.core.function.TransformationDescriptor; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.Files; @@ -31,10 +31,10 @@ /** * Test suite for {@link SparkTextFileSink}. */ -public class SparkTextFileSinkTest extends SparkOperatorTestBase { +class SparkTextFileSinkTest extends SparkOperatorTestBase { @Test - public void testWritingDoesNotFail() throws IOException { + void testWritingDoesNotFail() throws IOException { // Prepare the sink. Path tempDir = Files.createTempDirectory("wayang-spark"); tempDir.toFile().deleteOnExit(); diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkUnionAllOperatorTest.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkUnionAllOperatorTest.java index d94059b86..0d8b6a7a1 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkUnionAllOperatorTest.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/operators/SparkUnionAllOperatorTest.java @@ -18,22 +18,23 @@ package org.apache.wayang.spark.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.core.platform.ChannelInstance; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkUnionAllOperator}. */ -public class SparkUnionAllOperatorTest extends SparkOperatorTestBase { +class SparkUnionAllOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { // Prepare test data. RddChannel.Instance input0 = this.createRddChannelInstance(Arrays.asList(6, 0, 1, 1, 5, 2)); RddChannel.Instance input1 = this.createRddChannelInstance(Arrays.asList(1, 1, 9)); @@ -55,8 +56,8 @@ public void testExecution() { // Verify the outcome. final List result = output.provideRdd().collect(); - Assert.assertEquals(9, result.size()); - Assert.assertEquals(Arrays.asList(6, 0, 1, 1, 5, 2, 1, 1, 9), result); + assertEquals(9, result.size()); + assertEquals(Arrays.asList(6, 0, 1, 1, 5, 2, 1, 1, 9), result); } diff --git a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/test/ChannelFactory.java b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/test/ChannelFactory.java index e83c44fc5..3c430d116 100644 --- a/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/test/ChannelFactory.java +++ b/wayang-platforms/wayang-spark/src/test/java/org/apache/wayang/spark/test/ChannelFactory.java @@ -18,7 +18,6 @@ package org.apache.wayang.spark.test; -import org.junit.Before; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.plan.executionplan.Channel; import org.apache.wayang.core.platform.ChannelDescriptor; @@ -26,6 +25,7 @@ import org.apache.wayang.java.channels.CollectionChannel; import org.apache.wayang.spark.channels.RddChannel; import org.apache.wayang.spark.execution.SparkExecutor; +import org.junit.jupiter.api.BeforeEach; import java.util.Collection; @@ -38,8 +38,8 @@ public class ChannelFactory { private static SparkExecutor sparkExecutor; - @Before - public void setUp() { + @BeforeEach + void setUp() { sparkExecutor = mock(SparkExecutor.class); } diff --git a/wayang-platforms/wayang-tensorflow/src/test/java/org/apache/wayang/tensorflow/model/TensorflowModelTest.java b/wayang-platforms/wayang-tensorflow/src/test/java/org/apache/wayang/tensorflow/model/TensorflowModelTest.java index 41c583956..d3b225fdb 100644 --- a/wayang-platforms/wayang-tensorflow/src/test/java/org/apache/wayang/tensorflow/model/TensorflowModelTest.java +++ b/wayang-platforms/wayang-tensorflow/src/test/java/org/apache/wayang/tensorflow/model/TensorflowModelTest.java @@ -25,8 +25,7 @@ import org.apache.wayang.basic.model.op.nn.Sigmoid; import org.apache.wayang.basic.model.optimizer.GradientDescent; import org.apache.wayang.basic.model.optimizer.Optimizer; -import org.junit.Test; -import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.tensorflow.ndarray.FloatNdArray; import org.tensorflow.ndarray.IntNdArray; import org.tensorflow.ndarray.NdArrays; @@ -34,9 +33,10 @@ import org.tensorflow.op.Ops; import org.tensorflow.types.TFloat32; import org.tensorflow.types.TInt32; -public class TensorflowModelTest { + +class TensorflowModelTest { @Test - public void test() { + void test() { FloatNdArray x = NdArrays.ofFloats(Shape.of(6, 4)) .set(NdArrays.vectorOf(5.1f, 3.5f, 1.4f, 0.2f), 0) .set(NdArrays.vectorOf(4.9f, 3.0f, 1.4f, 0.2f), 1) diff --git a/wayang-platforms/wayang-tensorflow/src/test/java/org/apache/wayang/tensorflow/operators/TensorflowOperatorTestBase.java b/wayang-platforms/wayang-tensorflow/src/test/java/org/apache/wayang/tensorflow/operators/TensorflowOperatorTestBase.java index 2bba4d606..c7aac2d6f 100644 --- a/wayang-platforms/wayang-tensorflow/src/test/java/org/apache/wayang/tensorflow/operators/TensorflowOperatorTestBase.java +++ b/wayang-platforms/wayang-tensorflow/src/test/java/org/apache/wayang/tensorflow/operators/TensorflowOperatorTestBase.java @@ -30,7 +30,7 @@ import org.apache.wayang.tensorflow.channels.TensorChannel; import org.apache.wayang.tensorflow.execution.TensorflowExecutor; import org.apache.wayang.tensorflow.platform.TensorflowPlatform; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.tensorflow.ndarray.NdArray; import java.util.Collection; @@ -41,13 +41,13 @@ /** * Test base for {@link TensorflowExecutionOperator} tests. */ -public class TensorflowOperatorTestBase { +class TensorflowOperatorTestBase { protected Configuration configuration; protected TensorflowExecutor tensorflowExecutor; - @Before - public void setUp() { + @BeforeEach + void setUp() { this.configuration = new Configuration(); if(tensorflowExecutor == null) this.tensorflowExecutor = (TensorflowExecutor) TensorflowPlatform.getInstance().getExecutorFactory().create(this.mockJob()); diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/JavaExecutionOperatorTestBase.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/JavaExecutionOperatorTestBase.java index 6266505df..a6b186208 100644 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/JavaExecutionOperatorTestBase.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/JavaExecutionOperatorTestBase.java @@ -18,7 +18,6 @@ package org.apache.wayang.iejoin.operators; -import org.junit.BeforeClass; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; @@ -31,6 +30,7 @@ import org.apache.wayang.java.execution.JavaExecutor; import org.apache.wayang.java.operators.JavaExecutionOperator; import org.apache.wayang.java.platform.JavaPlatform; +import org.junit.jupiter.api.BeforeAll; import java.util.Collection; import java.util.stream.Stream; @@ -47,8 +47,8 @@ public class JavaExecutionOperatorTestBase { protected static Configuration configuration; - @BeforeClass - public static void init() { + @BeforeAll + static void init() { configuration = new Configuration(); job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/JavaIEJoinOperatorTest.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/JavaIEJoinOperatorTest.java index 137084aa5..523d4a1e9 100755 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/JavaIEJoinOperatorTest.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/JavaIEJoinOperatorTest.java @@ -18,28 +18,29 @@ package org.apache.wayang.iejoin.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.function.TransformationDescriptor; import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.java.channels.JavaChannelInstance; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link JavaIEJoinOperator}. */ -public class JavaIEJoinOperatorTest extends JavaExecutionOperatorTestBase { +class JavaIEJoinOperatorTest extends JavaExecutionOperatorTestBase { @Test - public void testExecution() { + void testExecution() { Record r1 = new Record(100, 10); Record r2 = new Record(200, 20); Record r3 = new Record(300, 30); @@ -84,7 +85,7 @@ public void testExecution() { // Verify the outcome. final List> result = outputs[0].>provideStream().collect(Collectors.toList()); - Assert.assertEquals(2, result.size()); + assertEquals(2, result.size()); //Assert.assertEquals(result.get(0), new Tuple2(1, "a")); } diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest.java index 503798a59..592c5c548 100755 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.iejoin.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.function.TransformationDescriptor; @@ -27,18 +25,21 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkIEJoinOperator}. */ -public class SparkIEJoinOperatorTest extends SparkOperatorTestBase { +class SparkIEJoinOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { Record r1 = new Record(100, 10); Record r2 = new Record(200, 20); Record r3 = new Record(300, 30); @@ -83,7 +84,7 @@ public void testExecution() { // Verify the outcome. final List> result = output.>provideRdd().collect(); - Assert.assertEquals(2, result.size()); + assertEquals(2, result.size()); //Assert.assertEquals(result.get(0), new Tuple2(1, "a")); } diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest2.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest2.java index 5c63d8603..f21918c81 100755 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest2.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest2.java @@ -18,8 +18,6 @@ package org.apache.wayang.iejoin.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.function.TransformationDescriptor; @@ -27,18 +25,21 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkIEJoinOperator}. */ -public class SparkIEJoinOperatorTest2 extends SparkOperatorTestBase { +class SparkIEJoinOperatorTest2 extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { Record r1 = new Record(100, 10); Record r2 = new Record(200, 20); Record r3 = new Record(300, 30); @@ -85,7 +86,7 @@ public void testExecution() { // Verify the outcome. final List> result = output.>provideRdd().collect(); - Assert.assertEquals(2, result.size()); + assertEquals(2, result.size()); //Assert.assertEquals(result.get(0), new Tuple2(1, "a")); } diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest3.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest3.java index 2083d2566..73b1c4f6d 100755 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest3.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest3.java @@ -18,8 +18,6 @@ package org.apache.wayang.iejoin.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.function.TransformationDescriptor; @@ -27,18 +25,21 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkIEJoinOperator}. */ -public class SparkIEJoinOperatorTest3 extends SparkOperatorTestBase { +class SparkIEJoinOperatorTest3 extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { Record r1 = new Record(100, 10); Record r2 = new Record(200, 20); Record r3 = new Record(300, 30); @@ -85,7 +86,7 @@ public void testExecution() { // Verify the outcome. final List> result = output.>provideRdd().collect(); - Assert.assertEquals(3, result.size()); + assertEquals(3, result.size()); //Assert.assertEquals(result.get(0), new Tuple2(1, "a")); } diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest4.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest4.java index 9840b51fa..124d94aad 100755 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest4.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIEJoinOperatorTest4.java @@ -18,8 +18,6 @@ package org.apache.wayang.iejoin.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.function.TransformationDescriptor; @@ -27,18 +25,21 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkIEJoinOperator}. */ -public class SparkIEJoinOperatorTest4 extends SparkOperatorTestBase { +class SparkIEJoinOperatorTest4 extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { Record r1 = new Record(100, 10); Record r2 = new Record(200, 20); Record r3 = new Record(300, 30); @@ -85,7 +86,7 @@ public void testExecution() { // Verify the outcome. final List> result = output.>provideRdd().collect(); - Assert.assertEquals(7, result.size()); + assertEquals(7, result.size()); //Assert.assertEquals(result.get(0), new Tuple2(1, "a")); } diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIESelfJoinOperatorTest.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIESelfJoinOperatorTest.java index 8029737a3..1e780e456 100755 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIESelfJoinOperatorTest.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkIESelfJoinOperatorTest.java @@ -18,8 +18,6 @@ package org.apache.wayang.iejoin.operators; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.function.TransformationDescriptor; @@ -27,18 +25,21 @@ import org.apache.wayang.core.types.DataSetType; import org.apache.wayang.core.types.DataUnitType; import org.apache.wayang.spark.channels.RddChannel; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test suite for {@link SparkIEJoinOperator}. */ -public class SparkIESelfJoinOperatorTest extends SparkOperatorTestBase { +class SparkIESelfJoinOperatorTest extends SparkOperatorTestBase { @Test - public void testExecution() { + void testExecution() { //Record r1 = new Record(100, 10); Record r2 = new Record(200, 20); Record r3 = new Record(300, 30); @@ -73,8 +74,8 @@ public void testExecution() { // Verify the outcome. final List> result = output.>provideRdd().collect(); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(result.get(0), new Tuple2(r11, r2)); + assertEquals(1, result.size()); + assertEquals(result.get(0), new Tuple2(r11, r2)); //Assert.assertEquals(result.get(0), new Tuple2(1, "a")); } diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkOperatorTestBase.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkOperatorTestBase.java index aa3337665..4c17a07c1 100644 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkOperatorTestBase.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/operators/SparkOperatorTestBase.java @@ -19,7 +19,6 @@ package org.apache.wayang.iejoin.operators; import org.apache.spark.api.java.JavaSparkContext; -import org.junit.Before; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; @@ -33,6 +32,7 @@ import org.apache.wayang.spark.execution.SparkExecutor; import org.apache.wayang.spark.operators.SparkExecutionOperator; import org.apache.wayang.spark.platform.SparkPlatform; +import org.junit.jupiter.api.BeforeEach; import java.util.Collection; @@ -50,8 +50,8 @@ public class SparkOperatorTestBase { protected Job job; - @Before - public void setUp() { + @BeforeEach + void setUp() { this.configuration = new Configuration(); this.job = mock(Job.class); when(this.job.getConfiguration()).thenReturn(this.configuration); diff --git a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/test/ChannelFactory.java b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/test/ChannelFactory.java index 424b78d10..93198b717 100644 --- a/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/test/ChannelFactory.java +++ b/wayang-plugins/wayang-iejoin/src/test/java/org/apache/wayang/iejoin/test/ChannelFactory.java @@ -18,7 +18,6 @@ package org.apache.wayang.iejoin.test; -import org.junit.Before; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.plan.executionplan.Channel; import org.apache.wayang.core.platform.ChannelDescriptor; @@ -28,6 +27,7 @@ import org.apache.wayang.java.execution.JavaExecutor; import org.apache.wayang.spark.channels.RddChannel; import org.apache.wayang.spark.execution.SparkExecutor; +import org.junit.jupiter.api.BeforeEach; import java.util.Collection; import java.util.stream.Stream; @@ -43,8 +43,8 @@ public class ChannelFactory { private static JavaExecutor javaExecutor; - @Before - public void setUp() { + @BeforeEach + void setUp() { sparkExecutor = mock(SparkExecutor.class); javaExecutor = mock(JavaExecutor.class); } diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/FlinkIntegrationIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/FlinkIntegrationIT.java index b5d964c6b..cfab48b25 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/FlinkIntegrationIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/FlinkIntegrationIT.java @@ -18,23 +18,19 @@ package org.apache.wayang.tests; -import org.apache.wayang.java.plugin.JavaBasicPlugin; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.api.Job; import org.apache.wayang.core.api.WayangContext; import org.apache.wayang.core.api.exception.WayangException; import org.apache.wayang.core.plan.wayangplan.WayangPlan; -import org.apache.wayang.core.plugin.Plugin; import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.flink.Flink; import org.apache.wayang.java.Java; import org.apache.wayang.tests.platform.MyMadeUpPlatform; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -47,10 +43,14 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + /** * Test the Spark integration with Wayang. */ -public class FlinkIntegrationIT { +class FlinkIntegrationIT { private static final String JAVA = "JAVA"; private static final String FLINK = "JAVA"; @@ -58,9 +58,9 @@ public class FlinkIntegrationIT { private WayangContext makeContext(String plugin){ WayangContext wayangContext = new WayangContext(); - if(plugin == JAVA || plugin == BOTH) + if (plugin == JAVA || plugin == BOTH) wayangContext.with(Java.basicPlugin()); - if(plugin == FLINK || plugin == BOTH) + if (plugin == FLINK || plugin == BOTH) wayangContext.with(Flink.basicPlugin()); return wayangContext; } @@ -71,7 +71,7 @@ private void makeAndRun(WayangPlan plan, String plugin){ } @Test - public void testReadAndWrite() throws URISyntaxException, IOException { + void testReadAndWrite() throws Exception { // Build a Wayang plan. List collector = new LinkedList<>(); @@ -79,12 +79,12 @@ public void testReadAndWrite() throws URISyntaxException, IOException { // Verify the plan result. final List lines = Files.lines(Paths.get(WayangPlans.FILE_SOME_LINES_TXT)).collect(Collectors.toList()); - Assert.assertEquals(lines, collector); + assertEquals(lines, collector); } @Test - public void testReadAndTransformAndWrite() throws URISyntaxException { + void testReadAndTransformAndWrite() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); @@ -93,7 +93,7 @@ public void testReadAndTransformAndWrite() throws URISyntaxException { } @Test - public void testCartesianOperator() throws IOException { + void testCartesianOperator() { List> collector = new ArrayList<>(); final WayangPlan wayangPlan = WayangPlansOperators.cartesian(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT, collector); @@ -104,48 +104,47 @@ public void testCartesianOperator() throws IOException { final WayangPlan wayangPlanJava = WayangPlansOperators.cartesian(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } @Test - public void testCoGroupOperator() throws IOException { + void testCoGroupOperator() { List> collector = new ArrayList<>(); final WayangPlan wayangPlan = WayangPlansOperators.coGroup(WayangPlans.FILE_WITH_KEY_1, WayangPlans.FILE_WITH_KEY_2, collector); makeAndRun(wayangPlan, FLINK); - // Run in java for test result List> collectorJava = new ArrayList<>(); final WayangPlan wayangPlanJava = WayangPlansOperators.coGroup(WayangPlans.FILE_WITH_KEY_1, WayangPlans.FILE_WITH_KEY_2, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } @Test - public void testCollectionSource(){ + void testCollectionSource() { List input = makeList(); List collector = new ArrayList<>(); WayangPlan wayangplan = WayangPlansOperators.collectionSourceOperator(input, collector); makeAndRun(wayangplan, FLINK); - Assert.assertEquals(input, collector); + assertEquals(input, collector); } @Test - public void testCountOperator(){ + void testCountOperator() { List input = makeList(); List collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.count(input, collector); makeAndRun(wayangPlan, FLINK); - Assert.assertTrue(input.size() == collector.get(0)); + assertEquals(input.size(), (long) collector.get(0)); } @Test - public void testDistinctOperator(){ + void testDistinctOperator() { List collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.distinct(WayangPlans.FILE_SOME_LINES_TXT, collector); makeAndRun(wayangPlan, FLINK); @@ -154,11 +153,11 @@ public void testDistinctOperator(){ WayangPlan wayangPlanJava = WayangPlansOperators.distinct(WayangPlans.FILE_SOME_LINES_TXT, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava.stream().sorted().toArray(), collector.stream().sorted().toArray()); + assertArrayEquals(collectorJava.stream().sorted().toArray(), collector.stream().sorted().toArray()); } @Test - public void testFilterOperator(){ + void testFilterOperator() { List collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.filter(WayangPlans.FILE_SOME_LINES_TXT, collector); makeAndRun(wayangPlan, FLINK); @@ -167,11 +166,11 @@ public void testFilterOperator(){ WayangPlan wayangPlanJava = WayangPlansOperators.filter(WayangPlans.FILE_SOME_LINES_TXT, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } @Test - public void testFlapMapOperator(){ + void testFlapMapOperator() { List collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.flatMap(WayangPlans.FILE_SOME_LINES_TXT, collector); makeAndRun(wayangPlan, FLINK); @@ -180,11 +179,11 @@ public void testFlapMapOperator(){ WayangPlan wayangPlanJava = WayangPlansOperators.flatMap(WayangPlans.FILE_SOME_LINES_TXT, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } @Test - public void testJoinOperator(){ + void testJoinOperator() { List> collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.join(WayangPlans.FILE_WITH_KEY_1, WayangPlans.FILE_WITH_KEY_2, collector); makeAndRun(wayangPlan, FLINK); @@ -193,12 +192,11 @@ public void testJoinOperator(){ WayangPlan wayangPlanJava = WayangPlansOperators.join(WayangPlans.FILE_WITH_KEY_1, WayangPlans.FILE_WITH_KEY_2, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } - @Test - public void testReduceByOperator(){ + void testReduceByOperator() { List> collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.reduceBy(WayangPlans.FILE_WITH_KEY_1, collector); makeAndRun(wayangPlan, FLINK); @@ -207,11 +205,11 @@ public void testReduceByOperator(){ WayangPlan wayangPlanJava = WayangPlansOperators.reduceBy(WayangPlans.FILE_WITH_KEY_1, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } @Test - public void testSortOperator(){ + void testSortOperator() { List collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.sort(WayangPlans.FILE_SOME_LINES_TXT, collector); makeAndRun(wayangPlan, FLINK); @@ -220,12 +218,11 @@ public void testSortOperator(){ WayangPlan wayangPlanJava = WayangPlansOperators.sort(WayangPlans.FILE_SOME_LINES_TXT, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } @Test - public void testTextFileSink() throws IOException { - + void testTextFileSink() throws Exception { File temp = File.createTempFile("tempfile", ".tmp"); temp.delete(); @@ -237,14 +234,13 @@ public void testTextFileSink() throws IOException { final List linesFlink = Files.lines(Paths.get(temp.toURI())).collect(Collectors.toList()); - Assert.assertEquals(lines, linesFlink); + assertEquals(lines, linesFlink); temp.delete(); - } @Test - public void testUnionOperator(){ + void testUnionOperator() { List collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.union(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT, collector); makeAndRun(wayangPlan, FLINK); @@ -253,11 +249,11 @@ public void testUnionOperator(){ WayangPlan wayangPlanJava = WayangPlansOperators.union(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } @Test - public void testZipWithIdOperator(){ + void testZipWithIdOperator() { List> collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlansOperators.zipWithId(WayangPlans.FILE_SOME_LINES_TXT, collector); makeAndRun(wayangPlan, FLINK); @@ -266,10 +262,10 @@ public void testZipWithIdOperator(){ WayangPlan wayangPlanJava = WayangPlansOperators.zipWithId(WayangPlans.FILE_SOME_LINES_TXT, collectorJava); makeAndRun(wayangPlanJava, JAVA); - Assert.assertEquals(collectorJava, collector); + assertEquals(collectorJava, collector); } - private List makeList(){ + private List makeList() { return Arrays.asList( "word1", "word2", @@ -284,11 +280,8 @@ private List makeList(){ ); } - - - - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration1() throws URISyntaxException { + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration1() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); // ILLEGAL: This platform is not registered, so this operator will find no implementation. @@ -297,15 +290,13 @@ public void testReadAndTransformAndWriteWithIllegalConfiguration1() throws URISy // Instantiate Wayang and activate the Spark backend. WayangContext wayangContext = makeContext(FLINK); - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); - - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); + assertThrows(WayangException.class, () -> + // Have Wayang execute the plan. + wayangContext.execute(wayangPlan)); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration2() throws URISyntaxException { + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration2() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); @@ -313,12 +304,13 @@ public void testReadAndTransformAndWriteWithIllegalConfiguration2() throws URISy // ILLEGAL: This dummy platform is not sufficient to execute the plan. wayangContext.register(MyMadeUpPlatform.getInstance()); - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); + assertThrows(WayangException.class, () -> + // Have Wayang execute the plan. + wayangContext.execute(wayangPlan)); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration3() throws URISyntaxException { + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration3() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); @@ -330,11 +322,11 @@ public void testReadAndTransformAndWriteWithIllegalConfiguration3() throws URISy // ILLEGAL: We blacklist the Spark platform, although we need it. job.getConfiguration().getPlatformProvider().addToBlacklist(Flink.platform()); job.getConfiguration().getPlatformProvider().addToWhitelist(MyMadeUpPlatform.getInstance()); - job.execute(); + assertThrows(WayangException.class, job::execute); } @Test - public void testMultiSourceAndMultiSink() throws URISyntaxException { + void testMultiSourceAndMultiSink() { // Define some input data. final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); @@ -354,12 +346,12 @@ public void testMultiSourceAndMultiSink() throws URISyntaxException { Collections.sort(expectedOutcome2); Collections.sort(collector1); Collections.sort(collector2); - Assert.assertEquals(expectedOutcome1, collector1); - Assert.assertEquals(expectedOutcome2, collector2); + assertEquals(expectedOutcome1, collector1); + assertEquals(expectedOutcome2, collector2); } @Test - public void testMultiSourceAndHoleAndMultiSink() throws URISyntaxException { + void testMultiSourceAndHoleAndMultiSink() { // Define some input data. final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); @@ -372,17 +364,15 @@ public void testMultiSourceAndHoleAndMultiSink() throws URISyntaxException { // Check the results in both sinks. List expectedOutcome = Stream.concat(collection1.stream(), collection2.stream()) - .flatMap(string -> Arrays.asList(string.toLowerCase(), string.toUpperCase()).stream()) - .collect(Collectors.toList()); - Collections.sort(expectedOutcome); + .flatMap(string -> Stream.of(string.toLowerCase(), string.toUpperCase())).sorted().collect(Collectors.toList()); Collections.sort(collector1); Collections.sort(collector2); - Assert.assertEquals(expectedOutcome, collector1); - Assert.assertEquals(expectedOutcome, collector2); + assertEquals(expectedOutcome, collector1); + assertEquals(expectedOutcome, collector2); } @Test - public void testGlobalMaterializedGroup() throws URISyntaxException { + void testGlobalMaterializedGroup() { // Build the WayangPlan. List> collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.globalMaterializedGroup(collector, 1, 2, 3); @@ -390,12 +380,12 @@ public void testGlobalMaterializedGroup() throws URISyntaxException { // Instantiate Wayang and activate the Java backend. makeAndRun(wayangPlan, FLINK); - Assert.assertEquals(1, collector.size()); - Assert.assertEquals(WayangCollections.asSet(1, 2, 3), WayangCollections.asCollection(collector.get(0), HashSet::new)); + assertEquals(1, collector.size()); + assertEquals(WayangCollections.asSet(1, 2, 3), WayangCollections.asCollection(collector.get(0), HashSet::new)); } @Test - public void testIntersect() throws URISyntaxException { + void testIntersect() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.intersectSquares(collector, 0, 1, 2, 3, 3, -1, -1, -2, -3, -3, -4); @@ -403,12 +393,13 @@ public void testIntersect() throws URISyntaxException { // Instantiate Wayang and activate the Java backend. makeAndRun(wayangPlan, FLINK); - Assert.assertEquals(WayangCollections.asSet(1, 4, 9), WayangCollections.asSet(collector)); + assertEquals(WayangCollections.asSet(1, 4, 9), WayangCollections.asSet(collector)); } //TODO validate this test is required - //@Test - public void testPageRankWithGraphBasic() { + @Disabled + @Test + void testPageRankWithGraphBasic() { // Build the WayangPlan. List> edges = Arrays.asList( new Tuple2<>(0L, 1L), @@ -431,7 +422,7 @@ public void testPageRankWithGraphBasic() { // Check the results. pageRanks.sort((r1, r2) -> Float.compare(r2.getField1(), r1.getField1())); final List vertexOrder = pageRanks.stream().map(Tuple2::getField0).collect(Collectors.toList()); - Assert.assertEquals( + assertEquals( Arrays.asList(3L, 0L, 2L, 1L), vertexOrder ); @@ -439,7 +430,7 @@ public void testPageRankWithGraphBasic() { @Test - public void testMapPartitions() throws URISyntaxException { + void testMapPartitions() { // Execute the Wayang plan. final Collection> result = new ArrayList<>(); @@ -447,14 +438,14 @@ public void testMapPartitions() throws URISyntaxException { makeAndRun(wayangPlan, FLINK); - Assert.assertEquals( + assertEquals( WayangCollections.asSet(new Tuple2<>("even", 4), new Tuple2<>("odd", 6)), WayangCollections.asSet(result) ); } @Test - public void testZipWithId() throws URISyntaxException { + void testZipWithId() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.zipWithId(collector, 0, 10, 20, 30, 30); @@ -462,12 +453,12 @@ public void testZipWithId() throws URISyntaxException { // Instantiate Wayang and activate the Java backend. makeAndRun(wayangPlan, FLINK); - Assert.assertEquals(1, collector.size()); - Assert.assertEquals(Long.valueOf(5L), collector.get(0)); + assertEquals(1, collector.size()); + assertEquals(Long.valueOf(5L), collector.get(0)); } @Test - public void testDiverseScenario1() throws URISyntaxException { + void testDiverseScenario1() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario1(WayangPlans.FILE_SOME_LINES_TXT); @@ -476,7 +467,7 @@ public void testDiverseScenario1() throws URISyntaxException { } @Test - public void testDiverseScenario2() throws URISyntaxException { + void testDiverseScenario2() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario2(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -485,7 +476,7 @@ public void testDiverseScenario2() throws URISyntaxException { } @Test - public void testDiverseScenario3() throws URISyntaxException { + void testDiverseScenario3() { // Build the WayangPlan. //TODO: need implement the loop for running this test //WayangPlan wayangPlan = WayangPlans.diverseScenario3(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -495,7 +486,7 @@ public void testDiverseScenario3() throws URISyntaxException { } @Test - public void testDiverseScenario4() throws URISyntaxException { + void testDiverseScenario4() { // Build the WayangPlan. //TODO: need implement the loop for running this test //WayangPlan wayangPlan = WayangPlans.diverseScenario4(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -506,7 +497,7 @@ public void testDiverseScenario4() throws URISyntaxException { @Test - public void testSample() throws URISyntaxException { + void testSample() { // Build the WayangPlan. final List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.simpleSample(3, collector, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); @@ -517,5 +508,4 @@ public void testSample() throws URISyntaxException { System.out.println(collector); } - } diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/FullIntegrationIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/FullIntegrationIT.java index 51cf036c4..7493bdf89 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/FullIntegrationIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/FullIntegrationIT.java @@ -18,9 +18,6 @@ package org.apache.wayang.tests; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; import org.apache.wayang.basic.WayangBasics; import org.apache.wayang.basic.data.Record; import org.apache.wayang.basic.data.Tuple2; @@ -43,10 +40,11 @@ import org.apache.wayang.spark.Spark; import org.apache.wayang.sqlite3.Sqlite3; import org.apache.wayang.tests.platform.MyMadeUpPlatform; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.sql.SQLException; @@ -62,15 +60,18 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + /** * Test the Java integration with Wayang. */ -public class FullIntegrationIT { +class FullIntegrationIT { private Configuration configuration; - @Before - public void setUp() throws SQLException, IOException { + @BeforeEach + void setUp() throws SQLException, IOException { this.configuration = new Configuration(); File sqlite3dbFile = File.createTempFile("wayang-sqlite3", "db"); sqlite3dbFile.deleteOnExit(); @@ -82,7 +83,7 @@ public void setUp() throws SQLException, IOException { } @Test - public void testReadAndWrite() throws URISyntaxException, IOException { + void testReadAndWrite() throws IOException { // Build a Wayang plan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.readWrite(WayangPlans.FILE_SOME_LINES_TXT, collector); @@ -98,11 +99,11 @@ public void testReadAndWrite() throws URISyntaxException, IOException { // Verify the plan result. final List lines = Files.lines(Paths.get(WayangPlans.FILE_SOME_LINES_TXT)).collect(Collectors.toList()); - Assert.assertEquals(lines, collector); + assertEquals(lines, collector); } @Test - public void testReadAndWriteCrossPlatform() throws URISyntaxException, IOException { + void testReadAndWriteCrossPlatform() throws IOException { // Build a Wayang plan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.readWrite(WayangPlans.FILE_SOME_LINES_TXT, collector); @@ -121,11 +122,11 @@ public void testReadAndWriteCrossPlatform() throws URISyntaxException, IOExcepti // Verify the plan result. final List lines = Files.lines(Paths.get(WayangPlans.FILE_SOME_LINES_TXT)).collect(Collectors.toList()); - Assert.assertEquals(lines, collector); + assertEquals(lines, collector); } @Test - public void testReadAndTransformAndWrite() throws URISyntaxException { + void testReadAndTransformAndWrite() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); @@ -138,28 +139,25 @@ public void testReadAndTransformAndWrite() throws URISyntaxException { wayangContext.execute(wayangPlan); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration1() throws URISyntaxException { - // Build a Wayang plan. + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration1() { final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); - // ILLEGAL: This platform is not registered, so this operator will find no implementation. wayangPlan.getSinks().forEach(sink -> sink.addTargetPlatform(MyMadeUpPlatform.getInstance())); - - // Instantiate Wayang and activate the Java backend. WayangContext wayangContext = new WayangContext(configuration) - .with(Java.basicPlugin()) - .with(Spark.basicPlugin()); + .with(Java.basicPlugin()) + .with(Spark.basicPlugin()); + assertThrows(WayangException.class, () -> - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); + // Have Wayang execute the plan. + wayangContext.execute(wayangPlan)); } @Test - public void testMultiSourceAndMultiSink() throws URISyntaxException { + void testMultiSourceAndMultiSink() { // Define some input data. - final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); - final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); + final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); + final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); List collector1 = new LinkedList<>(); List collector2 = new LinkedList<>(); final WayangPlan wayangPlan = WayangPlans.multiSourceMultiSink(collection1, collection2, collector1, collector2); @@ -182,15 +180,15 @@ public void testMultiSourceAndMultiSink() throws URISyntaxException { Collections.sort(expectedOutcome2); Collections.sort(collector1); Collections.sort(collector2); - Assert.assertEquals(expectedOutcome1, collector1); - Assert.assertEquals(expectedOutcome2, collector2); + assertEquals(expectedOutcome1, collector1); + assertEquals(expectedOutcome2, collector2); } @Test - public void testMultiSourceAndHoleAndMultiSink() throws URISyntaxException { + void testMultiSourceAndHoleAndMultiSink() { // Define some input data. - final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); - final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); + final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); + final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); List collector1 = new LinkedList<>(); List collector2 = new LinkedList<>(); final WayangPlan wayangPlan = WayangPlans.multiSourceHoleMultiSink(collection1, collection2, collector1, collector2); @@ -205,17 +203,15 @@ public void testMultiSourceAndHoleAndMultiSink() throws URISyntaxException { // Check the results in both sinks. List expectedOutcome = Stream.concat(collection1.stream(), collection2.stream()) - .flatMap(string -> Arrays.asList(string.toLowerCase(), string.toUpperCase()).stream()) - .collect(Collectors.toList()); - Collections.sort(expectedOutcome); + .flatMap(string -> Stream.of(string.toLowerCase(), string.toUpperCase())).sorted().collect(Collectors.toList()); Collections.sort(collector1); Collections.sort(collector2); - Assert.assertEquals(expectedOutcome, collector1); - Assert.assertEquals(expectedOutcome, collector2); + assertEquals(expectedOutcome, collector1); + assertEquals(expectedOutcome, collector2); } @Test - public void testGlobalMaterializedGroup() throws URISyntaxException { + void testGlobalMaterializedGroup() { // Build the WayangPlan. List> collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.globalMaterializedGroup(collector, 1, 2, 3); @@ -227,12 +223,12 @@ public void testGlobalMaterializedGroup() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(1, collector.size()); - Assert.assertEquals(WayangCollections.asSet(1, 2, 3), WayangCollections.asCollection(collector.get(0), HashSet::new)); + assertEquals(1, collector.size()); + assertEquals(WayangCollections.asSet(1, 2, 3), WayangCollections.asCollection(collector.get(0), HashSet::new)); } @Test - public void testIntersect() throws URISyntaxException { + void testIntersect() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.intersectSquares(collector, 0, 1, 2, 3, 3, -1, -1, -2, -3, -3, -4); @@ -244,11 +240,11 @@ public void testIntersect() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(WayangCollections.asSet(1, 4, 9), WayangCollections.asSet(collector)); + assertEquals(WayangCollections.asSet(1, 4, 9), WayangCollections.asSet(collector)); } @Test - public void testRepeat() { + void testRepeat() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.repeat(collector, 5, 0, 10, 20, 30, 45); @@ -260,12 +256,12 @@ public void testRepeat() { wayangContext.execute(wayangPlan); - Assert.assertEquals(5, collector.size()); - Assert.assertEquals(WayangCollections.asSet(5, 15, 25, 35, 50), WayangCollections.asSet(collector)); + assertEquals(5, collector.size()); + assertEquals(WayangCollections.asSet(5, 15, 25, 35, 50), WayangCollections.asSet(collector)); } @Test - public void testPageRankWithGraphBasic() { + void testPageRankWithGraphBasic() { // Build the WayangPlan. List> edges = Arrays.asList( new Tuple2<>(0L, 1L), @@ -289,28 +285,28 @@ public void testPageRankWithGraphBasic() { // Check the results. pageRanks.sort((r1, r2) -> Float.compare(r2.getField1(), r1.getField1())); final List vertexOrder = pageRanks.stream().map(Tuple2::getField0).collect(Collectors.toList()); - Assert.assertEquals( + assertEquals( Arrays.asList(3L, 0L, 2L, 1L), vertexOrder ); } @Test - public void testMapPartitions() throws URISyntaxException { + void testMapPartitions() { // Instantiate Wayang and activate the Java backend. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()).with(Spark.basicPlugin()); // Execute the Wayang plan. final Collection> result = WayangPlans.mapPartitions(wayangContext, 0, 1, 1, 3, 3, 4, 4, 5, 5, 6); - Assert.assertEquals( + assertEquals( WayangCollections.asSet(new Tuple2<>("even", 4), new Tuple2<>("odd", 6)), WayangCollections.asSet(result) ); } @Test - public void testZipWithId() throws URISyntaxException { + void testZipWithId() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.zipWithId(collector, 0, 10, 20, 30, 30); @@ -322,12 +318,12 @@ public void testZipWithId() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(1, collector.size()); - Assert.assertEquals(Long.valueOf(5L), collector.get(0)); + assertEquals(1, collector.size()); + assertEquals(Long.valueOf(5L), collector.get(0)); } @Test - public void testDiverseScenario1() throws URISyntaxException { + void testDiverseScenario1() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario1(WayangPlans.FILE_SOME_LINES_TXT); @@ -340,7 +336,7 @@ public void testDiverseScenario1() throws URISyntaxException { } @Test - public void testDiverseScenario2() throws URISyntaxException { + void testDiverseScenario2() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario2(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -353,7 +349,7 @@ public void testDiverseScenario2() throws URISyntaxException { } @Test - public void testDiverseScenario3() throws URISyntaxException { + void testDiverseScenario3() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario2(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -366,7 +362,7 @@ public void testDiverseScenario3() throws URISyntaxException { } @Test - public void testDiverseScenario4() throws URISyntaxException { + void testDiverseScenario4() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario4(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -379,7 +375,7 @@ public void testDiverseScenario4() throws URISyntaxException { } @Test - public void testSimpleSingleStageLoop() throws URISyntaxException { + void testSimpleSingleStageLoop() { // Build the WayangPlan. final Set collector = new HashSet<>(); WayangPlan wayangPlan = WayangPlans.simpleLoop(3, collector, 0, 1, 2); @@ -399,11 +395,11 @@ public void testSimpleSingleStageLoop() throws URISyntaxException { wayangContext.execute(wayangPlan); final HashSet expected = new HashSet<>(WayangArrays.asList(WayangArrays.range(0, 24))); - Assert.assertEquals(expected, collector); + assertEquals(expected, collector); } @Test - public void testSimpleMultiStageLoop() throws URISyntaxException { + void testSimpleMultiStageLoop() { // Build the WayangPlan. final List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.simpleLoop(3, collector, 0, 1, 2); @@ -423,11 +419,11 @@ public void testSimpleMultiStageLoop() throws URISyntaxException { wayangContext.execute(wayangPlan); final HashSet expected = new HashSet<>(WayangArrays.asList(WayangArrays.range(0, 24))); - Assert.assertEquals(expected, WayangCollections.asSet(collector)); + assertEquals(expected, WayangCollections.asSet(collector)); } @Test - public void testSimpleSample() throws URISyntaxException { + void testSimpleSample() { // Build the WayangPlan. final List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.simpleSample(3, collector, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); @@ -442,29 +438,29 @@ public void testSimpleSample() throws URISyntaxException { } @Test - public void testCurrentIterationNumber() { + void testCurrentIterationNumber() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()).with(Spark.basicPlugin()); final Collection result = WayangPlans.loopWithIterationNumber(wayangContext, 15, 5, -1, 1, 5); int expectedOffset = 10; - Assert.assertEquals( + assertEquals( WayangCollections.asSet(-1 + expectedOffset, 1 + expectedOffset, 5 + expectedOffset), WayangCollections.asSet(result) ); } @Test - public void testCurrentIterationNumberWithTooFewExpectedIterations() { + void testCurrentIterationNumberWithTooFewExpectedIterations() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()).with(Spark.basicPlugin()); final Collection result = WayangPlans.loopWithIterationNumber(wayangContext, 15, 2, -1, 1, 5); int expectedOffset = 10; - Assert.assertEquals( + assertEquals( WayangCollections.asSet(-1 + expectedOffset, 1 + expectedOffset, 5 + expectedOffset), WayangCollections.asSet(result) ); } @Test - public void testGroupByOperator() { + void testGroupByOperator() { final CollectionSource source = new CollectionSource<>( Arrays.asList("a", "b", "a", "ab", "aa", "bb"), String.class @@ -496,7 +492,7 @@ public void testGroupByOperator() { } @Test - public void testSqlite3Scenario1() { + void testSqlite3Scenario1() { Collection collector = new ArrayList<>(); final WayangPlan wayangPlan = WayangPlans.sqlite3Scenario1(collector); @@ -507,11 +503,11 @@ public void testSqlite3Scenario1() { wayangContext.execute("SQLite3 scenario 1", wayangPlan); - Assert.assertEquals(WayangPlans.getSqlite3Customers(), collector); + assertEquals(WayangPlans.getSqlite3Customers(), collector); } @Test - public void testSqlite3Scenario2() { + void testSqlite3Scenario2() { Collection collector = new ArrayList<>(); final WayangPlan wayangPlan = WayangPlans.sqlite3Scenario2(collector); @@ -525,11 +521,11 @@ public void testSqlite3Scenario2() { final List expected = WayangPlans.getSqlite3Customers().stream() .filter(r -> (Integer) r.getField(1) >= 18) .collect(Collectors.toList()); - Assert.assertEquals(expected, collector); + assertEquals(expected, collector); } @Test - public void testSqlite3Scenario3() { + void testSqlite3Scenario3() { Collection collector = new ArrayList<>(); final WayangPlan wayangPlan = WayangPlans.sqlite3Scenario3(collector); @@ -542,8 +538,8 @@ public void testSqlite3Scenario3() { final List expected = WayangPlans.getSqlite3Customers().stream() .filter(r -> (Integer) r.getField(1) >= 18) - .map(r -> new Record(new Object[]{r.getField(0)})) + .map(r -> new Record(r.getField(0))) .collect(Collectors.toList()); - Assert.assertEquals(expected, collector); + assertEquals(expected, collector); } } diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/GiraphIntegrationIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/GiraphIntegrationIT.java index 8921a2672..8b80b9eaf 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/GiraphIntegrationIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/GiraphIntegrationIT.java @@ -18,13 +18,13 @@ package org.apache.wayang.tests; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.core.api.WayangContext; import org.apache.wayang.core.plan.wayangplan.WayangPlan; import org.apache.wayang.giraph.Giraph; import org.apache.wayang.java.Java; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; @@ -32,26 +32,30 @@ import java.util.Set; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Integration tests for the integration of Giraph with Wayang. */ -public class GiraphIntegrationIT { +class GiraphIntegrationIT { - //@Test //TODO validate if this test is helpfull - public void testPageRankWithJava() { + @Disabled + @Test + void testPageRankWithJava() { List> pageRanks = new ArrayList<>(); WayangPlan wayangPlan = WayangPlans.pageRankWithDictionaryCompression(pageRanks); WayangContext rc = new WayangContext().with(Java.basicPlugin()).with(Giraph.plugin()); rc.execute(wayangPlan); - pageRanks.stream().forEach(System.out::println); + pageRanks.forEach(System.out::println); this.check(pageRanks); } @Test - public void testPageRankWithoutGiraph() { + void testPageRankWithoutGiraph() { List> pageRanks = new ArrayList<>(); WayangPlan wayangPlan = WayangPlans.pageRankWithDictionaryCompression(pageRanks); WayangContext rc = new WayangContext() @@ -65,8 +69,8 @@ public void testPageRankWithoutGiraph() { private void check(List> pageRanks) { final Map solutions = WayangPlans.pageRankWithDictionaryCompressionSolution(); Set vertices = pageRanks.stream().map(Tuple2::getField0).collect(Collectors.toSet()); - solutions.forEach((k, v) -> Assert.assertTrue(String.format("Missing page rank for %s.", k), vertices.contains(k))); - Assert.assertEquals(String.format("Illegal number of page ranks in %s.", pageRanks), solutions.size(), pageRanks.size()); + solutions.forEach((k, v) -> assertTrue(vertices.contains(k), String.format("Missing page rank for %s.", k))); + assertEquals(solutions.size(), pageRanks.size(), String.format("Illegal number of page ranks in %s.", pageRanks)); } } diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/JavaIntegrationIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/JavaIntegrationIT.java index deafb008c..925ee195f 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/JavaIntegrationIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/JavaIntegrationIT.java @@ -18,8 +18,6 @@ package org.apache.wayang.tests; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.WayangBasics; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.operators.CollectionSource; @@ -39,9 +37,9 @@ import org.apache.wayang.core.util.WayangCollections; import org.apache.wayang.java.Java; import org.apache.wayang.tests.platform.MyMadeUpPlatform; +import org.junit.jupiter.api.Test; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -55,13 +53,16 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + /** * Test the Java integration with Wayang. */ -public class JavaIntegrationIT { +class JavaIntegrationIT { @Test - public void testReadAndWrite() throws URISyntaxException, IOException { + void testReadAndWrite() throws IOException { // Build a Wayang plan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.readWrite(WayangPlans.FILE_SOME_LINES_TXT, collector); @@ -74,11 +75,11 @@ public void testReadAndWrite() throws URISyntaxException, IOException { // Verify the plan result. final List lines = Files.lines(Paths.get(WayangPlans.FILE_SOME_LINES_TXT)).collect(Collectors.toList()); - Assert.assertEquals(lines, collector); + assertEquals(lines, collector); } @Test - public void testReadAndTransformAndWrite() throws URISyntaxException { + void testReadAndTransformAndWrite() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); @@ -89,57 +90,41 @@ public void testReadAndTransformAndWrite() throws URISyntaxException { wayangContext.execute(wayangPlan); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration1() throws URISyntaxException { - // Build a Wayang plan. + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration1() { final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); - // ILLEGAL: This platform is not registered, so this operator will find no implementation. wayangPlan.getSinks().forEach(sink -> sink.addTargetPlatform(MyMadeUpPlatform.getInstance())); - - // Instantiate Wayang and activate the Java backend. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); - - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); - - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); + assertThrows(WayangException.class, () -> + // Have Wayang execute the plan. + wayangContext.execute(wayangPlan)); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration2() throws URISyntaxException { - // Build a Wayang plan. + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration2() { final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); - WayangContext wayangContext = new WayangContext(); - // ILLEGAL: This dummy platform is not sufficient to execute the plan. wayangContext.register(MyMadeUpPlatform.getInstance()); - - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); + assertThrows(WayangException.class, () -> + // Have Wayang execute the plan. + wayangContext.execute(wayangPlan)); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration3() throws URISyntaxException { - // Build a Wayang plan. + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration3() { final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); - - // Instantiate Wayang and activate the Java backend. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); - - // Have Wayang execute the plan. final Job job = wayangContext.createJob(null, wayangPlan); - // ILLEGAL: We blacklist the Java platform, although we need it. job.getConfiguration().getPlatformProvider().addToBlacklist(Java.platform()); job.getConfiguration().getPlatformProvider().addToWhitelist(MyMadeUpPlatform.getInstance()); - job.execute(); + assertThrows(WayangException.class, job::execute); } @Test - public void testMultiSourceAndMultiSink() throws URISyntaxException { + void testMultiSourceAndMultiSink() { // Define some input data. - final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); - final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); + final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); + final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); List collector1 = new LinkedList<>(); List collector2 = new LinkedList<>(); final WayangPlan wayangPlan = WayangPlans.multiSourceMultiSink(collection1, collection2, collector1, collector2); @@ -160,15 +145,15 @@ public void testMultiSourceAndMultiSink() throws URISyntaxException { Collections.sort(expectedOutcome2); Collections.sort(collector1); Collections.sort(collector2); - Assert.assertEquals(expectedOutcome1, collector1); - Assert.assertEquals(expectedOutcome2, collector2); + assertEquals(expectedOutcome1, collector1); + assertEquals(expectedOutcome2, collector2); } @Test - public void testMultiSourceAndHoleAndMultiSink() throws URISyntaxException { + void testMultiSourceAndHoleAndMultiSink() { // Define some input data. - final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); - final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); + final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); + final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); List collector1 = new LinkedList<>(); List collector2 = new LinkedList<>(); final WayangPlan wayangPlan = WayangPlans.multiSourceHoleMultiSink(collection1, collection2, collector1, collector2); @@ -181,17 +166,15 @@ public void testMultiSourceAndHoleAndMultiSink() throws URISyntaxException { // Check the results in both sinks. List expectedOutcome = Stream.concat(collection1.stream(), collection2.stream()) - .flatMap(string -> Arrays.asList(string.toLowerCase(), string.toUpperCase()).stream()) - .collect(Collectors.toList()); - Collections.sort(expectedOutcome); + .flatMap(string -> Stream.of(string.toLowerCase(), string.toUpperCase())).sorted().collect(Collectors.toList()); Collections.sort(collector1); Collections.sort(collector2); - Assert.assertEquals(expectedOutcome, collector1); - Assert.assertEquals(expectedOutcome, collector2); + assertEquals(expectedOutcome, collector1); + assertEquals(expectedOutcome, collector2); } @Test - public void testGlobalMaterializedGroup() throws URISyntaxException { + void testGlobalMaterializedGroup() { // Build the WayangPlan. List> collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.globalMaterializedGroup(collector, 1, 2, 3); @@ -201,12 +184,12 @@ public void testGlobalMaterializedGroup() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(1, collector.size()); - Assert.assertEquals(WayangCollections.asSet(1, 2, 3), WayangCollections.asCollection(collector.get(0), HashSet::new)); + assertEquals(1, collector.size()); + assertEquals(WayangCollections.asSet(1, 2, 3), WayangCollections.asCollection(collector.get(0), HashSet::new)); } @Test - public void testIntersect() throws URISyntaxException { + void testIntersect() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.intersectSquares(collector, 0, 1, 2, 3, 3, -1, -1, -2, -3, -3, -4); @@ -217,11 +200,11 @@ public void testIntersect() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(WayangCollections.asSet(1, 4, 9), WayangCollections.asSet(collector)); + assertEquals(WayangCollections.asSet(1, 4, 9), WayangCollections.asSet(collector)); } @Test - public void testRepeat() { + void testRepeat() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.repeat(collector, 5, 0, 10, 20, 30, 45); @@ -232,12 +215,12 @@ public void testRepeat() { wayangContext.execute(wayangPlan); - Assert.assertEquals(5, collector.size()); - Assert.assertEquals(WayangCollections.asSet(5, 15, 25, 35, 50), WayangCollections.asSet(collector)); + assertEquals(5, collector.size()); + assertEquals(WayangCollections.asSet(5, 15, 25, 35, 50), WayangCollections.asSet(collector)); } @Test - public void testPageRankWithGraphBasic() { + void testPageRankWithGraphBasic() { // Build the WayangPlan. List> edges = Arrays.asList( new Tuple2<>(0L, 1L), @@ -260,14 +243,14 @@ public void testPageRankWithGraphBasic() { // Check the results. pageRanks.sort((r1, r2) -> Float.compare(r2.getField1(), r1.getField1())); final List vertexOrder = pageRanks.stream().map(Tuple2::getField0).collect(Collectors.toList()); - Assert.assertEquals( + assertEquals( Arrays.asList(3L, 0L, 2L, 1L), vertexOrder ); } @Test - public void testPageRankWithJavaGraph() { + void testPageRankWithJavaGraph() { // Build the WayangPlan. List> edges = Arrays.asList( new Tuple2<>(0L, 1L), @@ -290,28 +273,28 @@ public void testPageRankWithJavaGraph() { // Check the results. pageRanks.sort((r1, r2) -> Float.compare(r2.getField1(), r1.getField1())); final List vertexOrder = pageRanks.stream().map(Tuple2::getField0).collect(Collectors.toList()); - Assert.assertEquals( + assertEquals( Arrays.asList(3L, 0L, 2L, 1L), vertexOrder ); } @Test - public void testMapPartitions() throws URISyntaxException { + void testMapPartitions() { // Instantiate Wayang and activate the Java backend. WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); // Execute the Wayang plan. final Collection> result = WayangPlans.mapPartitions(wayangContext, 0, 1, 1, 3, 3, 4, 4, 5, 5, 6); - Assert.assertEquals( + assertEquals( WayangCollections.asSet(new Tuple2<>("even", 4), new Tuple2<>("odd", 6)), WayangCollections.asSet(result) ); } @Test - public void testZipWithId() throws URISyntaxException { + void testZipWithId() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.zipWithId(collector, 0, 10, 20, 30, 30); @@ -321,12 +304,12 @@ public void testZipWithId() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(1, collector.size()); - Assert.assertEquals(Long.valueOf(5L), collector.get(0)); + assertEquals(1, collector.size()); + assertEquals(Long.valueOf(5L), collector.get(0)); } @Test - public void testDiverseScenario1() throws URISyntaxException { + void testDiverseScenario1() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario1(WayangPlans.FILE_SOME_LINES_TXT); @@ -338,7 +321,7 @@ public void testDiverseScenario1() throws URISyntaxException { } @Test - public void testDiverseScenario2() throws URISyntaxException { + void testDiverseScenario2() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario2(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -349,7 +332,7 @@ public void testDiverseScenario2() throws URISyntaxException { } @Test - public void testDiverseScenario3() throws URISyntaxException { + void testDiverseScenario3() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario3(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -360,7 +343,7 @@ public void testDiverseScenario3() throws URISyntaxException { } @Test - public void testDiverseScenario4() throws URISyntaxException { + void testDiverseScenario4() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario4(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -371,7 +354,7 @@ public void testDiverseScenario4() throws URISyntaxException { } @Test - public void testSimpleLoop() throws URISyntaxException { + void testSimpleLoop() { // Build the WayangPlan. final List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.simpleLoop(3, collector, 0, 1, 2); @@ -384,7 +367,7 @@ public void testSimpleLoop() throws URISyntaxException { } @Test - public void testSample() throws URISyntaxException { + void testSample() { // Build the WayangPlan. final List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.simpleSample(3, collector, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); @@ -397,7 +380,7 @@ public void testSample() throws URISyntaxException { } @Test - public void testLargerSample() throws URISyntaxException { + void testLargerSample() { // Build the WayangPlan. final List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.simpleSample(15, collector, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); @@ -410,22 +393,22 @@ public void testLargerSample() throws URISyntaxException { } @Test - public void testCurrentIterationNumber() { + void testCurrentIterationNumber() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); final Collection result = WayangPlans.loopWithIterationNumber(wayangContext, 15, 5, -1, 1, 5); int expectedOffset = 5 * 4 / 2; - Assert.assertEquals( + assertEquals( WayangCollections.asSet(-1 + expectedOffset, 1 + expectedOffset, 5 + expectedOffset), WayangCollections.asSet(result) ); } @Test - public void testCurrentIterationNumberWithTooFewExpectedIterations() { + void testCurrentIterationNumberWithTooFewExpectedIterations() { WayangContext wayangContext = new WayangContext().with(Java.basicPlugin()); final Collection result = WayangPlans.loopWithIterationNumber(wayangContext, 15, 2, -1, 1, 5); int expectedOffset = 5 * 4 / 2; - Assert.assertEquals( + assertEquals( WayangCollections.asSet(-1 + expectedOffset, 1 + expectedOffset, 5 + expectedOffset), WayangCollections.asSet(result) ); @@ -433,7 +416,7 @@ public void testCurrentIterationNumberWithTooFewExpectedIterations() { @Test - public void testBroadcasts() { + void testBroadcasts() { Collection broadcastedValues = Arrays.asList(1, 2, 3, 4); Collection mainValues = Arrays.asList(2, 4, 6, 2); List collectedValues = new ArrayList<>(); @@ -446,13 +429,13 @@ public void testBroadcasts() { integerDataSetType); FilterOperator semijoin = new FilterOperator<>( integerDataSetType, - new PredicateDescriptor.ExtendedSerializablePredicate() { + new PredicateDescriptor.ExtendedSerializablePredicate<>() { private Set allowedInts; @Override public void open(ExecutionContext ctx) { - this.allowedInts = new HashSet<>(ctx.getBroadcast("allowed values")); + this.allowedInts = new HashSet<>(ctx.getBroadcast("allowed values")); } @Override @@ -476,12 +459,12 @@ public boolean test(Integer integer) { wayangContext.execute(wayangPlan); Collections.sort(collectedValues); - Assert.assertEquals(expectedValues, collectedValues); + assertEquals(expectedValues, collectedValues); } @Test - public void testBroadcasts2() { - Collection broadcastedValues = Arrays.asList(9); + void testBroadcasts2() { + Collection broadcastedValues = List.of(9); Collection mainValues = Arrays.asList(2, 4, 6, 2); List collectedValues = new ArrayList<>(); List expectedValues = Arrays.asList(18, 18, 36, 54); @@ -493,13 +476,13 @@ public void testBroadcasts2() { integerDataSetType); MapOperator mulitply = new MapOperator<>( new TransformationDescriptor<>( - new FunctionDescriptor.ExtendedSerializableFunction() { + new FunctionDescriptor.ExtendedSerializableFunction<>() { private int coefficient; @Override public void open(ExecutionContext ctx) { - final Collection broadcast = ctx.getBroadcast("allowed values"); + final Collection broadcast = ctx.getBroadcast("allowed values"); this.coefficient = broadcast.stream().findAny().get(); } @@ -528,6 +511,6 @@ public Integer apply(Integer integer) { wayangContext.execute(wayangPlan); Collections.sort(collectedValues); - Assert.assertEquals(expectedValues, collectedValues); + assertEquals(expectedValues, collectedValues); } } diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/PostgresIntegrationIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/PostgresIntegrationIT.java index 721f27b21..a73d25ea0 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/PostgresIntegrationIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/PostgresIntegrationIT.java @@ -18,27 +18,26 @@ package org.apache.wayang.tests; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; import org.apache.wayang.core.api.exception.WayangException; import org.apache.wayang.postgres.platform.PostgresPlatform; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; - /** * Test the Postgres integration with Wayang. */ -@Ignore("Requires specific PostgreSQL installation.") -public class PostgresIntegrationIT { +@Disabled("Requires specific PostgreSQL installation.") +class PostgresIntegrationIT { private static final PostgresPlatform pg = PostgresPlatform.getInstance(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { Statement stmt = null; @@ -62,8 +61,8 @@ public static void setup() { } } - @AfterClass - public static void tearDown() { + @AfterAll + static void tearDown() { Statement stmt = null; try { diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/RegressionIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/RegressionIT.java index 59b48cd41..8edec98df 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/RegressionIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/RegressionIT.java @@ -18,8 +18,6 @@ package org.apache.wayang.tests; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.api.JavaPlanBuilder; import org.apache.wayang.api.LoadCollectionDataQuantaBuilder; import org.apache.wayang.api.MapDataQuantaBuilder; @@ -27,21 +25,24 @@ import org.apache.wayang.core.util.WayangArrays; import org.apache.wayang.java.Java; import org.apache.wayang.spark.Spark; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * This class hosts and documents some tests for bugs that we encountered. Ultimately, we want to avoid re-introducing * already encountered and fixed bugs. */ -public class RegressionIT { +class RegressionIT { /** * This plan revealed an issue with the {@link org.apache.wayang.core.optimizer.channels.ChannelConversionGraph.ShortestTreeSearcher}. */ @Test - public void testCollectionToRddAndBroadcast() { + void testCollectionToRddAndBroadcast() { WayangContext wayangContext = new WayangContext().with(Spark.basicPlugin()).with(Java.basicPlugin()); JavaPlanBuilder planBuilder = new JavaPlanBuilder(wayangContext, "testCollectionToRddAndBroadcast"); @@ -64,7 +65,7 @@ public void testCollectionToRddAndBroadcast() { ArrayList result = new ArrayList<>(map1.union(map2).collect()); result.sort(Integer::compareTo); - Assert.assertEquals( + assertEquals( WayangArrays.asList(-1, 1, 2, 3), result ); diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/SparkIntegrationIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/SparkIntegrationIT.java index a6c4a2035..03f2acc99 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/SparkIntegrationIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/SparkIntegrationIT.java @@ -37,29 +37,26 @@ import org.apache.wayang.java.Java; import org.apache.wayang.spark.Spark; import org.apache.wayang.tests.platform.MyMadeUpPlatform; -import org.junit.Assert; -import org.junit.Test; - - - - +import org.junit.jupiter.api.Test; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test the Spark integration with Wayang. */ -public class SparkIntegrationIT { +class SparkIntegrationIT { @Test - public void testReadAndWrite() throws URISyntaxException, IOException { + void testReadAndWrite() throws IOException { // Build a Wayang plan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.readWrite(WayangPlans.FILE_SOME_LINES_TXT, collector); @@ -72,11 +69,11 @@ public void testReadAndWrite() throws URISyntaxException, IOException { // Verify the plan result. final List lines = Files.lines(Paths.get(WayangPlans.FILE_SOME_LINES_TXT)).collect(Collectors.toList()); - Assert.assertEquals(lines, collector); + assertEquals(lines, collector); } @Test - public void testReadAndTransformAndWrite() throws URISyntaxException { + void testReadAndTransformAndWrite() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); @@ -87,8 +84,8 @@ public void testReadAndTransformAndWrite() throws URISyntaxException { wayangContext.execute(wayangPlan); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration1() throws URISyntaxException { + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration1() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); // ILLEGAL: This platform is not registered, so this operator will find no implementation. @@ -97,29 +94,26 @@ public void testReadAndTransformAndWriteWithIllegalConfiguration1() throws URISy // Instantiate Wayang and activate the Spark backend. WayangContext wayangContext = new WayangContext().with(Spark.basicPlugin()); - - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); - - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); + assertThrows(WayangException.class, () -> + // Have Wayang execute the plan. + wayangContext.execute(wayangPlan)); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration2() throws URISyntaxException { + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration2() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); WayangContext wayangContext = new WayangContext(); // ILLEGAL: This dummy platform is not sufficient to execute the plan. wayangContext.register(MyMadeUpPlatform.getInstance()); - - // Have Wayang execute the plan. - wayangContext.execute(wayangPlan); + assertThrows(WayangException.class, () -> + // Have Wayang execute the plan. + wayangContext.execute(wayangPlan)); } - @Test(expected = WayangException.class) - public void testReadAndTransformAndWriteWithIllegalConfiguration3() throws URISyntaxException { + @Test + void testReadAndTransformAndWriteWithIllegalConfiguration3() { // Build a Wayang plan. final WayangPlan wayangPlan = WayangPlans.readTransformWrite(WayangPlans.FILE_SOME_LINES_TXT); @@ -131,11 +125,11 @@ public void testReadAndTransformAndWriteWithIllegalConfiguration3() throws URISy // ILLEGAL: We blacklist the Spark platform, although we need it. job.getConfiguration().getPlatformProvider().addToBlacklist(Spark.platform()); job.getConfiguration().getPlatformProvider().addToWhitelist(MyMadeUpPlatform.getInstance()); - job.execute(); + assertThrows(WayangException.class, job::execute); } @Test - public void testMultiSourceAndMultiSink() throws URISyntaxException { + void testMultiSourceAndMultiSink() { // Define some input data. final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); @@ -159,12 +153,12 @@ public void testMultiSourceAndMultiSink() throws URISyntaxException { Collections.sort(expectedOutcome2); Collections.sort(collector1); Collections.sort(collector2); - Assert.assertEquals(expectedOutcome1, collector1); - Assert.assertEquals(expectedOutcome2, collector2); + assertEquals(expectedOutcome1, collector1); + assertEquals(expectedOutcome2, collector2); } @Test - public void testMultiSourceAndHoleAndMultiSink() throws URISyntaxException { + void testMultiSourceAndHoleAndMultiSink() { // Define some input data. final List collection1 = Arrays.asList("This is source 1.", "This is source 1, too."); final List collection2 = Arrays.asList("This is source 2.", "This is source 2, too."); @@ -180,17 +174,15 @@ public void testMultiSourceAndHoleAndMultiSink() throws URISyntaxException { // Check the results in both sinks. List expectedOutcome = Stream.concat(collection1.stream(), collection2.stream()) - .flatMap(string -> Arrays.asList(string.toLowerCase(), string.toUpperCase()).stream()) - .collect(Collectors.toList()); - Collections.sort(expectedOutcome); + .flatMap(string -> Stream.of(string.toLowerCase(), string.toUpperCase())).sorted().collect(Collectors.toList()); Collections.sort(collector1); Collections.sort(collector2); - Assert.assertEquals(expectedOutcome, collector1); - Assert.assertEquals(expectedOutcome, collector2); + assertEquals(expectedOutcome, collector1); + assertEquals(expectedOutcome, collector2); } @Test - public void testGlobalMaterializedGroup() throws URISyntaxException { + void testGlobalMaterializedGroup() { // Build the WayangPlan. List> collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.globalMaterializedGroup(collector, 1, 2, 3); @@ -200,12 +192,12 @@ public void testGlobalMaterializedGroup() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(1, collector.size()); - Assert.assertEquals(WayangCollections.asSet(1, 2, 3), WayangCollections.asCollection(collector.get(0), HashSet::new)); + assertEquals(1, collector.size()); + assertEquals(WayangCollections.asSet(1, 2, 3), WayangCollections.asCollection(collector.get(0), HashSet::new)); } @Test - public void testIntersect() throws URISyntaxException { + void testIntersect() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.intersectSquares(collector, 0, 1, 2, 3, 3, -1, -1, -2, -3, -3, -4); @@ -215,11 +207,11 @@ public void testIntersect() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(WayangCollections.asSet(1, 4, 9), WayangCollections.asSet(collector)); + assertEquals(WayangCollections.asSet(1, 4, 9), WayangCollections.asSet(collector)); } @Test - public void testRepeat() { + void testRepeat() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.repeat(collector, 5, 0, 10, 20, 30, 45); @@ -230,12 +222,12 @@ public void testRepeat() { wayangContext.execute(wayangPlan); - Assert.assertEquals(5, collector.size()); - Assert.assertEquals(WayangCollections.asSet(5, 15, 25, 35, 50), WayangCollections.asSet(collector)); + assertEquals(5, collector.size()); + assertEquals(WayangCollections.asSet(5, 15, 25, 35, 50), WayangCollections.asSet(collector)); } @Test - public void testPageRankWithGraphBasic() { + void testPageRankWithGraphBasic() { // Build the WayangPlan. List> edges = Arrays.asList( new Tuple2<>(0L, 1L), @@ -258,7 +250,7 @@ public void testPageRankWithGraphBasic() { // Check the results. pageRanks.sort((r1, r2) -> Float.compare(r2.getField1(), r1.getField1())); final List vertexOrder = pageRanks.stream().map(Tuple2::getField0).collect(Collectors.toList()); - Assert.assertEquals( + assertEquals( Arrays.asList(3L, 0L, 2L, 1L), vertexOrder ); @@ -266,7 +258,7 @@ public void testPageRankWithGraphBasic() { @Test - public void testPageRankWithSparkGraph() { + void testPageRankWithSparkGraph() { // Build the WayangPlan. List> edges = Arrays.asList( new Tuple2<>(0L, 1L), @@ -289,28 +281,28 @@ public void testPageRankWithSparkGraph() { // Check the results. pageRanks.sort((r1, r2) -> Float.compare(r2.getField1(), r1.getField1())); final List vertexOrder = pageRanks.stream().map(Tuple2::getField0).collect(Collectors.toList()); - Assert.assertEquals( + assertEquals( Arrays.asList(3L, 0L, 2L, 1L), vertexOrder ); } @Test - public void testMapPartitions() throws URISyntaxException { + void testMapPartitions() { // Instantiate Wayang and activate the Java backend. WayangContext wayangContext = new WayangContext().with(Spark.basicPlugin()); // Execute the Wayang plan. final Collection> result = WayangPlans.mapPartitions(wayangContext, 0, 1, 1, 3, 3, 4, 4, 5, 5, 6); - Assert.assertEquals( + assertEquals( WayangCollections.asSet(new Tuple2<>("even", 4), new Tuple2<>("odd", 6)), WayangCollections.asSet(result) ); } @Test - public void testZipWithId() throws URISyntaxException { + void testZipWithId() { // Build the WayangPlan. List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.zipWithId(collector, 0, 10, 20, 30, 30); @@ -320,12 +312,12 @@ public void testZipWithId() throws URISyntaxException { wayangContext.execute(wayangPlan); - Assert.assertEquals(1, collector.size()); - Assert.assertEquals(Long.valueOf(5L), collector.get(0)); + assertEquals(1, collector.size()); + assertEquals(Long.valueOf(5L), collector.get(0)); } @Test - public void testDiverseScenario1() throws URISyntaxException { + void testDiverseScenario1() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario1(WayangPlans.FILE_SOME_LINES_TXT); @@ -336,7 +328,7 @@ public void testDiverseScenario1() throws URISyntaxException { } @Test - public void testDiverseScenario2() throws URISyntaxException { + void testDiverseScenario2() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario2(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -347,7 +339,7 @@ public void testDiverseScenario2() throws URISyntaxException { } @Test - public void testDiverseScenario3() throws URISyntaxException { + void testDiverseScenario3() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario3(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -358,7 +350,7 @@ public void testDiverseScenario3() throws URISyntaxException { } @Test - public void testDiverseScenario4() throws URISyntaxException { + void testDiverseScenario4() { // Build the WayangPlan. WayangPlan wayangPlan = WayangPlans.diverseScenario4(WayangPlans.FILE_SOME_LINES_TXT, WayangPlans.FILE_OTHER_LINES_TXT); @@ -369,7 +361,7 @@ public void testDiverseScenario4() throws URISyntaxException { } @Test - public void testSimpleLoop() throws URISyntaxException { + void testSimpleLoop() { // Build the WayangPlan. final List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.simpleLoop(3, collector, 0, 1, 2); @@ -382,7 +374,7 @@ public void testSimpleLoop() throws URISyntaxException { } @Test - public void testSample() throws URISyntaxException { + void testSample() { // Build the WayangPlan. final List collector = new LinkedList<>(); WayangPlan wayangPlan = WayangPlans.simpleSample(3, collector, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); @@ -395,7 +387,7 @@ public void testSample() throws URISyntaxException { } @Test - public void testSampleInLoop() { + void testSampleInLoop() { final List collector = new ArrayList<>(); WayangPlan wayangPlan = WayangPlans.sampleInLoop(2, 10, collector, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); @@ -408,29 +400,29 @@ public void testSampleInLoop() { } @Test - public void testCurrentIterationNumber() { + void testCurrentIterationNumber() { WayangContext wayangContext = new WayangContext().with(Spark.basicPlugin()); final Collection result = WayangPlans.loopWithIterationNumber(wayangContext, 15, 5, -1, 1, 5); int expectedOffset = 10; - Assert.assertEquals( + assertEquals( WayangCollections.asSet(-1 + expectedOffset, 1 + expectedOffset, 5 + expectedOffset), WayangCollections.asSet(result) ); } @Test - public void testCurrentIterationNumberWithTooFewExpectedIterations() { + void testCurrentIterationNumberWithTooFewExpectedIterations() { WayangContext wayangContext = new WayangContext().with(Spark.basicPlugin()); final Collection result = WayangPlans.loopWithIterationNumber(wayangContext, 15, 2, -1, 1, 5); int expectedOffset = 10; - Assert.assertEquals( + assertEquals( WayangCollections.asSet(-1 + expectedOffset, 1 + expectedOffset, 5 + expectedOffset), WayangCollections.asSet(result) ); } @Test - public void testBroadcasts() { + void testBroadcasts() { Collection broadcastedValues = Arrays.asList(1, 2, 3, 4); Collection mainValues = Arrays.asList(2, 4, 6, 2); List collectedValues = new ArrayList<>(); @@ -455,11 +447,11 @@ public void testBroadcasts() { wayangContext.execute(wayangPlan); Collections.sort(collectedValues); - Assert.assertEquals(expectedValues, collectedValues); + assertEquals(expectedValues, collectedValues); } @Test - public void testLogisticRegressionOperator() { + void testLogisticRegressionOperator() { CollectionSource xSource = new CollectionSource<>( Arrays.asList( new double[]{0.0, 1.0}, @@ -495,14 +487,14 @@ public void testLogisticRegressionOperator() { context.execute(plan); - Assert.assertEquals(4, results.size()); + assertEquals(4, results.size()); for (double pred : results) { - Assert.assertTrue(pred == 0.0 || pred == 1.0); + assertTrue(pred == 0.0 || pred == 1.0); } } @Test - public void testLogisticRegressionWithAPI() { + void testLogisticRegressionWithAPI() { WayangContext context = new WayangContext() .with(Spark.basicPlugin()) .with(Spark.mlPlugin()); @@ -544,7 +536,7 @@ public void testLogisticRegressionWithAPI() { } } @Test - public void testDecisionTreeRegressionWithAPI() { + void testDecisionTreeRegressionWithAPI() { WayangContext context = new WayangContext() .with(Spark.basicPlugin()) .with(Spark.mlPlugin()); @@ -584,7 +576,7 @@ public void testDecisionTreeRegressionWithAPI() { @Test - public void testKMeans() { + void testKMeans() { CollectionSource collectionSource = new CollectionSource<>( Arrays.asList( new double[]{1, 2, 3}, @@ -618,8 +610,8 @@ public void testKMeans() { wayangContext.execute(wayangPlan); // Verify the outcome. - Assert.assertEquals(3, results.size()); - Assert.assertEquals( + assertEquals(3, results.size()); + assertEquals( results.get(0), results.get(2) ); diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIntegrationIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIntegrationIT.java index 91c07f3f4..bad5b27d0 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIntegrationIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIntegrationIT.java @@ -30,8 +30,7 @@ import org.apache.wayang.core.plan.wayangplan.WayangPlan; import org.apache.wayang.java.Java; import org.apache.wayang.tensorflow.Tensorflow; -import org.junit.Test; -import org.junit.Ignore; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; @@ -69,7 +68,7 @@ public class TensorflowIntegrationIT { public static String[] LABELS = new String[]{"Iris-setosa", "Iris-versicolor", "Iris-virginica"}; @Test - public void test() { + void test() { /* training features */ CollectionSource trainXSource = new CollectionSource<>(trainX, float[].class); diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisIT.java index f8c08b75c..05b3af741 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisIT.java @@ -32,8 +32,8 @@ import org.apache.wayang.core.util.Tuple; import org.apache.wayang.java.Java; import org.apache.wayang.tensorflow.Tensorflow; -import org.junit.Test; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.net.URI; import java.net.URISyntaxException; @@ -46,7 +46,7 @@ * Test the Tensorflow integration with Wayang. * Note: this test fails on M1 Macs because of Tensorflow-Java incompatibility. */ -public class TensorflowIrisIT { +class TensorflowIrisIT { public static URI TRAIN_PATH = createUri("/iris_train.csv"); public static URI TEST_PATH = createUri("/iris_test.csv"); @@ -57,8 +57,9 @@ public class TensorflowIrisIT { "Iris-virginica", 2 ); - @Ignore - public void test() { + @Disabled + @Test + void test() { final Tuple trainSource = fileOperation(TRAIN_PATH, true); final Tuple testSource = fileOperation(TEST_PATH, false); diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisScalaLikeApiIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisScalaLikeApiIT.java index d7da2ca7d..0015d1a5f 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisScalaLikeApiIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisScalaLikeApiIT.java @@ -31,7 +31,7 @@ import org.apache.wayang.core.util.Tuple; import org.apache.wayang.java.Java; import org.apache.wayang.tensorflow.Tensorflow; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.net.URISyntaxException; @@ -56,7 +56,7 @@ public class TensorflowIrisScalaLikeApiIT { ); @Test - public void test() { + void test() { WayangContext wayangContext = new WayangContext() .with(Java.basicPlugin()) .with(Tensorflow.plugin()); diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WayangPlans.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WayangPlans.java index 6792e2064..b0d6e26a9 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WayangPlans.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WayangPlans.java @@ -248,7 +248,7 @@ public static WayangPlan diverseScenario1(URI inputFileUri) { * Then, they are unioned in a {@link UnionAllOperator}, go through a {@link SortOperator}, a {@link MapOperator} * (applies {@link String#toUpperCase()}), {@link DistinctOperator}, and finally a {@link LocalCallbackSink} (stdout). */ - public static WayangPlan diverseScenario2(URI inputFileUri1, URI inputFileUri2) throws URISyntaxException { + public static WayangPlan diverseScenario2(URI inputFileUri1, URI inputFileUri2) { // Build a Wayang plan. TextFileSource textFileSource1 = new TextFileSource(inputFileUri1.toString()); TextFileSource textFileSource2 = new TextFileSource(inputFileUri2.toString()); @@ -278,8 +278,7 @@ public static WayangPlan diverseScenario2(URI inputFileUri1, URI inputFileUri2) * then {@code k} times map each value to {@code 2n} and {@code 2n+1}. Finally, the outcome of the loop is * collected in the {@code collector}. */ - public static WayangPlan simpleLoop(final int numIterations, Collection collector, final int... values) - throws URISyntaxException { + public static WayangPlan simpleLoop(final int numIterations, Collection collector, final int... values) { CollectionSource source = new CollectionSource<>(WayangArrays.asList(values), Integer.class); source.setName("source"); @@ -370,8 +369,7 @@ public Integer apply(Integer integer) { * Creates a {@link WayangPlan} with a {@link CollectionSource} that is fed into a {@link SampleOperator}. It will * then map each value to its double and output the results in the {@code collector}. */ - public static WayangPlan simpleSample(int sampleSize, Collection collector, final int... values) - throws URISyntaxException { + public static WayangPlan simpleSample(int sampleSize, Collection collector, final int... values) { CollectionSource source = new CollectionSource<>(WayangArrays.asList(values), Integer.class); source.setName("source"); @@ -440,8 +438,7 @@ public static WayangPlan sampleInLoop(int sampleSize, int iterations, Collection * Creates a {@link WayangPlan} with a {@link CollectionSource} that is fed into a {@link GlobalMaterializedGroupOperator}. * It will then push the results in the {@code collector}. */ - public static WayangPlan globalMaterializedGroup(Collection> collector, final int... values) - throws URISyntaxException { + public static WayangPlan globalMaterializedGroup(Collection> collector, final int... values) { CollectionSource source = new CollectionSource<>(WayangArrays.asList(values), Integer.class); source.setName("source"); @@ -499,8 +496,7 @@ public static WayangPlan repeat(Collection collector, int numIterations * Creates a {@link WayangPlan} with a {@link CollectionSource} that is fed into a {@link ZipWithIdOperator}. * It will then push the results in the {@code collector}. */ - public static WayangPlan zipWithId(Collection collector, final int... values) - throws URISyntaxException { + public static WayangPlan zipWithId(Collection collector, final int... values) { CollectionSource source = new CollectionSource<>(WayangArrays.asList(values), Integer.class); source.setName("source"); @@ -540,8 +536,7 @@ public static WayangPlan zipWithId(Collection collector, final int... valu * non-negative. Then, their squares are intersected using the {@link IntersectOperator}. The result is * pushed to the {@code collector}. */ - public static WayangPlan intersectSquares(Collection collector, final int... values) - throws URISyntaxException { + public static WayangPlan intersectSquares(Collection collector, final int... values) { CollectionSource source = new CollectionSource<>(WayangArrays.asList(values), Integer.class); source.setName("source"); @@ -653,7 +648,7 @@ public static WayangPlan pageRankWithDictionaryCompression(Collection, Tuple2> translate = new MapOperator<>( new TransformationDescriptor<>( - new FunctionDescriptor.ExtendedSerializableFunction, Tuple2>() { + new FunctionDescriptor.ExtendedSerializableFunction<>() { private Map dictionary; @@ -684,7 +679,7 @@ public Tuple2 apply(Tuple2 in) { // Back-translate the page ranks. MapOperator, Tuple2> backtranslate = new MapOperator<>( new TransformationDescriptor<>( - new FunctionDescriptor.ExtendedSerializableFunction, Tuple2>() { + new FunctionDescriptor.ExtendedSerializableFunction<>() { private Map dictionary; @@ -709,7 +704,7 @@ public Tuple2 apply(Tuple2 in) { LocalCallbackSink callbackSink = LocalCallbackSink.createCollectingSink( pageRankCollector, - DataSetType.>createDefaultUnchecked(Tuple2.class) + DataSetType.createDefaultUnchecked(Tuple2.class) ); callbackSink.setName("sink"); backtranslate.connectTo(0, callbackSink, 0); @@ -724,9 +719,9 @@ public static Map pageRankWithDictionaryCompressionSolution() .map( line -> { String[] parts = line.split(" "); - return new Tuple2( - parts[0].charAt(0), - Float.parseFloat(parts[1]) + return new Tuple2<>( + parts[0].charAt(0), + Float.parseFloat(parts[1]) ); } ) @@ -798,7 +793,7 @@ public static Collection> mapPartitions(WayangContext wa /** * Same as scenarion2 but repeat 10 times before output. */ - public static WayangPlan diverseScenario3(URI inputFileUri1, URI inputFileUri2) throws URISyntaxException { + public static WayangPlan diverseScenario3(URI inputFileUri1, URI inputFileUri2) { // Build a Wayang plan. TextFileSource textFileSource1 = new TextFileSource(inputFileUri1.toString()); textFileSource1.setName("Source 1"); @@ -859,7 +854,7 @@ public static String concat9(String k) { /** * Simple counter loop . */ - public static WayangPlan diverseScenario4(URI inputFileUri1, URI inputFileUri2) throws URISyntaxException { + public static WayangPlan diverseScenario4(URI inputFileUri1, URI inputFileUri2) { // Build a Wayang plan. TextFileSource textFileSource1 = new TextFileSource(inputFileUri1.toString()); textFileSource1.setName("file1"); diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WayangPlansOperators.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WayangPlansOperators.java index 1dc5179d4..f47958680 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WayangPlansOperators.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WayangPlansOperators.java @@ -55,7 +55,7 @@ public static WayangPlan cartesian(URI inputFileUri1, URI inputFileUri2, List cartesianOperator = new CartesianOperator(String.class, String.class); + CartesianOperator cartesianOperator = new CartesianOperator<>(String.class, String.class); LocalCallbackSink> sink = LocalCallbackSink.createCollectingSink(collector, ReflectionUtils.specify(Tuple2.class)); @@ -76,13 +76,13 @@ public static WayangPlan coGroup(URI inputFileUri1, URI inputFileUri2, List(split[0], Integer.parseInt(split[1])); }; - MapOperator> mapOperator1 = new MapOperator>( + MapOperator> mapOperator1 = new MapOperator<>( mapFunction, String.class, ReflectionUtils.specify(Tuple2.class) ); - MapOperator> mapOperator2 = new MapOperator>( + MapOperator> mapOperator2 = new MapOperator<>( mapFunction, String.class, ReflectionUtils.specify(Tuple2.class) @@ -90,9 +90,7 @@ public static WayangPlan coGroup(URI inputFileUri1, URI inputFileUri2, List, String> keyExtractor = - element -> { - return element.field0; - }; + element -> element.field0; CoGroupOperator, Tuple2, String> coGroupOperator = new CoGroupOperator<>( @@ -116,7 +114,7 @@ public static WayangPlan coGroup(URI inputFileUri1, URI inputFileUri2, List source, Collection collector){ - CollectionSource colSource = new CollectionSource(source, String.class); + CollectionSource colSource = new CollectionSource<>(source, String.class); LocalCallbackSink sink = LocalCallbackSink.createCollectingSink(collector, String.class); @@ -126,9 +124,9 @@ public static WayangPlan collectionSourceOperator(Collection source, Col } public static WayangPlan count(Collection source, Collection collector){ - CollectionSource colSource = new CollectionSource(source, String.class); + CollectionSource colSource = new CollectionSource<>(source, String.class); - CountOperator countOperator = new CountOperator(String.class); + CountOperator countOperator = new CountOperator<>(String.class); LocalCallbackSink sink = LocalCallbackSink.createCollectingSink(collector, Long.class); @@ -141,15 +139,13 @@ public static WayangPlan count(Collection source, Collection colle public static WayangPlan distinct(URI inputFileUri1, Collection collector){ TextFileSource source = new TextFileSource(inputFileUri1.toString()); - MapOperator mapOperator = new MapOperator( - line -> { - return line.toLowerCase(); - }, + MapOperator mapOperator = new MapOperator<>( + String::toLowerCase, String.class, String.class ); - DistinctOperator distinctOperator = new DistinctOperator(String.class); + DistinctOperator distinctOperator = new DistinctOperator<>(String.class); LocalCallbackSink sink = LocalCallbackSink.createCollectingSink(collector, String.class); @@ -163,10 +159,8 @@ public static WayangPlan distinct(URI inputFileUri1, Collection collecto public static WayangPlan filter(URI inputFileUri1, Collection collector){ TextFileSource source = new TextFileSource(inputFileUri1.toString()); - FilterOperator filterOperator = new FilterOperator( - line -> { - return line.contains("line"); - }, + FilterOperator filterOperator = new FilterOperator<>( + line -> line.contains("line"), String.class ); @@ -181,10 +175,8 @@ public static WayangPlan filter(URI inputFileUri1, Collection collector) public static WayangPlan flatMap(URI inputFileUri1, Collection collector){ TextFileSource source = new TextFileSource(inputFileUri1.toString()); - FlatMapOperator flatMapOperator = new FlatMapOperator( - line -> { - return Arrays.asList(line.split(" ")); - }, + FlatMapOperator flatMapOperator = new FlatMapOperator<>( + line -> Arrays.asList(line.split(" ")), String.class, String.class ); @@ -208,13 +200,13 @@ public static WayangPlan join(URI inputFileUri1, URI inputFileUri2, Collection(split[0], split[1]); }; - MapOperator> mapOperator1 = new MapOperator>( + MapOperator> mapOperator1 = new MapOperator<>( mapFunction, String.class, ReflectionUtils.specify(Tuple2.class) ); - MapOperator> mapOperator2 = new MapOperator>( + MapOperator> mapOperator2 = new MapOperator<>( mapFunction, String.class, ReflectionUtils.specify(Tuple2.class) @@ -222,7 +214,7 @@ public static WayangPlan join(URI inputFileUri1, URI inputFileUri2, Collection, String> keyFunction = tuple -> tuple.field0; - JoinOperator, Tuple2, String> joinOperator = new JoinOperator, Tuple2, String>( + JoinOperator, Tuple2, String> joinOperator = new JoinOperator<>( keyFunction, keyFunction, ReflectionUtils.specify(Tuple2.class), @@ -251,7 +243,7 @@ public static WayangPlan reduceBy(URI inputFileUri1, Collection> co return new Tuple2<>(split[0], split[1]); }; - MapOperator> mapOperator = new MapOperator>( + MapOperator> mapOperator = new MapOperator<>( mapFunction, String.class, ReflectionUtils.specify(Tuple2.class) @@ -260,11 +252,9 @@ public static WayangPlan reduceBy(URI inputFileUri1, Collection> co FunctionDescriptor.SerializableFunction, String> keyFunction = tuple -> tuple.field0; - ReduceByOperator, String> reduceByOperator = new ReduceByOperator, String>( + ReduceByOperator, String> reduceByOperator = new ReduceByOperator<>( keyFunction, - (tuple, tuple2) -> { - return new Tuple2<>(tuple.field0, tuple.field1+" - "+tuple2.field1); - }, + (tuple, tuple2) -> new Tuple2<>(tuple.field0, tuple.field1 + " - " + tuple2.field1), String.class, ReflectionUtils.specify(Tuple2.class) ); @@ -282,17 +272,15 @@ public static WayangPlan sort(URI inputFileUri1, Collection collector){ TextFileSource source = new TextFileSource(inputFileUri1.toString()); FunctionDescriptor.SerializableFunction> flatMapFunction = - line -> { - return Arrays.asList(line.split(" ")); - }; + line -> Arrays.asList(line.split(" ")); - FlatMapOperator flatMapOperator = new FlatMapOperator( + FlatMapOperator flatMapOperator = new FlatMapOperator<>( flatMapFunction, String.class, String.class ); - SortOperator sortOperator = new SortOperator( + SortOperator sortOperator = new SortOperator<>( word -> word, String.class, String.class @@ -311,7 +299,7 @@ public static WayangPlan sort(URI inputFileUri1, Collection collector){ public static WayangPlan textFileSink(URI inputFileUri1, URI outputFileUri1){ TextFileSource source = new TextFileSource(inputFileUri1.toString()); - TextFileSink sink = new TextFileSink(outputFileUri1.toString(), String.class); + TextFileSink sink = new TextFileSink<>(outputFileUri1.toString(), String.class); source.connectTo(0, sink, 0); @@ -322,7 +310,7 @@ public static WayangPlan union(URI inputFileUri1, URI inputFileUri2, Collection< TextFileSource source1 = new TextFileSource(inputFileUri1.toString()); TextFileSource source2 = new TextFileSource(inputFileUri2.toString()); - UnionAllOperator unionAllOperator = new UnionAllOperator(String.class); + UnionAllOperator unionAllOperator = new UnionAllOperator<>(String.class); LocalCallbackSink sink = LocalCallbackSink.createCollectingSink(collector, String.class); @@ -336,7 +324,7 @@ public static WayangPlan union(URI inputFileUri1, URI inputFileUri2, Collection< public static WayangPlan zipWithId(URI inputFileUri1, Collection> collector){ TextFileSource source1 = new TextFileSource(inputFileUri1.toString()); - ZipWithIdOperator zipWithIdOperator = new ZipWithIdOperator(String.class); + ZipWithIdOperator zipWithIdOperator = new ZipWithIdOperator<>(String.class); LocalCallbackSink> sink = LocalCallbackSink.createCollectingSink(collector, ReflectionUtils.specify(Tuple2.class)); @@ -347,9 +335,9 @@ public static WayangPlan zipWithId(URI inputFileUri1, Collection> collector, int... inputValues) { - CollectionSource source = new CollectionSource(WayangArrays.asList(inputValues), Integer.class); + CollectionSource source = new CollectionSource<>(WayangArrays.asList(inputValues), Integer.class); - MapPartitionsOperator> mapPartition = new MapPartitionsOperator>( + MapPartitionsOperator> mapPartition = new MapPartitionsOperator<>( partition -> { int numEvens = 0, numOdds = 0; for (Integer value : partition) { @@ -367,11 +355,9 @@ public static WayangPlan mapPartitions(Collection> colle FunctionDescriptor.SerializableFunction, String> keyFunction = tuple -> tuple.field0; - ReduceByOperator, String> reduceByOperator = new ReduceByOperator, String>( + ReduceByOperator, String> reduceByOperator = new ReduceByOperator<>( keyFunction, - (t1, t2) -> { - return new Tuple2<>(t1.getField0(), t1.getField1() + t2.getField1()); - }, + (t1, t2) -> new Tuple2<>(t1.getField0(), t1.getField1() + t2.getField1()), String.class, ReflectionUtils.specify(Tuple2.class) ); diff --git a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WordCountIT.java b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WordCountIT.java index 0175ae54a..df965e3c6 100644 --- a/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WordCountIT.java +++ b/wayang-tests-integration/src/test/java/org/apache/wayang/tests/WordCountIT.java @@ -18,8 +18,6 @@ package org.apache.wayang.tests; -import org.junit.Assert; -import org.junit.Test; import org.apache.wayang.basic.data.Tuple2; import org.apache.wayang.basic.operators.FlatMapOperator; import org.apache.wayang.basic.operators.LocalCallbackSink; @@ -45,9 +43,9 @@ import org.apache.wayang.spark.operators.SparkFlatMapOperator; import org.apache.wayang.spark.operators.SparkMapOperator; import org.apache.wayang.spark.operators.SparkTextFileSource; +import org.junit.jupiter.api.Test; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -57,14 +55,17 @@ import java.util.Map; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Word count integration test. Besides going through different {@link Platform} combinations, each test addresses a different * way of specifying the target {@link Platform}s. */ -public class WordCountIT { +class WordCountIT { @Test - public void testOnJava() throws URISyntaxException, IOException { + void testOnJava() throws IOException { // Assignment mode: WayangContext. // Instantiate Wayang and activate the backend. @@ -73,7 +74,7 @@ public void testOnJava() throws URISyntaxException, IOException { // for each line (input) output an iterator of the words FlatMapOperator flatMapOperator = new FlatMapOperator<>( - new FlatMapDescriptor<>(line -> Arrays.asList((String[]) line.split(" ")), + new FlatMapDescriptor<>(line -> Arrays.asList(line.split(" ")), String.class, String.class ) @@ -86,9 +87,9 @@ public void testOnJava() throws URISyntaxException, IOException { // for each word transform it to lowercase and output a key-value pair (word, 1) MapOperator> mapOperator = new MapOperator<>( - new TransformationDescriptor<>(word -> new Tuple2(word.toLowerCase(), 1), - DataUnitType.createBasic(String.class), - DataUnitType.>createBasicUnchecked(Tuple2.class) + new TransformationDescriptor<>(word -> new Tuple2<>(word.toLowerCase(), 1), + DataUnitType.createBasic(String.class), + DataUnitType.createBasicUnchecked(Tuple2.class) ), DataSetType.createDefault(String.class), DataSetType.createDefaultUnchecked(Tuple2.class) ); @@ -145,18 +146,18 @@ public void testOnJava() throws URISyntaxException, IOException { for (Map.Entry countEntry : counter) { correctResults.add(new Tuple2<>(countEntry.getKey(), countEntry.getValue())); } - Assert.assertTrue(results.size() == correctResults.size() && results.containsAll(correctResults) && correctResults.containsAll(results)); + assertTrue(results.size() == correctResults.size() && results.containsAll(correctResults) && correctResults.containsAll(results)); } @Test - public void testOnSpark() throws URISyntaxException, IOException { + void testOnSpark() throws IOException { // Assignment mode: Job. TextFileSource textFileSource = new TextFileSource(WayangPlans.FILE_SOME_LINES_TXT.toString()); // for each line (input) output an iterator of the words FlatMapOperator flatMapOperator = new FlatMapOperator<>( - new FlatMapDescriptor<>(line -> Arrays.asList((String[]) line.split(" ")), + new FlatMapDescriptor<>(line -> Arrays.asList(line.split(" ")), String.class, String.class ) @@ -165,7 +166,7 @@ public void testOnSpark() throws URISyntaxException, IOException { // for each word transform it to lowercase and output a key-value pair (word, 1) MapOperator> mapOperator = new MapOperator<>( - new TransformationDescriptor<>(word -> new Tuple2(word.toLowerCase(), 1), + new TransformationDescriptor<>(word -> new Tuple2<>(word.toLowerCase(), 1), DataUnitType.createBasic(String.class), DataUnitType.createBasicUnchecked(Tuple2.class) ), DataSetType.createDefault(String.class), @@ -216,11 +217,11 @@ public void testOnSpark() throws URISyntaxException, IOException { for (Map.Entry countEntry : counter) { correctResults.add(new Tuple2<>(countEntry.getKey(), countEntry.getValue())); } - Assert.assertTrue(results.size() == correctResults.size() && results.containsAll(correctResults) && correctResults.containsAll(results)); + assertTrue(results.size() == correctResults.size() && results.containsAll(correctResults) && correctResults.containsAll(results)); } @Test - public void testOnSparkToJava() throws URISyntaxException, IOException { + void testOnSparkToJava() throws IOException { // Assignment mode: ExecutionOperators. // Instantiate Wayang and activate the backend. @@ -292,11 +293,11 @@ public void testOnSparkToJava() throws URISyntaxException, IOException { for (Map.Entry countEntry : counter) { correctResults.add(new Tuple2<>(countEntry.getKey(), countEntry.getValue())); } - Assert.assertTrue(results.size() == correctResults.size() && results.containsAll(correctResults) && correctResults.containsAll(results)); + assertTrue(results.size() == correctResults.size() && results.containsAll(correctResults) && correctResults.containsAll(results)); } @Test - public void testOnJavaToSpark() throws URISyntaxException, IOException { + void testOnJavaToSpark() throws IOException { // Assignment mode: Constraints. TextFileSource textFileSource = new TextFileSource(WayangPlans.FILE_SOME_LINES_TXT.toString()); @@ -304,7 +305,7 @@ public void testOnJavaToSpark() throws URISyntaxException, IOException { // for each line (input) output an iterator of the words FlatMapOperator flatMapOperator = new FlatMapOperator<>( - new FlatMapDescriptor<>(line -> Arrays.asList((String[]) line.split(" ")), + new FlatMapDescriptor<>(line -> Arrays.asList(line.split(" ")), String.class, String.class ) @@ -371,11 +372,11 @@ public void testOnJavaToSpark() throws URISyntaxException, IOException { for (Map.Entry countEntry : counter) { correctResults.add(new Tuple2<>(countEntry.getKey(), countEntry.getValue())); } - Assert.assertEquals(new HashSet<>(correctResults), new HashSet<>(results)); + assertEquals(new HashSet<>(correctResults), new HashSet<>(results)); } @Test - public void testOnJavaAndSpark() throws URISyntaxException, IOException { + void testOnJavaAndSpark() throws IOException { // Assignment mode: none. TextFileSource textFileSource = new TextFileSource(WayangPlans.FILE_SOME_LINES_TXT.toString()); @@ -384,7 +385,7 @@ public void testOnJavaAndSpark() throws URISyntaxException, IOException { // for each line (input) output an iterator of the words FlatMapOperator flatMapOperator = new FlatMapOperator<>( - new FlatMapDescriptor<>(line -> Arrays.asList((String[]) line.split(" ")), + new FlatMapDescriptor<>(line -> Arrays.asList(line.split(" ")), String.class, String.class ) @@ -393,7 +394,7 @@ public void testOnJavaAndSpark() throws URISyntaxException, IOException { // for each word transform it to lowercase and output a key-value pair (word, 1) MapOperator> mapOperator = new MapOperator<>( - new TransformationDescriptor<>(word -> new Tuple2(word.toLowerCase(), 1), + new TransformationDescriptor<>(word -> new Tuple2<>(word.toLowerCase(), 1), DataUnitType.createBasic(String.class), DataUnitType.createBasicUnchecked(Tuple2.class) ), DataSetType.createDefault(String.class), @@ -444,7 +445,7 @@ public void testOnJavaAndSpark() throws URISyntaxException, IOException { for (Map.Entry countEntry : counter) { correctResults.add(new Tuple2<>(countEntry.getKey(), countEntry.getValue())); } - Assert.assertTrue(results.size() == correctResults.size() && results.containsAll(correctResults) && correctResults.containsAll(results)); + assertTrue(results.size() == correctResults.size() && results.containsAll(correctResults) && correctResults.containsAll(results)); }