mirror of
https://github.com/corda/corda.git
synced 2025-06-13 20:58:19 +00:00
Merge remote-tracking branch 'open/master' into kat-merge-20180508
This commit is contained in:
@ -11,15 +11,31 @@
|
||||
package net.corda.docs
|
||||
|
||||
import net.corda.core.contracts.Amount
|
||||
import net.corda.core.contracts.ContractState
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.node.services.queryBy
|
||||
import net.corda.core.node.services.vault.DEFAULT_PAGE_NUM
|
||||
import net.corda.core.node.services.vault.DEFAULT_PAGE_SIZE
|
||||
import net.corda.core.node.services.vault.PageSpecification
|
||||
import net.corda.core.node.services.vault.QueryCriteria
|
||||
import net.corda.core.node.services.vault.builder
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.finance.*
|
||||
import net.corda.docs.java.tutorial.helloworld.IOUFlow
|
||||
import net.corda.finance.CHF
|
||||
import net.corda.finance.DOLLARS
|
||||
import net.corda.finance.GBP
|
||||
import net.corda.finance.POUNDS
|
||||
import net.corda.finance.SWISS_FRANCS
|
||||
import net.corda.finance.USD
|
||||
import net.corda.finance.contracts.getCashBalances
|
||||
import net.corda.finance.flows.CashIssueFlow
|
||||
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
|
||||
import org.junit.Before
|
||||
@ -34,7 +50,7 @@ class CustomVaultQueryTest {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance", "net.corda.docs"))
|
||||
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance", "net.corda.docs", "com.template"))
|
||||
nodeA = mockNet.createPartyNode()
|
||||
nodeB = mockNet.createPartyNode()
|
||||
nodeA.registerInitiatedFlow(TopupIssuerFlow.TopupIssuer::class.java)
|
||||
@ -46,6 +62,22 @@ class CustomVaultQueryTest {
|
||||
mockNet.stopNodes()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `query by max recorded time`() {
|
||||
|
||||
nodeA.startFlow(IOUFlow(1000, nodeB.info.singleIdentity())).getOrThrow()
|
||||
nodeA.startFlow(IOUFlow(500, nodeB.info.singleIdentity())).getOrThrow()
|
||||
|
||||
val max = builder { VaultSchemaV1.VaultStates::recordedTime.max() }
|
||||
val maxCriteria = QueryCriteria.VaultCustomQueryCriteria(max)
|
||||
|
||||
val results = nodeA.transaction {
|
||||
val pageSpecification = PageSpecification(pageNumber = DEFAULT_PAGE_NUM, pageSize = DEFAULT_PAGE_SIZE)
|
||||
nodeA.services.vaultService.queryBy<ContractState>(criteria = maxCriteria, paging = pageSpecification)
|
||||
}
|
||||
assertThatCode { results.otherResults.single() }.doesNotThrowAnyException()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test custom vault query`() {
|
||||
// issue some cash in several currencies
|
||||
@ -92,4 +124,4 @@ class CustomVaultQueryTest {
|
||||
|
||||
return Pair(balancesNodesA, balancesNodesB)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user