You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spot.apache.org by na...@apache.org on 2017/09/26 21:37:21 UTC

[15/18] incubator-spot git commit: syncing with master

http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/fbcfa683/spot-ml/src/test/scala/org/apache/spot/utilities/FloatPointPrecisionUtility32Test.scala
----------------------------------------------------------------------
diff --git a/spot-ml/src/test/scala/org/apache/spot/utilities/FloatPointPrecisionUtility32Test.scala b/spot-ml/src/test/scala/org/apache/spot/utilities/FloatPointPrecisionUtility32Test.scala
index f9ee9ce..50a639a 100644
--- a/spot-ml/src/test/scala/org/apache/spot/utilities/FloatPointPrecisionUtility32Test.scala
+++ b/spot-ml/src/test/scala/org/apache/spot/utilities/FloatPointPrecisionUtility32Test.scala
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spot.utilities
 
 import org.apache.spark.sql.types._

http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/fbcfa683/spot-ml/src/test/scala/org/apache/spot/utilities/FloatingPointUtility64.scala
----------------------------------------------------------------------
diff --git a/spot-ml/src/test/scala/org/apache/spot/utilities/FloatingPointUtility64.scala b/spot-ml/src/test/scala/org/apache/spot/utilities/FloatingPointUtility64.scala
index 478129a..b6c2b98 100644
--- a/spot-ml/src/test/scala/org/apache/spot/utilities/FloatingPointUtility64.scala
+++ b/spot-ml/src/test/scala/org/apache/spot/utilities/FloatingPointUtility64.scala
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spot.utilities
 
 import org.apache.spark.sql.types._

http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/fbcfa683/spot-ml/src/test/scala/org/apache/spot/utilities/data/validation/InputSchemaTest.scala
----------------------------------------------------------------------
diff --git a/spot-ml/src/test/scala/org/apache/spot/utilities/data/validation/InputSchemaTest.scala b/spot-ml/src/test/scala/org/apache/spot/utilities/data/validation/InputSchemaTest.scala
new file mode 100644
index 0000000..52a3447
--- /dev/null
+++ b/spot-ml/src/test/scala/org/apache/spot/utilities/data/validation/InputSchemaTest.scala
@@ -0,0 +1,53 @@
+package org.apache.spot.utilities.data.validation
+
+import org.apache.spark.sql.types._
+import org.scalatest.{FlatSpec, Matchers}
+
+class InputSchemaTest extends FlatSpec with Matchers {
+
+  "validate" should "return true when incoming schema is valid" in {
+
+    val incomingSchema = StructType(List(StructField("ip", StringType),
+      StructField("ibyt", LongType),
+      StructField("host", StringType),
+      StructField("score", FloatType)))
+
+    val modelSchema = StructType(List(StructField("ip", StringType),
+      StructField("ibyt", LongType),
+      StructField("host", StringType)))
+
+    val results = InputSchema.validate(incomingSchema, modelSchema)
+
+    results.isValid shouldBe true
+  }
+
+  it should "return false when incoming schema is not valid due to type mismatch" in {
+    val incomingSchema = StructType(List(StructField("ip", StringType),
+      StructField("ibyt", StringType),
+      StructField("host", IntegerType),
+      StructField("score", FloatType)))
+
+    val modelSchema = StructType(List(StructField("ip", StringType),
+      StructField("ibyt", LongType),
+      StructField("host", StringType)))
+
+    val results = InputSchema.validate(incomingSchema, modelSchema)
+
+    results.isValid shouldBe false
+  }
+
+  it should "return false when incoming schema is not valid due to required field is missing" in {
+
+    val incomingSchema = StructType(List(StructField("ip", StringType),
+      StructField("ibyt", LongType),
+      StructField("score", FloatType)))
+
+    val modelSchema = StructType(List(StructField("ip", StringType),
+      StructField("ibyt", LongType),
+      StructField("host", StringType)))
+
+    val results = InputSchema.validate(incomingSchema, modelSchema)
+
+    results.isValid shouldBe false
+  }
+}