CORDA-540: Small changes to make "finance" tests pass in AMQP mode (#1445)

This commit is contained in:
Viktor Kolomeyko 2017-09-07 13:31:41 +01:00 committed by GitHub
parent c293d6b18a
commit d9d17be284
6 changed files with 6 additions and 7 deletions

View File

@ -82,7 +82,7 @@ public class JavaCommercialPaper implements Contract {
return owner;
}
Amount<Issued<Currency>> getFaceValue() {
public Amount<Issued<Currency>> getFaceValue() {
return faceValue;
}

View File

@ -14,7 +14,7 @@ import kotlin.collections.Set
* 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> {
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)}"
companion object {

View File

@ -16,7 +16,7 @@ private typealias MapCreationFunction = (Map<*, *>) -> Map<*, *>
* Serialization / deserialization of certain supported [Map] types.
*/
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)}"
companion object {

View File

@ -37,7 +37,7 @@ internal fun constructorForDeserialization(type: Type): KFunction<Any>? {
val kotlinConstructors = clazz.kotlin.constructors
val hasDefault = kotlinConstructors.any { it.parameters.isEmpty() }
for (kotlinConstructor in kotlinConstructors) {
if (preferredCandidate == null && kotlinConstructors.size == 1 && !hasDefault) {
if (preferredCandidate == null && kotlinConstructors.size == 1) {
preferredCandidate = kotlinConstructor
} else if (preferredCandidate == null && kotlinConstructors.size == 2 && hasDefault && kotlinConstructor.parameters.isNotEmpty()) {
preferredCandidate = kotlinConstructor

View File

@ -27,7 +27,6 @@ data class schemaAndDescriptor(val schema: Schema, val typeDescriptor: Any)
// TODO: use guava caches etc so not unbounded
// 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: 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: 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?
@ -342,7 +341,7 @@ class SerializerFactory(val whitelist: ClassWhitelist, cl: ClassLoader) {
}
is ParameterizedType -> "${nameForType(type.rawType)}<${type.actualTypeArguments.joinToString { nameForType(it) }}>"
is GenericArrayType -> "${nameForType(type.genericComponentType)}[]"
is WildcardType -> "Any"
is WildcardType -> "?"
is TypeVariable<*> -> "?"
else -> throw NotSerializableException("Unable to render type $type to a string.")
}

View File

@ -266,7 +266,7 @@ class SerializationOutputTests {
serdes(obj)
}
@Test(expected = NotSerializableException::class)
@Test
fun `test top level list array`() {
val obj = arrayOf(listOf("Fred", "Ginger"), listOf("Rogers", "Hammerstein"))
serdes(obj)