Minor: address more formatting issues spotted by Shams

This commit is contained in:
Mike Hearn 2017-04-11 14:28:56 +02:00
parent 4853e41a58
commit 0c0c5521c0
15 changed files with 28 additions and 67 deletions

View File

@ -24,8 +24,7 @@ import org.junit.Before
import java.util.*
import java.util.concurrent.locks.ReentrantLock
abstract class AbstractClientRPC {
abstract class AbstractClientRPCTest {
lateinit var artemis: EmbeddedActiveMQ
lateinit var serverSession: ClientSession
lateinit var clientSession: ClientSession
@ -93,8 +92,10 @@ abstract class AbstractClientRPC {
return CordaRPCClientImpl(clientSession, ReentrantLock(), rpcUser.username).proxyFor(type)
}
fun safeClose(obj: Any) = try {
(obj as AutoCloseable).close()
} catch (e: Exception) {
fun safeClose(obj: Any) {
try {
(obj as AutoCloseable).close()
} catch (e: Exception) {
}
}
}

View File

@ -23,7 +23,7 @@ import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue
class ClientRPCInfrastructureTests : AbstractClientRPC() {
class ClientRPCInfrastructureTests : AbstractClientRPCTest() {
// TODO: Test that timeouts work
lateinit var proxy: TestOps

View File

@ -8,7 +8,7 @@ import org.junit.After
import org.junit.Test
import kotlin.test.assertFailsWith
class RPCPermissionsTest : AbstractClientRPC() {
class RPCPermissionsTest : AbstractClientRPCTest() {
companion object {
const val DUMMY_FLOW = "StartFlow.net.corda.flows.DummyFlow"
const val OTHER_FLOW = "StartFlow.net.corda.flows.OtherFlow"

View File

@ -10,30 +10,13 @@ import java.time.Instant
* UTC zone offset.
*/
class InstantConverter : Converter<Instant, Timestamp> {
override fun getMappedType() = Instant::class.java
override fun getMappedType(): Class<Instant> {
return Instant::class.java
}
override fun getPersistedType() = Timestamp::class.java
override fun getPersistedType(): Class<Timestamp> {
return Timestamp::class.java
}
override fun getPersistedSize() = null
override fun getPersistedSize(): Int? {
return null
}
override fun convertToPersisted(value: Instant?) = value?.let { Timestamp.from(it) }
override fun convertToPersisted(value: Instant?): Timestamp? {
if (value == null) {
return null
}
return Timestamp.from(value)
}
override fun convertToMapped(type: Class<out Instant>, value: Timestamp?): Instant? {
if (value == null) {
return null
}
return value.toInstant()
}
override fun convertToMapped(type: Class<out Instant>, value: Timestamp?) = value?.toInstant()
}

View File

@ -8,31 +8,14 @@ import net.corda.core.crypto.SecureHash
* Converts from a [StateRef] to a Composite Key defined by a [String] txnHash and an [Int] index
*/
class StateRefConverter : Converter<StateRef, Pair<String, Int>> {
override fun getMappedType(): Class<StateRef> {
return StateRef::class.java
}
override fun getMappedType() = StateRef::class.java
@Suppress("UNCHECKED_CAST")
override fun getPersistedType(): Class<Pair<String, Int>> {
return Pair::class.java as Class<Pair<String, Int>>
}
override fun getPersistedType() = Pair::class.java as Class<Pair<String, Int>>
override fun getPersistedSize(): Int? {
return null
}
override fun getPersistedSize() = null
override fun convertToPersisted(value: StateRef?): Pair<String, Int>? {
if (value == null) {
return null
}
return Pair(value.txhash.toString(), value.index)
}
override fun convertToPersisted(value: StateRef?) = value?.let { Pair(it.txhash.toString(), it.index) }
override fun convertToMapped(type: Class<out StateRef>, value: Pair<String, Int>?): StateRef? {
if (value == null) {
return null
}
return StateRef(SecureHash.parse(value.first), value.second)
}
override fun convertToMapped(type: Class<out StateRef>, value: Pair<String, Int>?) = value?.let { StateRef(SecureHash.parse(it.first), it.second) }
}

View File

@ -43,7 +43,7 @@ class NonEmptySet<T>(initial: T) : MutableSet<T> {
if (size > elements.size)
set.removeAll(elements)
else if (!containsAll(elements))
// Remove the common elements
// Remove the common elements
set.removeAll(elements)
else
throw IllegalStateException()

View File

@ -105,7 +105,7 @@ class CommercialPaperLegacy : Contract {
}
}
// TODO: Think about how to evolve contracts over time with new commands.
// TODO: Think about how to evolve contracts over time with new commands.
else -> throw IllegalArgumentException("Unrecognised command")
}
}

View File

@ -144,7 +144,6 @@ object TwoPartyTradeFlow {
val typeToBuy: Class<out OwnableState>) : FlowLogic<SignedTransaction>() {
// DOCSTART 2
object RECEIVING : ProgressTracker.Step("Waiting for seller trading info")
object VERIFYING : ProgressTracker.Step("Verifying seller assets")
object SIGNING : ProgressTracker.Step("Generating and signing transaction proposal")
object SENDING_SIGNATURES : ProgressTracker.Step("Sending signatures to the seller")

View File

@ -28,6 +28,7 @@ import org.junit.Assert
import org.junit.Before
import org.junit.Test
import rx.Observable
import sun.misc.MessageUtils.where
import java.time.Instant
import java.util.*
import java.util.concurrent.CountDownLatch
@ -554,7 +555,7 @@ class VaultSchemaTest {
// select unlocked states
data.invoke {
val result = select(VaultSchema.VaultStates::class) where (VaultSchema.VaultStates::txId eq stateEntity.txId)
.and(VaultSchema.VaultStates::lockId.isNull())
.and(VaultSchema.VaultStates::lockId.isNull())
assertEquals(0, result.get().count())
}

View File

@ -217,8 +217,7 @@ private fun drawBanner(nodeVersionInfo: NodeVersionInfo) {
Emoji.renderIfSupported {
val (msg1, msg2) = messageOfTheDay()
println(Ansi.ansi().fgBrightRed().a(
"""
println(Ansi.ansi().fgBrightRed().a("""
______ __
/ ____/ _________/ /___ _
/ / __ / ___/ __ / __ `/ """).fgBrightBlue().a(msg1).newline().fgBrightRed().a(

View File

@ -5,6 +5,7 @@ import net.corda.core.flows.FlowLogic
import net.corda.core.flows.StateMachineRunId
import net.corda.core.node.services.VaultService
import net.corda.core.utilities.loggerFor
import net.corda.core.utilities.trace
import net.corda.node.services.statemachine.StateMachineManager
import net.corda.node.utilities.AddOrRemove
import java.util.*
@ -20,7 +21,7 @@ class VaultSoftLockManager(val vault: VaultService, smm: StateMachineManager) {
init {
smm.changes.subscribe { change ->
if (change.addOrRemove == AddOrRemove.REMOVE && trackingFlowIds.contains(change.id.uuid)) {
log.trace("${change.addOrRemove} Flow name ${change.logic.javaClass} with id ${change.id}")
log.trace { "${change.addOrRemove} Flow name ${change.logic.javaClass} with id ${change.id}" }
unregisterSoftLocks(change.id, change.logic)
}
trackingFlowIds.remove(change.id.uuid)

View File

@ -373,7 +373,7 @@ class NodeVaultServiceTest {
val spendableStatesUSD = (services.vaultService as NodeVaultService).unconsumedStatesForSpending<Cash.State>(1.DOLLARS, lockId = UUID.randomUUID())
spendableStatesUSD.forEach(::println)
assertThat(spendableStatesUSD).hasSize(1)
assertThat(spendableStatesUSD[0].state.data.amount.quantity).isGreaterThanOrEqualTo(1L * 100)
assertThat(spendableStatesUSD[0].state.data.amount.quantity).isGreaterThanOrEqualTo(100L)
assertThat(services.vaultService.softLockedStates<Cash.State>()).hasSize(1)
}
}

View File

@ -75,8 +75,6 @@ private class BankOfCordaDriver {
if (result)
println("Successfully processed Cash Issue request")
}
Role.ISSUER -> {
}
}
} catch (e: Exception) {
println("Exception occurred: $e \n ${e.printStackTrace()}")

View File

@ -12,8 +12,6 @@ class BankOfCordaPlugin : CordaPluginRegistry() {
// A list of classes that expose web APIs.
override val webApis = listOf(Function(::BankOfCordaWebApi))
// A list of flow that are required for this cordapp
override val requiredFlows: Map<String, Set<String>> =
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 requiredFlows: Map<String, Set<String>> = 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))
}

View File

@ -9,8 +9,6 @@ import java.util.function.Function
class ExplorerPlugin : CordaPluginRegistry() {
// A list of flow that are required for this cordapp
override val requiredFlows: Map<String, Set<String>> =
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 requiredFlows: Map<String, Set<String>> = 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))
}