From 9948815df1857cee0e0266ea50fd43992ec402d6 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 11 Apr 2017 12:48:15 +0200 Subject: [PATCH] Minor: auto-format of module: samples --- samples/attachment-demo/build.gradle | 4 ++-- .../net/corda/attachmentdemo/AttachmentDemoTest.kt | 8 ++++---- .../net/corda/attachmentdemo/AttachmentDemo.kt | 4 ++-- samples/bank-of-corda-demo/build.gradle | 14 +++++++------- .../net/corda/bank/BankOfCordaHttpAPITest.kt | 4 ++-- .../kotlin/net/corda/bank/BankOfCordaDriver.kt | 11 +++++------ .../kotlin/net/corda/bank/api/BankOfCordaWebApi.kt | 3 +++ .../net/corda/bank/plugin/BankOfCordaPlugin.kt | 6 +++--- .../net/corda/irs/api/InterestRateSwapAPI.kt | 1 - .../kotlin/net/corda/irs/api/NodeInterestRates.kt | 1 + .../src/main/kotlin/net/corda/irs/contract/IRS.kt | 8 +++++--- .../kotlin/net/corda/irs/flows/AutoOfferFlow.kt | 2 +- .../main/kotlin/net/corda/irs/flows/FixingFlow.kt | 2 +- .../net/corda/irs/testing/NodeInterestRatesTest.kt | 9 +++++---- .../corda/notarydemo/flows/DummyIssueAndMove.kt | 2 +- .../main/kotlin/net/corda/vega/flows/SimmFlow.kt | 2 +- .../kotlin/net/corda/vega/flows/SimmRevaluation.kt | 2 +- .../src/main/kotlin/net/corda/traderdemo/Main.kt | 6 +++--- .../net/corda/traderdemo/TraderDemoClientApi.kt | 1 - 19 files changed, 47 insertions(+), 43 deletions(-) diff --git a/samples/attachment-demo/build.gradle b/samples/attachment-demo/build.gradle index 6cc01c2d9b..53d6d67d30 100644 --- a/samples/attachment-demo/build.gradle +++ b/samples/attachment-demo/build.gradle @@ -52,14 +52,14 @@ dependencies { } task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - ext.rpcUsers = [ ['username' : "demo", 'password' : "demo", 'permissions' : ["StartFlow.net.corda.flows.FinalityFlow"]] ] + ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["StartFlow.net.corda.flows.FinalityFlow"]]] directory "./build/nodes" networkMap "Controller" node { name "Controller" nearestCity "London" - advertisedServices ["corda.notary.validating"] + advertisedServices["corda.notary.validating"] p2pPort 10002 rpcPort 10003 cordapps = [] diff --git a/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt b/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt index 954d4cf7b4..e0b21ea3e6 100644 --- a/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt +++ b/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt @@ -25,9 +25,9 @@ class AttachmentDemoTest { driver(dsl = { val demoUser = listOf(User("demo", "demo", setOf("StartFlow.net.corda.flows.FinalityFlow"))) val (nodeA, nodeB) = Futures.allAsList( - startNode("Bank A", rpcUsers = demoUser), - startNode("Bank B", rpcUsers = demoUser), - startNode("Notary", setOf(ServiceInfo(SimpleNotaryService.Companion.type))) + startNode("Bank A", rpcUsers = demoUser), + startNode("Bank B", rpcUsers = demoUser), + startNode("Notary", setOf(ServiceInfo(SimpleNotaryService.Companion.type))) ).getOrThrow() val senderThread = CompletableFuture.supplyAsync { @@ -36,7 +36,7 @@ class AttachmentDemoTest { } }.exceptionally { it.printStackTrace() } - val recipientThread = CompletableFuture.supplyAsync{ + val recipientThread = CompletableFuture.supplyAsync { nodeB.rpcClientToNode().use(demoUser[0].username, demoUser[0].password) { recipient(this) } diff --git a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt index 3714e02f43..3fdf57bd72 100644 --- a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt +++ b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt @@ -10,16 +10,16 @@ import net.corda.core.div import net.corda.core.getOrThrow import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.startFlow +import net.corda.core.sizedInputStreamAndHash import net.corda.core.utilities.Emoji import net.corda.flows.FinalityFlow import net.corda.nodeapi.config.SSLConfiguration import net.corda.testing.ALICE_KEY +import java.io.InputStream import java.nio.file.Path import java.nio.file.Paths import kotlin.system.exitProcess import kotlin.test.assertEquals -import java.io.* -import net.corda.core.sizedInputStreamAndHash internal enum class Role { SENDER, diff --git a/samples/bank-of-corda-demo/build.gradle b/samples/bank-of-corda-demo/build.gradle index 9c69c89cca..8991a95b1d 100644 --- a/samples/bank-of-corda-demo/build.gradle +++ b/samples/bank-of-corda-demo/build.gradle @@ -70,10 +70,10 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { webPort 10007 cordapps = [] rpcUsers = [ - ['username' : "bankUser", - 'password' : "test", - 'permissions' : ["StartFlow.net.corda.flows.CashPaymentFlow", - "StartFlow.net.corda.flows.IssuerFlow\$IssuanceRequester"]] + ['username' : "bankUser", + 'password' : "test", + 'permissions': ["StartFlow.net.corda.flows.CashPaymentFlow", + "StartFlow.net.corda.flows.IssuerFlow\$IssuanceRequester"]] ] } node { @@ -85,9 +85,9 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { webPort 10010 cordapps = [] rpcUsers = [ - ['username' : "bigCorpUser", - 'password' : "test", - 'permissions' : ["StartFlow.net.corda.flows.CashPaymentFlow"]] + ['username' : "bigCorpUser", + 'password' : "test", + 'permissions': ["StartFlow.net.corda.flows.CashPaymentFlow"]] ] } } diff --git a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt index 02c48873b2..7a94eff2d4 100644 --- a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt +++ b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt @@ -14,8 +14,8 @@ class BankOfCordaHttpAPITest { fun `issuer flow via Http`() { driver(dsl = { val (nodeBankOfCorda) = Futures.allAsList( - startNode("BankOfCorda", setOf(ServiceInfo(SimpleNotaryService.type))), - startNode("BigCorporation") + startNode("BankOfCorda", setOf(ServiceInfo(SimpleNotaryService.type))), + startNode("BigCorporation") ).getOrThrow() val nodeBankOfCordaApiAddr = startWebserver(nodeBankOfCorda).getOrThrow() assert(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", "BigCorporation", "1", "BankOfCorda"))) diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt index 770cc44e9e..4eb4b68048 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt @@ -4,11 +4,11 @@ import com.google.common.net.HostAndPort import joptsimple.OptionParser import net.corda.bank.api.BankOfCordaClientApi import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams -import net.corda.flows.IssuerFlow import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceType import net.corda.core.transactions.SignedTransaction import net.corda.flows.CashPaymentFlow +import net.corda.flows.IssuerFlow import net.corda.node.driver.driver import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService @@ -59,8 +59,7 @@ private class BankOfCordaDriver { startWebserver(bankOfCorda.get()) waitForAllNodesToFinish() }, isDebug = true) - } - else { + } else { try { val requestParams = IssueRequestParams(options.valueOf(quantity), options.valueOf(currency), "BigCorporation", "1", "BankOfCorda") when (role) { @@ -76,10 +75,10 @@ private class BankOfCordaDriver { if (result) println("Successfully processed Cash Issue request") } - Role.ISSUER -> {} + Role.ISSUER -> { + } } - } - catch (e: Exception) { + } catch (e: Exception) { println("Exception occurred: $e \n ${e.printStackTrace()}") exitProcess(1) } diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaWebApi.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaWebApi.kt index cc00506df8..0394f86d1c 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaWebApi.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaWebApi.kt @@ -20,15 +20,18 @@ class BankOfCordaWebApi(val rpc: CordaRPCOps) { data class IssueRequestParams(val amount: Long, val currency: String, val issueToPartyName: String, val issueToPartyRefAsString: String, val issuerBankName: String) + private companion object { val logger = loggerFor() } + @GET @Path("date") @Produces(MediaType.APPLICATION_JSON) fun getCurrentDate(): Any { return mapOf("date" to LocalDateTime.now().toLocalDate()) } + /** * Request asset issuance */ diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/plugin/BankOfCordaPlugin.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/plugin/BankOfCordaPlugin.kt index 96abb9d1d9..b6a9997140 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/plugin/BankOfCordaPlugin.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/plugin/BankOfCordaPlugin.kt @@ -1,11 +1,11 @@ package net.corda.bank.plugin import net.corda.bank.api.BankOfCordaWebApi -import net.corda.flows.IssuerFlow import net.corda.core.contracts.Amount import net.corda.core.crypto.Party import net.corda.core.node.CordaPluginRegistry import net.corda.core.serialization.OpaqueBytes +import net.corda.flows.IssuerFlow import java.util.function.Function class BankOfCordaPlugin : CordaPluginRegistry() { @@ -13,7 +13,7 @@ class BankOfCordaPlugin : CordaPluginRegistry() { override val webApis = listOf(Function(::BankOfCordaWebApi)) // A list of flow that are required for this cordapp override val requiredFlows: Map> = - mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name) - ) + mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name) + ) override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service)) } diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/api/InterestRateSwapAPI.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/api/InterestRateSwapAPI.kt index bfe16d166f..34b7f4e6de 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/api/InterestRateSwapAPI.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/api/InterestRateSwapAPI.kt @@ -1,7 +1,6 @@ package net.corda.irs.api import net.corda.core.contracts.filterStatesOfType -import net.corda.core.crypto.AnonymousParty import net.corda.core.crypto.Party import net.corda.core.getOrThrow import net.corda.core.messaging.CordaRPCOps diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/api/NodeInterestRates.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/api/NodeInterestRates.kt index 9811d0daf0..fe88c4710c 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/api/NodeInterestRates.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/api/NodeInterestRates.kt @@ -213,6 +213,7 @@ object NodeInterestRates { else -> throw IllegalArgumentException("Oracle received data of different type than expected.") } } + val leaves = ftx.filteredLeaves if (!leaves.checkWithFun(::check)) throw IllegalArgumentException() diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt index e53eb81c25..d72ccf3395 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt @@ -304,7 +304,7 @@ class InterestRateSwap : Contract { } @CordaSerializable - open class FixedLeg( + open class FixedLeg

( var fixedRatePayer: P, notional: Amount, paymentFrequency: Frequency, @@ -362,6 +362,7 @@ class InterestRateSwap : Contract { fixedRatePayer, notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment, dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, fixedRate, rollConvention) + fun toAnonymous(): FixedLeg { return FixedLeg(fixedRatePayer.toAnonymous(), notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment, dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, @@ -370,7 +371,7 @@ class InterestRateSwap : Contract { } @CordaSerializable - open class FloatingLeg( + open class FloatingLeg

( var floatingRatePayer: P, notional: Amount, paymentFrequency: Frequency, @@ -458,6 +459,7 @@ class InterestRateSwap : Contract { paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, rollConvention, fixingRollConvention, resetDayInMonth, fixingPeriod, resetRule, fixingsPerPayment, fixingCalendar, index, indexSource, indexTenor) + fun toAnonymous(): FloatingLeg { return FloatingLeg(floatingRatePayer.toAnonymous(), notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment, dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, @@ -662,7 +664,7 @@ class InterestRateSwap : Contract { /** * The state class contains the 4 major data classes. */ - data class State( + data class State

( val fixedLeg: FixedLeg

, val floatingLeg: FloatingLeg

, val calculation: Calculation, diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/AutoOfferFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/AutoOfferFlow.kt index 60fede7ca3..026c731135 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/AutoOfferFlow.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/AutoOfferFlow.kt @@ -73,7 +73,7 @@ object AutoOfferFlow { return stx } - private fun notUs(parties: List): List { + private fun notUs(parties: List): List { val notUsParties: MutableList = arrayListOf() for (party in parties) { if (serviceHub.myInfo.legalIdentity != party) { diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/FixingFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/FixingFlow.kt index 087163a045..849e8cc83b 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/FixingFlow.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/FixingFlow.kt @@ -135,7 +135,7 @@ object FixingFlow { * TODO: Replace [FixingSession] and [FixingSessionInitiationHandler] with generic session initiation logic once it exists. */ class FixingRoleDecider(val ref: StateRef, override val progressTracker: ProgressTracker) : FlowLogic() { - @Suppress("unused") // Used via reflection. + @Suppress("unused") // Used via reflection. constructor(ref: StateRef) : this(ref, tracker()) companion object { diff --git a/samples/irs-demo/src/test/kotlin/net/corda/irs/testing/NodeInterestRatesTest.kt b/samples/irs-demo/src/test/kotlin/net/corda/irs/testing/NodeInterestRatesTest.kt index 9d8608e719..dfac04dd40 100644 --- a/samples/irs-demo/src/test/kotlin/net/corda/irs/testing/NodeInterestRatesTest.kt +++ b/samples/irs-demo/src/test/kotlin/net/corda/irs/testing/NodeInterestRatesTest.kt @@ -136,6 +136,7 @@ class NodeInterestRatesTest { else -> false } } + val ftx1 = wtx1.buildFilteredTransaction(::filterAllOutputs) assertFailsWith { oracle.sign(ftx1) } tx.addCommand(Cash.Commands.Move(), ALICE_PUBKEY) @@ -231,10 +232,10 @@ class NodeInterestRatesTest { rateTolerance: BigDecimal, progressTracker: ProgressTracker = RatesFixFlow.tracker(fixOf.name)) : RatesFixFlow(tx, oracle, fixOf, expectedRate, rateTolerance, progressTracker) { override fun filtering(elem: Any): Boolean { - return when (elem) { - is Command -> oracle.owningKey in elem.signers && elem.value is Fix - else -> false - } + return when (elem) { + is Command -> oracle.owningKey in elem.signers && elem.value is Fix + else -> false + } } } diff --git a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt index 2ec05290d5..bba9ae1442 100644 --- a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt +++ b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt @@ -23,7 +23,7 @@ class DummyIssueAndMove(private val notary: Party, private val counterpartyNode: val moveTx = DummyContract.move(asset, counterPartyKey).apply { signWith(myKeyPair) } - // We don't check signatures because we know that the notary's signature is missing + // We don't check signatures because we know that the notary's signature is missing return moveTx.toSignedTransaction(checkSufficientSignatures = false) } } diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmFlow.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmFlow.kt index 9d27cb9079..c4cc3100bc 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmFlow.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmFlow.kt @@ -54,7 +54,7 @@ object SimmFlow { class Requester(val otherParty: Party, val valuationDate: LocalDate, val existing: StateAndRef?) - : FlowLogic>() { + : FlowLogic>() { constructor(otherParty: Party, valuationDate: LocalDate) : this(otherParty, valuationDate, null) lateinit var myIdentity: Party diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmRevaluation.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmRevaluation.kt index 2a184dd73e..4580e568be 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmRevaluation.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmRevaluation.kt @@ -20,7 +20,7 @@ object SimmRevaluation { val myIdentity = serviceHub.myInfo.legalIdentity.toAnonymous() if (myIdentity == curState.parties[0]) { val otherParty = serviceHub.identityService.partyFromAnonymous(curState.parties[1]) - require (otherParty != null) { "Other party must be known by this node" } + require(otherParty != null) { "Other party must be known by this node" } subFlow(SimmFlow.Requester(otherParty!!, valuationDate, stateAndRef)) } } diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/Main.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/Main.kt index e1e6649957..03ef810017 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/Main.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/Main.kt @@ -1,14 +1,14 @@ package net.corda.traderdemo -import net.corda.flows.IssuerFlow +import net.corda.core.div import net.corda.core.node.services.ServiceInfo +import net.corda.flows.IssuerFlow import net.corda.node.driver.driver import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import net.corda.testing.BOC import java.nio.file.Paths -import net.corda.core.div -import net.corda.nodeapi.User /** * This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes) diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemoClientApi.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemoClientApi.kt index 58b9419c87..aef6e24198 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemoClientApi.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemoClientApi.kt @@ -4,7 +4,6 @@ import com.google.common.util.concurrent.Futures import net.corda.contracts.testing.calculateRandomlySizedAmounts import net.corda.core.contracts.Amount import net.corda.core.contracts.DOLLARS -import net.corda.core.contracts.Issued import net.corda.core.getOrThrow import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.startFlow