mirror of
https://github.com/corda/corda.git
synced 2025-06-18 23:28:21 +00:00
CORDA-1699: Restore binary compatibility for UniqueIdentifier class. (#3505)
* Update JarFilter to remove certain annotations from primary constructors. * Enhance unit tests for deleting constructors. * Update the documentation to explain how to handle non-deterministic default constructor parameters. * Reduce the base logging level of SanitisingTransformer to DEBUG. * Simplify the execution of repeatable ClassVisitors. * Simplify Gradle usage slightly. * Add test for deterministic UniqueIdentifier. * Update README to cover handling default parameters.
This commit is contained in:
@ -0,0 +1,37 @@
|
||||
package net.corda.deterministic.contracts
|
||||
|
||||
import net.corda.core.contracts.UniqueIdentifier
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
class UniqueIdentifierTest {
|
||||
private companion object {
|
||||
private const val NAME = "MyName"
|
||||
private val TEST_UUID: UUID = UUID.fromString("00000000-1111-2222-3333-444444444444")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNewInstance() {
|
||||
val id = UniqueIdentifier(NAME, TEST_UUID)
|
||||
assertEquals("${NAME}_$TEST_UUID", id.toString())
|
||||
assertEquals(NAME, id.externalId)
|
||||
assertEquals(TEST_UUID, id.id)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPrimaryConstructor() {
|
||||
val primary = UniqueIdentifier::class.primaryConstructor ?: throw AssertionError("primary constructor missing")
|
||||
assertThat(primary.call(NAME, TEST_UUID)).isEqualTo(UniqueIdentifier(NAME, TEST_UUID))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConstructors() {
|
||||
assertEquals(1, UniqueIdentifier::class.constructors.size)
|
||||
val ex = assertFailsWith<IllegalArgumentException> { UniqueIdentifier::class.constructors.first().call() }
|
||||
assertThat(ex).hasMessage("Callable expects 2 arguments, but 0 were provided.")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user