-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple test about DefaultSource class
DefaultSource should have default constructor for executors to be able to create it.
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/test/scala/cognite/spark/v1/DefaultSourceClassTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cognite.spark.v1 | ||
|
||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
|
||
class DefaultSourceClassTest extends FlatSpec with Matchers { | ||
it should "have default constructor" in { | ||
// Data source should be constructable with no arguments and | ||
// any parameters should be parsed within specific methods. | ||
// Implicit parameters are also not allowed. | ||
// Otherwise spark executors will fail to create it. | ||
val res = new DefaultSource() | ||
res shouldBe a[DefaultSource] | ||
} | ||
|
||
it should "really have a no-argument constructor" in { | ||
// let's also check via reflection to rule out varargs option like A(String... s) | ||
// getConstructor() will only pick up no-args version | ||
// getConstructor(String[].class) can be used to select varargs version | ||
// reflection also makes sure no scala implicits are needed | ||
val res = classOf[DefaultSource].getConstructor().newInstance() | ||
res shouldBe a[DefaultSource] | ||
} | ||
} |