mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
CORDA-540: Small changes to make "finance" tests pass in AMQP mode (#1445)
This commit is contained in:
parent
c293d6b18a
commit
d9d17be284
@ -82,7 +82,7 @@ public class JavaCommercialPaper implements Contract {
|
|||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
Amount<Issued<Currency>> getFaceValue() {
|
public Amount<Issued<Currency>> getFaceValue() {
|
||||||
return faceValue;
|
return faceValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import kotlin.collections.Set
|
|||||||
* Serialization / deserialization of predefined set of supported [Collection] types covering mostly [List]s and [Set]s.
|
* Serialization / deserialization of predefined set of supported [Collection] types covering mostly [List]s and [Set]s.
|
||||||
*/
|
*/
|
||||||
class CollectionSerializer(val declaredType: ParameterizedType, factory: SerializerFactory) : AMQPSerializer<Any> {
|
class CollectionSerializer(val declaredType: ParameterizedType, factory: SerializerFactory) : AMQPSerializer<Any> {
|
||||||
override val type: Type = declaredType as? DeserializedParameterizedType ?: DeserializedParameterizedType.make(declaredType.toString())
|
override val type: Type = declaredType as? DeserializedParameterizedType ?: DeserializedParameterizedType.make(SerializerFactory.nameForType(declaredType))
|
||||||
override val typeDescriptor = "$DESCRIPTOR_DOMAIN:${fingerprintForType(type, factory)}"
|
override val typeDescriptor = "$DESCRIPTOR_DOMAIN:${fingerprintForType(type, factory)}"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -16,7 +16,7 @@ private typealias MapCreationFunction = (Map<*, *>) -> Map<*, *>
|
|||||||
* Serialization / deserialization of certain supported [Map] types.
|
* Serialization / deserialization of certain supported [Map] types.
|
||||||
*/
|
*/
|
||||||
class MapSerializer(private val declaredType: ParameterizedType, factory: SerializerFactory) : AMQPSerializer<Any> {
|
class MapSerializer(private val declaredType: ParameterizedType, factory: SerializerFactory) : AMQPSerializer<Any> {
|
||||||
override val type: Type = declaredType as? DeserializedParameterizedType ?: DeserializedParameterizedType.make(declaredType.toString())
|
override val type: Type = declaredType as? DeserializedParameterizedType ?: DeserializedParameterizedType.make(SerializerFactory.nameForType(declaredType))
|
||||||
override val typeDescriptor = "$DESCRIPTOR_DOMAIN:${fingerprintForType(type, factory)}"
|
override val typeDescriptor = "$DESCRIPTOR_DOMAIN:${fingerprintForType(type, factory)}"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -37,7 +37,7 @@ internal fun constructorForDeserialization(type: Type): KFunction<Any>? {
|
|||||||
val kotlinConstructors = clazz.kotlin.constructors
|
val kotlinConstructors = clazz.kotlin.constructors
|
||||||
val hasDefault = kotlinConstructors.any { it.parameters.isEmpty() }
|
val hasDefault = kotlinConstructors.any { it.parameters.isEmpty() }
|
||||||
for (kotlinConstructor in kotlinConstructors) {
|
for (kotlinConstructor in kotlinConstructors) {
|
||||||
if (preferredCandidate == null && kotlinConstructors.size == 1 && !hasDefault) {
|
if (preferredCandidate == null && kotlinConstructors.size == 1) {
|
||||||
preferredCandidate = kotlinConstructor
|
preferredCandidate = kotlinConstructor
|
||||||
} else if (preferredCandidate == null && kotlinConstructors.size == 2 && hasDefault && kotlinConstructor.parameters.isNotEmpty()) {
|
} else if (preferredCandidate == null && kotlinConstructors.size == 2 && hasDefault && kotlinConstructor.parameters.isNotEmpty()) {
|
||||||
preferredCandidate = kotlinConstructor
|
preferredCandidate = kotlinConstructor
|
||||||
|
@ -27,7 +27,6 @@ data class schemaAndDescriptor(val schema: Schema, val typeDescriptor: Any)
|
|||||||
// TODO: use guava caches etc so not unbounded
|
// TODO: use guava caches etc so not unbounded
|
||||||
// TODO: do we need to support a transient annotation to exclude certain properties?
|
// TODO: do we need to support a transient annotation to exclude certain properties?
|
||||||
// TODO: allow definition of well known types that are left out of the schema.
|
// TODO: allow definition of well known types that are left out of the schema.
|
||||||
// TODO: generally map Object to '*' all over the place in the schema and make sure use of '*' amd '?' is consistent and documented in generics.
|
|
||||||
// TODO: found a document that states textual descriptors are Symbols. Adjust schema class appropriately.
|
// TODO: found a document that states textual descriptors are Symbols. Adjust schema class appropriately.
|
||||||
// TODO: document and alert to the fact that classes cannot default superclass/interface properties otherwise they are "erased" due to matching with constructor.
|
// TODO: document and alert to the fact that classes cannot default superclass/interface properties otherwise they are "erased" due to matching with constructor.
|
||||||
// TODO: type name prefixes for interfaces and abstract classes? Or use label?
|
// TODO: type name prefixes for interfaces and abstract classes? Or use label?
|
||||||
@ -342,7 +341,7 @@ class SerializerFactory(val whitelist: ClassWhitelist, cl: ClassLoader) {
|
|||||||
}
|
}
|
||||||
is ParameterizedType -> "${nameForType(type.rawType)}<${type.actualTypeArguments.joinToString { nameForType(it) }}>"
|
is ParameterizedType -> "${nameForType(type.rawType)}<${type.actualTypeArguments.joinToString { nameForType(it) }}>"
|
||||||
is GenericArrayType -> "${nameForType(type.genericComponentType)}[]"
|
is GenericArrayType -> "${nameForType(type.genericComponentType)}[]"
|
||||||
is WildcardType -> "Any"
|
is WildcardType -> "?"
|
||||||
is TypeVariable<*> -> "?"
|
is TypeVariable<*> -> "?"
|
||||||
else -> throw NotSerializableException("Unable to render type $type to a string.")
|
else -> throw NotSerializableException("Unable to render type $type to a string.")
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ class SerializationOutputTests {
|
|||||||
serdes(obj)
|
serdes(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NotSerializableException::class)
|
@Test
|
||||||
fun `test top level list array`() {
|
fun `test top level list array`() {
|
||||||
val obj = arrayOf(listOf("Fred", "Ginger"), listOf("Rogers", "Hammerstein"))
|
val obj = arrayOf(listOf("Fred", "Ginger"), listOf("Rogers", "Hammerstein"))
|
||||||
serdes(obj)
|
serdes(obj)
|
||||||
|
Loading…
Reference in New Issue
Block a user