From c17139733a079bacabf735bfdde2cacb361c5d6b Mon Sep 17 00:00:00 2001 From: Bing Li Date: Fri, 27 Sep 2024 13:13:27 -0700 Subject: [PATCH] update test --- .../com/snowflake/code_verification/JavaScalaAPISuite.scala | 4 ++-- .../scala/com/snowflake/code_verification/PomSuite.scala | 4 ++-- .../scala/com/snowflake/snowpark/ErrorMessageSuite.scala | 4 ++-- .../scala/com/snowflake/snowpark/FatJarBuilderSuite.scala | 5 ++--- src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala | 5 +++-- .../scala/com/snowflake/snowpark/JavaCodeCompilerSuite.scala | 4 ++-- src/test/scala/com/snowflake/snowpark/LoggingSuite.scala | 4 ++-- src/test/scala/com/snowflake/snowpark/SNTestBase.scala | 5 +++-- .../snowpark/SnowparkSFConnectionHandlerSuite.scala | 4 ++-- .../snowflake/snowpark_test/DataFrameAggregateSuite.scala | 5 +---- .../com/snowflake/snowpark_test/IndependentClassSuite.scala | 4 ++-- .../scala/com/snowflake/snowpark_test/JavaUtilsSuite.scala | 5 +++-- .../com/snowflake/snowpark_test/ScalaVariantSuite.scala | 4 ++-- .../scala/com/snowflake/snowpark_test/WindowSpecSuite.scala | 3 +-- 14 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/test/scala/com/snowflake/code_verification/JavaScalaAPISuite.scala b/src/test/scala/com/snowflake/code_verification/JavaScalaAPISuite.scala index f71a8182..7c417f46 100644 --- a/src/test/scala/com/snowflake/code_verification/JavaScalaAPISuite.scala +++ b/src/test/scala/com/snowflake/code_verification/JavaScalaAPISuite.scala @@ -1,11 +1,11 @@ package com.snowflake.code_verification import com.snowflake.snowpark.{CodeVerification, DataFrame} -import org.scalatest.FunSuite +import org.scalatest.funsuite.AnyFunSuite // verify API Java and Scala API contain same functions @CodeVerification -class JavaScalaAPISuite extends FunSuite { +class JavaScalaAPISuite extends AnyFunSuite { private val scalaCaseClassFunctions = Set( "apply", "copy", diff --git a/src/test/scala/com/snowflake/code_verification/PomSuite.scala b/src/test/scala/com/snowflake/code_verification/PomSuite.scala index b5b39f4d..45535f1f 100644 --- a/src/test/scala/com/snowflake/code_verification/PomSuite.scala +++ b/src/test/scala/com/snowflake/code_verification/PomSuite.scala @@ -1,12 +1,12 @@ package com.snowflake.code_verification import com.snowflake.snowpark.CodeVerification -import org.scalatest.FunSuite +import org.scalatest.funsuite.AnyFunSuite import scala.collection.mutable @CodeVerification -class PomSuite extends FunSuite { +class PomSuite extends AnyFunSuite { private val pomFileName = "pom.xml" private val fipsPomFileName = "fips-pom.xml" diff --git a/src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala b/src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala index 211131ab..74c1f123 100644 --- a/src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala +++ b/src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala @@ -6,9 +6,9 @@ import com.snowflake.snowpark.internal.ParameterUtils.{ MIN_REQUEST_TIMEOUT_IN_SECONDS, SnowparkRequestTimeoutInSeconds } -import org.scalatest.FunSuite +import org.scalatest.funsuite.AnyFunSuite -class ErrorMessageSuite extends FunSuite { +class ErrorMessageSuite extends AnyFunSuite { test("INTERNAL_TEST_MESSAGE") { val ex = ErrorMessage.INTERNAL_TEST_MESSAGE("my message: '%d $'") diff --git a/src/test/scala/com/snowflake/snowpark/FatJarBuilderSuite.scala b/src/test/scala/com/snowflake/snowpark/FatJarBuilderSuite.scala index c3007066..28d94199 100644 --- a/src/test/scala/com/snowflake/snowpark/FatJarBuilderSuite.scala +++ b/src/test/scala/com/snowflake/snowpark/FatJarBuilderSuite.scala @@ -3,14 +3,13 @@ package com.snowflake.snowpark import java.io.{File, FileOutputStream} import java.util.jar.{JarFile, JarOutputStream} import java.util.zip.ZipException - import com.snowflake.snowpark.internal.{FatJarBuilder, JavaCodeCompiler} -import org.scalatest.FunSuite +import org.scalatest.funsuite.AnyFunSuite import scala.collection.mutable.ArrayBuffer import scala.util.Random -class FatJarBuilderSuite extends FunSuite with FileUtils { +class FatJarBuilderSuite extends AnyFunSuite with FileUtils { test("Check that fat jar is built correctly") { val className = "HelloWorld" diff --git a/src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala b/src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala index 98365cac..ede3bb5f 100644 --- a/src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala +++ b/src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala @@ -1,10 +1,11 @@ package com.snowflake.snowpark -import org.scalatest.FunSuite +import org.scalatest.funsuite.AnyFunSuite + import java.io.ByteArrayOutputStream @JavaAPITest -class JavaAPISuite extends FunSuite { +class JavaAPISuite extends AnyFunSuite { // some tests can't be implemented in Java are listed below // console redirect doesn't work in Java since run JUnit from Scala diff --git a/src/test/scala/com/snowflake/snowpark/JavaCodeCompilerSuite.scala b/src/test/scala/com/snowflake/snowpark/JavaCodeCompilerSuite.scala index 4e3faa54..f9e7bd4e 100644 --- a/src/test/scala/com/snowflake/snowpark/JavaCodeCompilerSuite.scala +++ b/src/test/scala/com/snowflake/snowpark/JavaCodeCompilerSuite.scala @@ -1,9 +1,9 @@ package com.snowflake.snowpark import com.snowflake.snowpark.internal.{InMemoryClassObject, JavaCodeCompiler, UDFClassPath} -import org.scalatest.FunSuite +import org.scalatest.funsuite.AnyFunSuite -class JavaCodeCompilerSuite extends FunSuite { +class JavaCodeCompilerSuite extends AnyFunSuite { test("Compile a class that requires scala in classpath") { val className = "HelloWorld" diff --git a/src/test/scala/com/snowflake/snowpark/LoggingSuite.scala b/src/test/scala/com/snowflake/snowpark/LoggingSuite.scala index d3a31d9e..0ea52e39 100644 --- a/src/test/scala/com/snowflake/snowpark/LoggingSuite.scala +++ b/src/test/scala/com/snowflake/snowpark/LoggingSuite.scala @@ -1,9 +1,9 @@ package com.snowflake.snowpark import com.snowflake.snowpark.internal.Logging -import org.scalatest.FunSuite +import org.scalatest.funsuite.AnyFunSuite -class LoggingSuite extends FunSuite { +class LoggingSuite extends AnyFunSuite { test("log name") { val a = new LoggingTestA diff --git a/src/test/scala/com/snowflake/snowpark/SNTestBase.scala b/src/test/scala/com/snowflake/snowpark/SNTestBase.scala index e1245569..2a5ab872 100644 --- a/src/test/scala/com/snowflake/snowpark/SNTestBase.scala +++ b/src/test/scala/com/snowflake/snowpark/SNTestBase.scala @@ -8,14 +8,15 @@ import com.snowflake.snowpark.internal.{ParameterUtils, ServerConnection, UDFCla import com.snowflake.snowpark.types._ import com.snowflake.snowpark_test.TestFiles import org.mockito.Mockito.{doReturn, spy, when} -import org.scalatest.{BeforeAndAfterAll, FunSuite} +import org.scalatest.BeforeAndAfterAll +import org.scalatest.funsuite.AnyFunSuite import scala.collection.mutable.ArrayBuffer import scala.concurrent.{Await, Future} import scala.concurrent.duration._ import scala.concurrent.ExecutionContext.Implicits.global -trait SNTestBase extends FunSuite with BeforeAndAfterAll with SFTestUtils with SnowTestFiles { +trait SNTestBase extends AnyFunSuite with BeforeAndAfterAll with SFTestUtils with SnowTestFiles { protected val defaultProfile: String = TestUtils.defaultProfile diff --git a/src/test/scala/com/snowflake/snowpark/SnowparkSFConnectionHandlerSuite.scala b/src/test/scala/com/snowflake/snowpark/SnowparkSFConnectionHandlerSuite.scala index 042a8146..cd11837a 100644 --- a/src/test/scala/com/snowflake/snowpark/SnowparkSFConnectionHandlerSuite.scala +++ b/src/test/scala/com/snowflake/snowpark/SnowparkSFConnectionHandlerSuite.scala @@ -1,9 +1,9 @@ package com.snowflake.snowpark -import org.scalatest.FunSuite import com.snowflake.snowpark.internal.SnowparkSFConnectionHandler +import org.scalatest.funsuite.AnyFunSuite -class SnowparkSFConnectionHandlerSuite extends FunSuite { +class SnowparkSFConnectionHandlerSuite extends AnyFunSuite { test("version") { assert(SnowparkSFConnectionHandler.extractValidVersionNumber("0.1.0-snapshot").equals("0.1.0")) diff --git a/src/test/scala/com/snowflake/snowpark_test/DataFrameAggregateSuite.scala b/src/test/scala/com/snowflake/snowpark_test/DataFrameAggregateSuite.scala index 7418701a..824dc029 100644 --- a/src/test/scala/com/snowflake/snowpark_test/DataFrameAggregateSuite.scala +++ b/src/test/scala/com/snowflake/snowpark_test/DataFrameAggregateSuite.scala @@ -3,7 +3,6 @@ package com.snowflake.snowpark_test import com.snowflake.snowpark.functions._ import com.snowflake.snowpark._ import net.snowflake.client.jdbc.SnowflakeSQLException -import org.scalatest.Matchers.the import java.sql.ResultSet @@ -306,9 +305,7 @@ class DataFrameAggregateSuite extends TestData { // Used temporary VIEW which is not supported by owner's mode stored proc yet test("Window functions inside aggregate functions", JavaStoredProcExcludeOwner) { def checkWindowError(df: => DataFrame): Unit = { - the[SnowflakeSQLException] thrownBy { - df.collect() - } + assertThrows[SnowparkClientException](df.collect()) } checkWindowError(testData2.select(min(avg($"b").over(Window.partitionBy($"a"))))) checkWindowError(testData2.agg(sum($"b"), max(rank().over(Window.orderBy($"a"))))) diff --git a/src/test/scala/com/snowflake/snowpark_test/IndependentClassSuite.scala b/src/test/scala/com/snowflake/snowpark_test/IndependentClassSuite.scala index 25b772db..5d02f598 100644 --- a/src/test/scala/com/snowflake/snowpark_test/IndependentClassSuite.scala +++ b/src/test/scala/com/snowflake/snowpark_test/IndependentClassSuite.scala @@ -1,14 +1,14 @@ package com.snowflake.snowpark_test -import org.scalatest.FunSuite import org.scalatest.exceptions.TestFailedException import com.snowflake.snowpark.internal.Utils +import org.scalatest.funsuite.AnyFunSuite import scala.language.postfixOps import sys.process._ // verify those classes do not depend on Snowpark package -class IndependentClassSuite extends FunSuite { +class IndependentClassSuite extends AnyFunSuite { lazy val pathPrefix = s"target/scala-${Utils.ScalaCompatVersion}/" private def generatePath(path: String): String = pathPrefix + path test("scala variant") { diff --git a/src/test/scala/com/snowflake/snowpark_test/JavaUtilsSuite.scala b/src/test/scala/com/snowflake/snowpark_test/JavaUtilsSuite.scala index 04228c55..c8eb59b5 100644 --- a/src/test/scala/com/snowflake/snowpark_test/JavaUtilsSuite.scala +++ b/src/test/scala/com/snowflake/snowpark_test/JavaUtilsSuite.scala @@ -1,16 +1,17 @@ package com.snowflake.snowpark_test -import org.scalatest.FunSuite import com.snowflake.snowpark.internal.JavaUtils._ import com.snowflake.snowpark.types.Variant import com.snowflake.snowpark_java.types.{Variant => JavaVariant} +import org.scalatest.funsuite.AnyFunSuite + import scala.collection.JavaConverters._ import java.util // test UDF utils functions // those functions work on server side. // can't be detected by test coverage report. -class JavaUtilsSuite extends FunSuite { +class JavaUtilsSuite extends AnyFunSuite { test("geography to string") { val data = "{\"type\":\"Point\",\"coordinates\":[125.6, 10.1]}" diff --git a/src/test/scala/com/snowflake/snowpark_test/ScalaVariantSuite.scala b/src/test/scala/com/snowflake/snowpark_test/ScalaVariantSuite.scala index 1f03c3f6..9d84ae77 100644 --- a/src/test/scala/com/snowflake/snowpark_test/ScalaVariantSuite.scala +++ b/src/test/scala/com/snowflake/snowpark_test/ScalaVariantSuite.scala @@ -1,12 +1,12 @@ package com.snowflake.snowpark_test import com.snowflake.snowpark.types.{Geography, Variant} -import org.scalatest.FunSuite +import org.scalatest.funsuite.AnyFunSuite import java.io.UncheckedIOException import java.sql.{Date, Time, Timestamp} -class ScalaVariantSuite extends FunSuite { +class ScalaVariantSuite extends AnyFunSuite { test("scala constructor and extension functions") { assert(new Variant(1.1).asDouble() == 1.1) assert(new Variant(1.2f).asFloat() == 1.2f) diff --git a/src/test/scala/com/snowflake/snowpark_test/WindowSpecSuite.scala b/src/test/scala/com/snowflake/snowpark_test/WindowSpecSuite.scala index 00100566..01a37eb4 100644 --- a/src/test/scala/com/snowflake/snowpark_test/WindowSpecSuite.scala +++ b/src/test/scala/com/snowflake/snowpark_test/WindowSpecSuite.scala @@ -3,7 +3,6 @@ package com.snowflake.snowpark_test import com.snowflake.snowpark.functions._ import com.snowflake.snowpark.{DataFrame, Row, TestData, Window} import net.snowflake.client.jdbc.SnowflakeSQLException -import org.scalatest.Matchers.the import scala.reflect.ClassTag @@ -56,7 +55,7 @@ class WindowSpecSuite extends TestData { test("Window functions inside WHERE and HAVING clauses") { def checkAnalysisError[T: ClassTag](df: => DataFrame): Unit = { - the[T] thrownBy { + assertThrows[ClassTag[T]] { df.collect() } }