-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- SessionTimeoutTaskProcessor integration with new topic and AVRO obj…
…ect. - Fix Metadata so it's an immutable map. - Add tests for Metadata checks.
- Loading branch information
1 parent
083efc2
commit 297c5ba
Showing
7 changed files
with
106 additions
and
44 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
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
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
47 changes: 47 additions & 0 deletions
47
...ate-manager/state-manager-api/src/test/kotlin/net/corda/libs/statemanager/api/Metadata.kt
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,47 @@ | ||
package net.corda.libs.statemanager.api | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertDoesNotThrow | ||
import org.junit.jupiter.api.assertThrows | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.MethodSource | ||
import java.util.stream.Stream | ||
|
||
class MetadataTests { | ||
companion object { | ||
@JvmStatic | ||
private fun acceptedTypes(): Stream<Any> = | ||
Stream.of( | ||
"foo", | ||
123, | ||
true | ||
) | ||
} | ||
@ParameterizedTest | ||
@MethodSource("acceptedTypes") | ||
fun `accept primitive types`(value: Any) { | ||
assertDoesNotThrow { | ||
Metadata(mapOf("foo" to value)) | ||
} | ||
} | ||
|
||
@Test | ||
fun `fail all non-primitive types`() { | ||
val list = listOf("Na Na Na Na Na Na Na Na", "Batman") | ||
val ex = assertThrows<IllegalArgumentException> { | ||
Metadata(mapOf("joker" to Superman(1000), "batman" to list)) | ||
} | ||
assertThat(ex).hasMessageContainingAll("joker", "batman", Superman::class.java.name, list.javaClass.name) | ||
} | ||
|
||
@Test | ||
fun `equals works as expected with map`() { | ||
val meta1 = Metadata(mapOf("foo" to "bar")) | ||
val meta2 = Metadata(mapOf("foo" to "bar")) | ||
assertThat(meta2).isEqualTo(meta1) | ||
assertThat(meta2).isNotSameAs(meta1) | ||
} | ||
|
||
data class Superman(val kudos: Int) | ||
} |