mirror of
https://github.com/corda/corda.git
synced 2025-06-18 23:28:21 +00:00
CORDA-1888 Fix Vault Query composite queries (#3775)
* Reproduce composite query failures. * Fixes to OR querying and composite queries that use the same QueryCriteria (Linear, Fungible, Custom) more than once. * Revert debug logging for Hibernate SQL. * Cleanup and remove redundant joinPredicates global var. * Fix failing Java Unit test. * Fix Java compilation error in example-code section of docs. * Include copy() function for original constructor to maintain backwards API compatibility.
This commit is contained in:
@ -6,8 +6,10 @@ import net.corda.core.identity.AbstractParty
|
||||
/**
|
||||
* Dummy state for use in testing. Not part of any contract, not even the [DummyContract].
|
||||
*/
|
||||
data class DummyState(
|
||||
data class DummyState @JvmOverloads constructor (
|
||||
/** Some information that the state represents for test purposes. **/
|
||||
val magicNumber: Int = 0) : ContractState {
|
||||
override val participants: List<AbstractParty> get() = emptyList()
|
||||
val magicNumber: Int = 0,
|
||||
override val participants: List<AbstractParty> = listOf()) : ContractState {
|
||||
|
||||
fun copy(magicNumber: Int = this.magicNumber) = DummyState(magicNumber)
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ import net.corda.finance.contracts.DealState
|
||||
import net.corda.finance.contracts.asset.Cash
|
||||
import net.corda.finance.contracts.asset.Obligation
|
||||
import net.corda.finance.contracts.asset.OnLedgerAsset
|
||||
import net.corda.testing.contracts.DummyContract
|
||||
import net.corda.testing.contracts.DummyState
|
||||
import net.corda.testing.core.*
|
||||
import net.corda.testing.internal.chooseIdentity
|
||||
import net.corda.testing.internal.chooseIdentityAndCert
|
||||
@ -96,6 +98,7 @@ class VaultFiller @JvmOverloads constructor(
|
||||
fun fillWithSomeTestLinearStates(numberToCreate: Int,
|
||||
externalId: String? = null,
|
||||
participants: List<AbstractParty> = emptyList(),
|
||||
uniqueIdentifier: UniqueIdentifier? = null,
|
||||
linearString: String = "",
|
||||
linearNumber: Long = 0L,
|
||||
linearBoolean: Boolean = false,
|
||||
@ -108,7 +111,7 @@ class VaultFiller @JvmOverloads constructor(
|
||||
// Issue a Linear state
|
||||
val dummyIssue = TransactionBuilder(notary = defaultNotary.party).apply {
|
||||
addOutputState(DummyLinearContract.State(
|
||||
linearId = UniqueIdentifier(externalId),
|
||||
linearId = uniqueIdentifier ?: UniqueIdentifier(externalId),
|
||||
participants = participants.plus(me),
|
||||
linearString = linearString,
|
||||
linearNumber = linearNumber,
|
||||
@ -203,6 +206,23 @@ class VaultFiller @JvmOverloads constructor(
|
||||
return Vault(states)
|
||||
}
|
||||
|
||||
/**
|
||||
* Records a dummy state in the Vault (useful for creating random states when testing vault queries)
|
||||
*/
|
||||
fun fillWithDummyState() : Vault<DummyState> {
|
||||
val outputState = TransactionState(
|
||||
data = DummyState(Random().nextInt(), participants = listOf(services.myInfo.singleIdentity())),
|
||||
contract = DummyContract.PROGRAM_ID,
|
||||
notary = defaultNotary.party
|
||||
)
|
||||
val builder = TransactionBuilder()
|
||||
.addOutputState(outputState)
|
||||
.addCommand(DummyCommandData, defaultNotary.party.owningKey)
|
||||
val stxn = services.signInitialTransaction(builder)
|
||||
services.recordTransactions(stxn)
|
||||
return Vault(setOf(stxn.tx.outRef(0)))
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts together an issuance transaction for the specified amount that starts out being owned by the given pubkey.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user