From af44dfa309344e727733733a7794390f6d2b1a56 Mon Sep 17 00:00:00 2001 From: Matthijs van den Bos Date: Sun, 14 Jul 2019 21:43:17 +0200 Subject: [PATCH] Fix API stability issue --- .../main/kotlin/net/corda/testing/node/MockNetwork.kt | 9 ++++++++- .../corda/testing/node/internal/InternalMockNetwork.kt | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetwork.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetwork.kt index 98964f3b94..6ae9732550 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetwork.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNetwork.kt @@ -104,6 +104,7 @@ data class MockNetworkParameters( fun withServicePeerAllocationStrategy(servicePeerAllocationStrategy: InMemoryMessagingNetwork.ServicePeerAllocationStrategy): MockNetworkParameters { return copy(servicePeerAllocationStrategy = servicePeerAllocationStrategy) } + fun withNotarySpecs(notarySpecs: List): MockNetworkParameters = copy(notarySpecs = notarySpecs) fun withCordappsForAllNodes(cordappsForAllNodes: Collection): MockNetworkParameters = copy(cordappsForAllNodes = cordappsForAllNodes) @@ -125,7 +126,13 @@ data class MockNetworkParameters( * @property validating Boolean for whether the notary is validating or non-validating. * @property className String the optional name of a notary service class to load. If null, a builtin notary is loaded. */ -data class MockNetworkNotarySpec @JvmOverloads constructor(val name: CordaX500Name, val validating: Boolean = true, val className: String? = null) +data class MockNetworkNotarySpec @JvmOverloads constructor(val name: CordaX500Name, val validating: Boolean = true) { + var className: String? = null + + constructor(name: CordaX500Name, validating: Boolean = true, className: String? = null) : this(name, validating) { + this.className = className + } +} /** A class that represents an unstarted mock node for testing. */ class UnstartedMockNode private constructor(private val node: InternalMockNetwork.MockNode) { diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt index 03f2bffdaf..3d0c786651 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt @@ -249,10 +249,10 @@ open class InternalMockNetwork(cordappPackages: List = emptyList(), @VisibleForTesting internal open fun createNotaries(): List { - return notarySpecs.map { (name, validating, className) -> + return notarySpecs.map { spec -> createNode(InternalMockNodeParameters( - legalName = name, - configOverrides = { doReturn(NotaryConfig(validating, className = className)).whenever(it).notary } + legalName = spec.name, + configOverrides = { doReturn(NotaryConfig(spec.validating, className = spec.className)).whenever(it).notary } )) } }