mirror of
https://github.com/corda/corda.git
synced 2024-12-19 21:17:58 +00:00
Moved dummy stuff from core into test-utils
This commit is contained in:
parent
d6deeb2bd6
commit
6e570b4d65
@ -1,25 +0,0 @@
|
||||
package net.corda.core.schemas.testing
|
||||
|
||||
/**
|
||||
* An object used to fully qualify the [DummyDealStateSchema] family name (i.e. independent of version).
|
||||
*/
|
||||
object DummyDealStateSchema
|
||||
|
||||
/**
|
||||
* First version of a cash contract ORM schema that maps all fields of the [DummyDealState] contract state as it stood
|
||||
* at the time of writing.
|
||||
*/
|
||||
object DummyDealStateSchemaV1 : net.corda.core.schemas.MappedSchema(schemaFamily = net.corda.core.schemas.testing.DummyDealStateSchema.javaClass, version = 1, mappedTypes = listOf(net.corda.core.schemas.testing.DummyDealStateSchemaV1.PersistentDummyDealState::class.java)) {
|
||||
@javax.persistence.Entity
|
||||
@javax.persistence.Table(name = "dummy_deal_states")
|
||||
class PersistentDummyDealState(
|
||||
|
||||
@javax.persistence.Column(name = "deal_reference")
|
||||
var dealReference: String,
|
||||
|
||||
/** parent attributes */
|
||||
@javax.persistence.Transient
|
||||
val uid: net.corda.core.contracts.UniqueIdentifier
|
||||
|
||||
) : net.corda.node.services.vault.schemas.jpa.CommonSchemaV1.LinearState(uid = uid)
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package net.corda.core.schemas.testing
|
||||
|
||||
/**
|
||||
* Second version of a cash contract ORM schema that extends the common
|
||||
* [VaultLinearState] abstract schema
|
||||
*/
|
||||
object DummyLinearStateSchemaV2 : net.corda.core.schemas.MappedSchema(schemaFamily = DummyLinearStateSchema.javaClass, version = 2,
|
||||
mappedTypes = listOf(net.corda.core.schemas.testing.DummyLinearStateSchemaV2.PersistentDummyLinearState::class.java)) {
|
||||
@javax.persistence.Entity
|
||||
@javax.persistence.Table(name = "dummy_linear_states_v2")
|
||||
class PersistentDummyLinearState(
|
||||
@javax.persistence.Column(name = "linear_string") var linearString: String,
|
||||
|
||||
@javax.persistence.Column(name = "linear_number") var linearNumber: Long,
|
||||
|
||||
@javax.persistence.Column(name = "linear_timestamp") var linearTimestamp: java.time.Instant,
|
||||
|
||||
@javax.persistence.Column(name = "linear_boolean") var linearBoolean: Boolean,
|
||||
|
||||
/** parent attributes */
|
||||
@Transient
|
||||
val uid: net.corda.core.contracts.UniqueIdentifier
|
||||
) : net.corda.node.services.vault.schemas.jpa.CommonSchemaV1.LinearState(uid = uid)
|
||||
}
|
@ -12,7 +12,6 @@ import net.corda.core.node.services.*;
|
||||
import net.corda.core.node.services.vault.*;
|
||||
import net.corda.core.node.services.vault.QueryCriteria.*;
|
||||
import net.corda.core.schemas.*;
|
||||
import net.corda.core.schemas.testing.*;
|
||||
import net.corda.core.transactions.*;
|
||||
import net.corda.core.utilities.*;
|
||||
import net.corda.node.services.database.*;
|
||||
@ -21,6 +20,7 @@ import net.corda.schemas.*;
|
||||
import net.corda.testing.*;
|
||||
import net.corda.testing.contracts.*;
|
||||
import net.corda.testing.node.*;
|
||||
import net.corda.testing.schemas.DummyLinearStateSchemaV1;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.jetbrains.exposed.sql.*;
|
||||
import org.junit.*;
|
||||
|
@ -12,8 +12,8 @@ import net.corda.core.crypto.toBase58String
|
||||
import net.corda.core.node.services.Vault
|
||||
import net.corda.core.node.services.VaultService
|
||||
import net.corda.core.schemas.PersistentStateRef
|
||||
import net.corda.core.schemas.testing.DummyLinearStateSchemaV1
|
||||
import net.corda.core.schemas.testing.DummyLinearStateSchemaV2
|
||||
import net.corda.testing.schemas.DummyLinearStateSchemaV1
|
||||
import net.corda.testing.schemas.DummyLinearStateSchemaV2
|
||||
import net.corda.core.serialization.deserialize
|
||||
import net.corda.core.serialization.storageKryo
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
|
@ -6,7 +6,6 @@ import net.corda.contracts.DealState
|
||||
import net.corda.contracts.asset.Cash
|
||||
import net.corda.contracts.asset.DUMMY_CASH_ISSUER
|
||||
import net.corda.core.contracts.*
|
||||
import net.corda.testing.contracts.DummyLinearContract
|
||||
import net.corda.core.crypto.entropyToKeyPair
|
||||
import net.corda.core.crypto.toBase58String
|
||||
import net.corda.core.days
|
||||
@ -14,10 +13,9 @@ import net.corda.core.identity.Party
|
||||
import net.corda.core.node.services.*
|
||||
import net.corda.core.node.services.vault.*
|
||||
import net.corda.core.node.services.vault.QueryCriteria.*
|
||||
import net.corda.core.schemas.testing.DummyLinearStateSchemaV1
|
||||
import net.corda.core.seconds
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.utilities.toHexString
|
||||
import net.corda.node.services.database.HibernateConfiguration
|
||||
import net.corda.node.services.schema.NodeSchemaService
|
||||
@ -32,6 +30,7 @@ import net.corda.testing.*
|
||||
import net.corda.testing.contracts.*
|
||||
import net.corda.testing.node.MockServices
|
||||
import net.corda.testing.node.makeTestDataSourceProperties
|
||||
import net.corda.testing.schemas.DummyLinearStateSchemaV1
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
@ -48,7 +47,6 @@ import java.time.LocalDate
|
||||
import java.time.ZoneOffset
|
||||
import java.time.temporal.ChronoUnit
|
||||
import java.util.*
|
||||
import kotlin.test.assertFails
|
||||
|
||||
class VaultQueryTests {
|
||||
|
||||
@ -974,7 +972,7 @@ class VaultQueryTests {
|
||||
assertThat(states).hasSize(20)
|
||||
assertThat(metadata.first().contractStateClassName).isEqualTo("net.corda.testing.contracts.DummyLinearContract\$State")
|
||||
assertThat(metadata.first().status).isEqualTo(Vault.StateStatus.UNCONSUMED) // 0 = UNCONSUMED
|
||||
assertThat(metadata.last().contractStateClassName).isEqualTo("net.corda.contracts.DummyDealContract\$State")
|
||||
assertThat(metadata.last().contractStateClassName).isEqualTo("net.corda.contracts.asset.Cash\$State")
|
||||
assertThat(metadata.last().status).isEqualTo(Vault.StateStatus.CONSUMED) // 1 = CONSUMED
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.corda.node.services.vault
|
||||
|
||||
import net.corda.contracts.DummyDealContract
|
||||
import net.corda.testing.contracts.DummyDealContract
|
||||
import net.corda.contracts.asset.Cash
|
||||
import net.corda.contracts.asset.DUMMY_CASH_ISSUER
|
||||
import net.corda.testing.contracts.fillWithSomeTestCash
|
||||
|
@ -1,4 +1,5 @@
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-jpa'
|
||||
apply plugin: 'net.corda.plugins.quasar-utils'
|
||||
apply plugin: 'net.corda.plugins.publish-utils'
|
||||
apply plugin: 'com.jfrog.artifactory'
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.corda.contracts
|
||||
package net.corda.testing.contracts
|
||||
|
||||
import net.corda.contracts.DealState
|
||||
import net.corda.core.contracts.Contract
|
||||
import net.corda.core.contracts.TransactionForContract
|
||||
import net.corda.core.contracts.UniqueIdentifier
|
||||
@ -10,7 +11,7 @@ import net.corda.core.identity.Party
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.core.schemas.PersistentState
|
||||
import net.corda.core.schemas.QueryableState
|
||||
import net.corda.core.schemas.testing.DummyDealStateSchemaV1
|
||||
import net.corda.testing.schemas.DummyDealStateSchemaV1
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import java.security.PublicKey
|
||||
|
@ -10,8 +10,8 @@ import net.corda.core.identity.AbstractParty
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.core.schemas.PersistentState
|
||||
import net.corda.core.schemas.QueryableState
|
||||
import net.corda.core.schemas.testing.DummyLinearStateSchemaV1
|
||||
import net.corda.core.schemas.testing.DummyLinearStateSchemaV2
|
||||
import net.corda.testing.schemas.DummyLinearStateSchemaV1
|
||||
import net.corda.testing.schemas.DummyLinearStateSchemaV2
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneOffset.UTC
|
||||
|
||||
|
@ -4,7 +4,6 @@ package net.corda.testing.contracts
|
||||
|
||||
import net.corda.contracts.Commodity
|
||||
import net.corda.contracts.DealState
|
||||
import net.corda.contracts.DummyDealContract
|
||||
import net.corda.contracts.asset.*
|
||||
import net.corda.core.contracts.*
|
||||
import net.corda.core.identity.AbstractParty
|
||||
|
@ -0,0 +1,33 @@
|
||||
package net.corda.testing.schemas
|
||||
|
||||
import net.corda.core.contracts.UniqueIdentifier
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.node.services.vault.schemas.jpa.CommonSchemaV1
|
||||
import javax.persistence.Column
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.Table
|
||||
import javax.persistence.Transient
|
||||
|
||||
/**
|
||||
* An object used to fully qualify the [DummyDealStateSchema] family name (i.e. independent of version).
|
||||
*/
|
||||
object DummyDealStateSchema
|
||||
|
||||
/**
|
||||
* First version of a cash contract ORM schema that maps all fields of the [DummyDealState] contract state as it stood
|
||||
* at the time of writing.
|
||||
*/
|
||||
object DummyDealStateSchemaV1 : MappedSchema(schemaFamily = DummyDealStateSchema.javaClass, version = 1, mappedTypes = listOf(PersistentDummyDealState::class.java)) {
|
||||
@Entity
|
||||
@Table(name = "dummy_deal_states")
|
||||
class PersistentDummyDealState(
|
||||
|
||||
@Column(name = "deal_reference")
|
||||
var dealReference: String,
|
||||
|
||||
/** parent attributes */
|
||||
@Transient
|
||||
val uid: UniqueIdentifier
|
||||
|
||||
) : CommonSchemaV1.LinearState(uid = uid)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.corda.core.schemas.testing
|
||||
package net.corda.testing.schemas
|
||||
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.core.schemas.PersistentState
|
@ -0,0 +1,31 @@
|
||||
package net.corda.testing.schemas
|
||||
|
||||
import net.corda.core.contracts.UniqueIdentifier
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.node.services.vault.schemas.jpa.CommonSchemaV1
|
||||
import javax.persistence.Column
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.Table
|
||||
|
||||
/**
|
||||
* Second version of a cash contract ORM schema that extends the common
|
||||
* [VaultLinearState] abstract schema
|
||||
*/
|
||||
object DummyLinearStateSchemaV2 : MappedSchema(schemaFamily = DummyLinearStateSchema.javaClass, version = 2,
|
||||
mappedTypes = listOf(PersistentDummyLinearState::class.java)) {
|
||||
@Entity
|
||||
@Table(name = "dummy_linear_states_v2")
|
||||
class PersistentDummyLinearState(
|
||||
@Column(name = "linear_string") var linearString: String,
|
||||
|
||||
@Column(name = "linear_number") var linearNumber: Long,
|
||||
|
||||
@Column(name = "linear_timestamp") var linearTimestamp: java.time.Instant,
|
||||
|
||||
@Column(name = "linear_boolean") var linearBoolean: Boolean,
|
||||
|
||||
/** parent attributes */
|
||||
@Transient
|
||||
val uid: UniqueIdentifier
|
||||
) : CommonSchemaV1.LinearState(uid = uid)
|
||||
}
|
Loading…
Reference in New Issue
Block a user