kramasamy closed pull request #2861: [Streamlet Scala API] Add Scala Streamlet 
Integration Tests Part II
URL: https://github.com/apache/incubator-heron/pull/2861
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/integration_test/src/python/test_runner/resources/test.json 
b/integration_test/src/python/test_runner/resources/test.json
index 7d7cf2b6d2..1174154645 100644
--- a/integration_test/src/python/test_runner/resources/test.json
+++ b/integration_test/src/python/test_runner/resources/test.json
@@ -12,6 +12,11 @@
       "topologyName" : "IntegrationTest_ScalaStreamletWithFilterAndTransform",
       "classPath"    : 
"scala_streamlet_with_filter_and_transform.ScalaStreamletWithFilterAndTransform",
       "expectedResultRelativePath" : 
"scala_streamlet_with_filter_and_transform/ScalaStreamletWithFilterAndTransformResults.json"
+    },
+    {
+      "topologyName" : 
"IntegrationTest_ScalaStreamletWithMapAndFlatMapAndFilterAndClone",
+      "classPath"    : 
"scala_streamlet_with_map_and_flatmap_and_filter_and_clone.ScalaStreamletWithMapAndFlatMapAndFilterAndClone",
+      "expectedResultRelativePath" : 
"scala_streamlet_with_map_and_flatmap_and_filter_and_clone/ScalaStreamletWithMapAndFlatMapAndFilterAndCloneResults.json"
     }
   ],
   "javaTopologies": [
diff --git 
a/integration_test/src/scala/org/apache/heron/integration_test/common/ScalaIntegrationTestBase.scala
 
b/integration_test/src/scala/org/apache/heron/integration_test/common/ScalaIntegrationTestBase.scala
index 0b36d6aa89..915233ff3f 100644
--- 
a/integration_test/src/scala/org/apache/heron/integration_test/common/ScalaIntegrationTestBase.scala
+++ 
b/integration_test/src/scala/org/apache/heron/integration_test/common/ScalaIntegrationTestBase.scala
@@ -21,7 +21,7 @@ import org.apache.heron.streamlet.scala.impl.BuilderImpl
 /**
   * Scala Integration Test Base
   */
-trait ScalaIntegrationTestBase extends Serializable {
+trait ScalaIntegrationTestBase {
 
   protected def build(testTopologyBuilder: TestTopologyBuilder,
                       streamletBuilder: Builder): TestTopologyBuilder = {
diff --git 
a/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_filter_and_transform/ScalaStreamletWithFilterAndTransform.scala
 
b/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_filter_and_transform/ScalaStreamletWithFilterAndTransform.scala
index 023f57ed78..7c1d7e82ab 100644
--- 
a/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_filter_and_transform/ScalaStreamletWithFilterAndTransform.scala
+++ 
b/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_filter_and_transform/ScalaStreamletWithFilterAndTransform.scala
@@ -38,7 +38,6 @@ object ScalaStreamletWithFilterAndTransform {
 /**
   * Scala Streamlet Integration Test
   */
-@SerialVersionUID(-7280407024398984674L)
 class ScalaStreamletWithFilterAndTransform(args: Array[String])
     extends AbstractTestTopology(args)
     with ScalaIntegrationTestBase {
diff --git 
a/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_map_and_flatmap_and_filter_and_clone/ScalaStreamletWithMapAndFlatMapAndFilterAndClone.scala
 
b/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_map_and_flatmap_and_filter_and_clone/ScalaStreamletWithMapAndFlatMapAndFilterAndClone.scala
new file mode 100644
index 0000000000..2742b993cb
--- /dev/null
+++ 
b/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_map_and_flatmap_and_filter_and_clone/ScalaStreamletWithMapAndFlatMapAndFilterAndClone.scala
@@ -0,0 +1,74 @@
+//  Copyright 2018 Twitter. All rights reserved.
+//
+//  Licensed under the Apache License, Version 2.0 (the "License");
+//  you may not use this file except in compliance with the License.
+//  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+package 
org.apache.heron.integration_test.topology.scala_streamlet_with_map_and_flatmap_and_filter_and_clone
+
+import scala.collection.mutable.Set
+
+import org.apache.heron.api.Config
+import org.apache.heron.integration_test.common.{
+  AbstractTestTopology,
+  ScalaIntegrationTestBase
+}
+import org.apache.heron.integration_test.core.TestTopologyBuilder
+import org.apache.heron.streamlet.scala.Builder
+
+object ScalaStreamletWithMapAndFlatMapAndFilterAndClone {
+  val months = "january - february - march - april - may - june" +
+    " - july - august - september - october - november - december"
+
+  val summerMonths =
+    List("june", "july", "august")
+
+  val incomingMonths = Set[String]()
+
+  def main(args: Array[String]): Unit = {
+    val conf = new Config
+    val topology = new ScalaStreamletWithMapAndFlatMapAndFilterAndClone(args)
+    topology.submit(conf)
+  }
+}
+
+class ScalaStreamletWithMapAndFlatMapAndFilterAndClone(args: Array[String])
+    extends AbstractTestTopology(args)
+    with ScalaIntegrationTestBase {
+
+  import ScalaStreamletWithMapAndFlatMapAndFilterAndClone._
+
+  override protected def buildTopology(
+      testTopologyBuilder: TestTopologyBuilder): TestTopologyBuilder = {
+    val streamletBuilder = Builder.newBuilder
+
+    val clonedStreamlet = streamletBuilder
+      .newSource(() => months)
+      .setName("months-text")
+      .flatMap[String]((m: String) => m.split(" - "))
+      .setName("months")
+      .filter((month: String) =>
+        (summerMonths.contains(month.toLowerCase)
+          && incomingMonths.add(month.toLowerCase)))
+      .setName("summer-months")
+      .map[String]((word: String) => word.substring(0, 3))
+      .setName("summer-months-with-short-name")
+      .clone(numClones = 2)
+
+    //Returns Summer Months with Uppercase
+    clonedStreamlet(0).map[String](month => month + "_2018")
+
+    //Returns Summer Months with Uppercase
+    clonedStreamlet(1).map[String](_.toUpperCase)
+
+    build(testTopologyBuilder, streamletBuilder)
+  }
+
+}
diff --git 
a/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_map_and_flatmap_and_filter_and_clone/ScalaStreamletWithMapAndFlatMapAndFilterAndCloneResults.json
 
b/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_map_and_flatmap_and_filter_and_clone/ScalaStreamletWithMapAndFlatMapAndFilterAndCloneResults.json
new file mode 100644
index 0000000000..6ececf2182
--- /dev/null
+++ 
b/integration_test/src/scala/org/apache/heron/integration_test/topology/scala_streamlet_with_map_and_flatmap_and_filter_and_clone/ScalaStreamletWithMapAndFlatMapAndFilterAndCloneResults.json
@@ -0,0 +1 @@
+["AUG", "JUL", "JUN", "aug_2018", "jul_2018", "jun_2018"]
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to