[CORDA-1472]: Crackdown on warnings. (#3136)

This commit is contained in:
Michele Sollecito
2018-05-14 21:15:52 +07:00
committed by GitHub
parent 5a92079011
commit d027b5b8f2
461 changed files with 1413 additions and 1578 deletions

View File

@ -466,7 +466,7 @@ public class FlowCookbookJava {
subFlow(new SendStateAndRefFlow(counterpartySession, dummyStates));
// On the receive side ...
List<StateAndRef<DummyState>> resolvedStateAndRef = subFlow(new ReceiveStateAndRefFlow<DummyState>(counterpartySession));
List<StateAndRef<DummyState>> resolvedStateAndRef = subFlow(new ReceiveStateAndRefFlow<>(counterpartySession));
// DOCEND 14
try {

View File

@ -50,7 +50,7 @@ public class CommercialPaper implements Contract {
requireThat(require -> {
require.using("the paper must have matured", time.isAfter(input.getMaturityDate()));
require.using("the received amount equals the face value", received == input.getFaceValue());
require.using("the paper must be destroyed", outputs.size() == 0);
require.using("the paper must be destroyed", outputs.isEmpty());
require.using("the transaction is signed by the owner of the CP", cmd.getSigners().contains(input.getOwner().getOwningKey()));
return null;
});

View File

@ -143,9 +143,8 @@ object TopupIssuerFlow {
// now invoke Cash subflow to Move issued assetType to issue requester
progressTracker.currentStep = TRANSFERRING
val moveCashFlow = CashPaymentFlow(amount, issueTo, anonymous = false)
val moveTx = subFlow(moveCashFlow)
// NOTE: CashFlow PayCash calls FinalityFlow which performs a Broadcast (which stores a local copy of the txn to the ledger)
return moveTx
return subFlow(moveCashFlow)
}
}
}

View File

@ -23,7 +23,7 @@ enum class WorkflowState {
REJECTED
}
val TRADE_APPROVAL_PROGRAM_ID = "net.corda.docs.TradeApprovalContract"
const val TRADE_APPROVAL_PROGRAM_ID = "net.corda.docs.TradeApprovalContract"
/**
* Minimal contract to encode a simple workflow with one initial state and two possible eventual states.

View File

@ -4,7 +4,7 @@ import net.corda.core.contracts.CommandData
import net.corda.core.contracts.Contract
import net.corda.core.transactions.LedgerTransaction
val TEMPLATE_CONTRACT_ID = "com.template.TemplateContract"
const val TEMPLATE_CONTRACT_ID = "com.template.TemplateContract"
open class TemplateContract : Contract {
// A transaction is considered valid if the verify() function of the contract of each of the transaction's input

View File

@ -8,20 +8,12 @@ import net.corda.core.flows.FlowSession
import net.corda.core.flows.InitiatedBy
import net.corda.core.flows.InitiatingFlow
import net.corda.core.identity.Party
import net.corda.core.messaging.MessageRecipients
import net.corda.core.serialization.deserialize
import net.corda.core.serialization.serialize
import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.unwrap
import net.corda.node.services.messaging.Message
import net.corda.node.services.statemachine.DataSessionMessage
import net.corda.node.services.statemachine.ExistingSessionMessage
import net.corda.testing.node.*
import net.corda.testing.node.MockNetwork
import net.corda.testing.node.StartedMockNode
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
class TutorialMockNetwork {
@ -53,9 +45,9 @@ class TutorialMockNetwork {
}
}
lateinit private var mockNet: MockNetwork
lateinit private var nodeA: StartedMockNode
lateinit private var nodeB: StartedMockNode
private lateinit var mockNet: MockNetwork
private lateinit var nodeA: StartedMockNode
private lateinit var nodeB: StartedMockNode
@Rule
@JvmField
@ -76,8 +68,8 @@ class TutorialMockNetwork {
// @Test
// fun `fail if initiated doesn't send back 1 on first result`() {
// DOCSTART 1
// TODO: Fix this test - accessing the MessagingService directly exposes internal interfaces
// DOCSTART 1
// TODO: Fix this test - accessing the MessagingService directly exposes internal interfaces
// nodeB.setMessagingServiceSpy(object : MessagingServiceSpy(nodeB.network) {
// override fun send(message: Message, target: MessageRecipients, retryId: Long?, sequenceKey: Any, additionalHeaders: Map<String, String>) {
// val messageData = message.data.deserialize<Any>() as? ExistingSessionMessage
@ -91,7 +83,7 @@ class TutorialMockNetwork {
// }
// }
// })
// DOCEND 1
// DOCEND 1
// val initiatingReceiveFlow = nodeA.startFlow(FlowA(nodeB.info.legalIdentities.first()))
//

View File

@ -9,7 +9,7 @@ import net.corda.core.transactions.LedgerTransaction
import net.corda.core.contracts.*
// Replace IOUContract's contract ID and definition with:
val IOU_CONTRACT_ID = "com.template.IOUContract"
const val IOU_CONTRACT_ID = "com.template.IOUContract"
class IOUContract : Contract {
// Our Create command.

View File

@ -4,19 +4,15 @@ package net.corda.docs.tutorial.twoparty
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.Command
import net.corda.core.contracts.StateAndContract
import net.corda.core.flows.*
import net.corda.core.flows.CollectSignaturesFlow
import net.corda.core.flows.FinalityFlow
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatingFlow
import net.corda.core.flows.StartableByRPC
import net.corda.core.identity.Party
import net.corda.core.messaging.CordaRPCOps
import net.corda.core.serialization.SerializationWhitelist
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.ProgressTracker
import net.corda.webserver.services.WebServerPluginRegistry
import java.util.function.Function
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
// DOCEND 01
@InitiatingFlow

View File

@ -24,7 +24,6 @@ import net.corda.node.services.vault.VaultSchemaV1
import net.corda.testing.core.singleIdentity
import net.corda.testing.node.MockNetwork
import net.corda.testing.node.StartedMockNode
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatCode
import org.junit.After
import org.junit.Assert
@ -105,12 +104,12 @@ class CustomVaultQueryTest {
val balancesNodesA = nodeA.transaction {
nodeA.services.getCashBalances()
}
println("BalanceA\n" + balancesNodesA)
println("BalanceA\n$balancesNodesA")
val balancesNodesB = nodeB.transaction {
nodeB.services.getCashBalances()
}
println("BalanceB\n" + balancesNodesB)
println("BalanceB\n$balancesNodesB")
return Pair(balancesNodesA, balancesNodesB)
}

View File

@ -4,15 +4,18 @@ import net.corda.core.identity.Party
import net.corda.core.toFuture
import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow
import net.corda.finance.*
import net.corda.finance.DOLLARS
import net.corda.finance.GBP
import net.corda.finance.POUNDS
import net.corda.finance.USD
import net.corda.finance.contracts.getCashBalances
import net.corda.finance.flows.CashIssueFlow
import net.corda.finance.issuedBy
import net.corda.testing.core.singleIdentity
import net.corda.testing.node.MockNetwork
import net.corda.testing.node.StartedMockNode
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import kotlin.test.assertEquals
@ -71,8 +74,8 @@ class FxTransactionBuildTutorialTest {
nodeB.services.getCashBalances()
}
println("BalanceA\n" + balancesA)
println("BalanceB\n" + balancesB)
println("BalanceA\n$balancesA")
println("BalanceB\n$balancesB")
// Verify the transfers occurred as expected
assertEquals(POUNDS(100), balancesA[GBP])
assertEquals(DOLLARS(1000 - 200), balancesA[USD])

View File

@ -3,7 +3,6 @@ package net.corda.docs.tutorial.testdsl
import com.nhaarman.mockito_kotlin.doReturn
import com.nhaarman.mockito_kotlin.whenever
import net.corda.core.contracts.TransactionVerificationException
import net.corda.core.crypto.generateKeyPair
import net.corda.core.identity.CordaX500Name
import net.corda.core.node.services.IdentityService
import net.corda.core.utilities.days
@ -14,11 +13,14 @@ import net.corda.finance.contracts.CommercialPaper
import net.corda.finance.contracts.ICommercialPaperState
import net.corda.finance.contracts.asset.CASH
import net.corda.finance.contracts.asset.Cash
import net.corda.testing.core.*
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.BOB_NAME
import net.corda.testing.core.DUMMY_NOTARY_NAME
import net.corda.testing.core.SerializationEnvironmentRule
import net.corda.testing.core.TestIdentity
import net.corda.testing.internal.rigorousMock
import net.corda.testing.node.MockServices
import net.corda.testing.node.ledger
import net.corda.testing.node.makeTestIdentityService
import net.corda.testing.node.transaction
import org.junit.Rule
import org.junit.Test