mirror of
https://github.com/corda/corda.git
synced 2025-06-23 01:19:00 +00:00
CORDA-2263 evolve types with calculated properties (#4314)
* CORDA-2263 evolve types with calculated properties * Push handling of computed properties into builders * Set isAccessible to true prior to calling * Type information captures Java constructor, not Kotlin wrapper
This commit is contained in:
@ -7,6 +7,7 @@ import net.corda.core.node.NetworkParameters
|
||||
import net.corda.core.node.NotaryInfo
|
||||
import net.corda.core.serialization.ConstructorForDeserialization
|
||||
import net.corda.core.serialization.DeprecatedConstructorForDeserialization
|
||||
import net.corda.core.serialization.SerializableCalculatedProperty
|
||||
import net.corda.core.serialization.SerializedBytes
|
||||
import net.corda.serialization.internal.amqp.testutils.*
|
||||
import net.corda.testing.common.internal.ProjectStructure.projectRootDir
|
||||
@ -149,6 +150,34 @@ class EvolvabilityTests {
|
||||
assertEquals(D, deserializedCC.d)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
@Test
|
||||
fun removeParameterWithCalculatedParameter() {
|
||||
val sf = testDefaultFactory()
|
||||
val resource = "EvolvabilityTests.removeParameterWithCalculatedParameter"
|
||||
|
||||
// Original version of the class as it was serialised
|
||||
// data class CC(val a: Int, val b: String, val c: String, val d: Int) {
|
||||
// @get:SerializableCalculatedProperty
|
||||
// val e: String get() = "$b $c"
|
||||
// }
|
||||
// File(URI("$localPath/$resource")).writeBytes(SerializationOutput(sf).serialize(CC(1, "hello", "world", 2)).bytes)
|
||||
|
||||
|
||||
data class CC(val b: String, val d: Int) {
|
||||
@get:SerializableCalculatedProperty
|
||||
val e: String get() = "$b sailor"
|
||||
}
|
||||
|
||||
val url = EvolvabilityTests::class.java.getResource(resource)
|
||||
val sc2 = url.readBytes()
|
||||
val deserializedCC = DeserializationInput(sf).deserialize(SerializedBytes<CC>(sc2))
|
||||
|
||||
assertEquals("hello", deserializedCC.b)
|
||||
assertEquals(2, deserializedCC.d)
|
||||
assertEquals("hello sailor", deserializedCC.e)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
@Test
|
||||
fun addAndRemoveParameters() {
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user