-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle null in genericserde for kafka tombstones handling (#34)
- Loading branch information
1 parent
2a06c79
commit 4e08819
Showing
2 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
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
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,53 @@ | ||
package com.davideicardi.kaa.darwin | ||
|
||
import org.scalatest._ | ||
import flatspec._ | ||
import matchers._ | ||
import com.davideicardi.kaa.kafka.GenericSerde | ||
import com.davideicardi.kaa.test.TestSchemaRegistry | ||
|
||
class GenericSerdeSpec extends AnyFlatSpec with should.Matchers { | ||
|
||
val registry = new TestSchemaRegistry | ||
|
||
"GenericSerde" should "serialize and deserialize a case class" in { | ||
val target = new GenericSerde[FooUser](registry) | ||
|
||
val expected = FooUser("foo") | ||
val bytes = target.serialize("topic", expected) | ||
val result = target.deserialize("topic", bytes) | ||
|
||
result should equal (expected) | ||
} | ||
|
||
it should "serialize and deserialize an Option Some" in { | ||
val target = new GenericSerde[Option[FooUser]](registry) | ||
|
||
val expected = Some(FooUser("foo")) | ||
val bytes = target.serialize("topic", expected) | ||
val result = target.deserialize("topic", bytes) | ||
result should equal (expected) | ||
} | ||
|
||
it should "serialize and deserialize an Option None" in { | ||
val target = new GenericSerde[Option[FooUser]](registry) | ||
|
||
val expected: Option[FooUser] = None | ||
val bytes = target.serialize("topic", expected) | ||
val result = target.deserialize("topic", bytes) | ||
result should equal (expected) | ||
} | ||
|
||
it should "serialize and deserialize a null" in { | ||
val target = new GenericSerde[FooUser](registry) | ||
|
||
val expected: FooUser = null | ||
val bytes = target.serialize("topic", expected) | ||
val result = target.deserialize("topic", bytes) | ||
|
||
result should equal (expected) | ||
} | ||
|
||
case class FooUser (name: String) { | ||
} | ||
} |