public class TransactionDSL<T extends TransactionDSLInterpreter> implements TransactionDSLInterpreter
Underlying class for the transaction DSL. Do not instantiate directly, instead use the transaction function.
Verifies.DefaultImpls
Constructor and Description |
---|
TransactionDSL(T interpreter,
Party notary)
Underlying class for the transaction DSL. Do not instantiate directly, instead use the transaction function.
|
Modifier and Type | Method and Description |
---|---|
void |
_attachment(java.lang.String contractClassName)
Attaches an attachment containing the named contract to the transaction
|
void |
_attachment(java.lang.String contractClassName,
SecureHash attachmentId,
java.util.List<? extends java.security.PublicKey> signers)
Attaches an attachment containing the named contract to the transaction
|
void |
_attachment(java.lang.String contractClassName,
SecureHash attachmentId,
java.util.List<? extends java.security.PublicKey> signers,
java.util.Map<java.lang.String,java.lang.String> jarManifestAttributes)
Attaches an attachment containing the named contract to the transaction.
|
EnforceVerifyOrFail |
_tweak(Function1<? super net.corda.testing.dsl.TransactionDSLInterpreter,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)
Creates a local scoped copy of the transaction.
|
void |
attachment(java.lang.String contractClassName) |
void |
attachment(java.lang.String contractClassName,
SecureHash attachmentId,
java.util.List<? extends java.security.PublicKey> signers,
java.util.Map<java.lang.String,java.lang.String> jarManifestAttributes) |
void |
attachment(java.lang.String contractClassName,
SecureHash attachmentId) |
void |
attachment(SecureHash attachmentId)
Adds an
interface Attachment reference to the transaction. |
NonExistentClass |
attachments(java.lang.String contractClassNames) |
NonExistentClass |
command(java.security.PublicKey signer,
CommandData commandData)
Adds a command to the transaction.
|
void |
command(java.util.List<? extends java.security.PublicKey> signers,
CommandData commandData)
Adds a command to the transaction.
|
EnforceVerifyOrFail |
fails()
Asserts that
Verifies.verifies throws, with no condition on the exception message. |
EnforceVerifyOrFail |
fails with(java.lang.String msg) |
EnforceVerifyOrFail |
failsWith(java.lang.String expectedMessage)
Asserts that verifies() throws.
|
LedgerDSLInterpreter<net.corda.testing.dsl.TransactionDSLInterpreter> |
getLedgerInterpreter()
A reference to the enclosing ledger{..}'s interpreter.
|
NonExistentClass |
input(java.lang.String stateLabel)
Looks up the output label and adds the found state as an input.
|
void |
input(java.lang.String contractClassName,
java.lang.String stateLabel) |
void |
input(java.lang.String contractClassName,
ContractState state)
Creates an
LedgerDSLInterpreter._unverifiedTransaction with a single output state and adds its reference as an
input to the current transaction. |
void |
input(StateRef stateRef)
Adds an input reference to the transaction. Note that
Verifies.verifies will resolve this reference. |
void |
output(java.lang.String contractClassName,
java.lang.String label,
Party notary,
ContractState contractState)
Adds a labelled output to the transaction.
|
void |
output(java.lang.String contractClassName,
java.lang.String label,
int encumbrance,
ContractState contractState)
Adds a labelled output to the transaction.
|
void |
output(java.lang.String contractClassName,
java.lang.String label,
ContractState contractState)
Adds a labelled output to the transaction.
|
void |
output(java.lang.String contractClassName,
Party notary,
ContractState contractState)
Adds an output to the transaction.
|
void |
output(java.lang.String contractClassName,
int encumbrance,
ContractState contractState)
Adds an output to the transaction.
|
void |
output(java.lang.String contractClassName,
ContractState contractState)
Adds an output to the transaction.
|
void |
output(java.lang.String contractClassName,
java.lang.String label,
Party notary,
java.lang.Integer encumbrance,
AttachmentConstraint attachmentConstraint,
ContractState contractState)
Adds an output to the transaction.
|
NonExistentClass |
reference(java.lang.String stateLabel)
Looks up the output label and adds the found state as an reference input state.
|
void |
reference(java.lang.String contractClassName,
ContractState state)
Creates an
LedgerDSLInterpreter._unverifiedTransaction with a single reference input state and adds its
reference as in input to the current transaction. |
void |
reference(StateRef stateRef)
Add a reference input state to the transaction. Note that
Verifies.verifies will resolve this reference. |
<S extends ContractState> |
retrieveOutputStateAndRef(java.lang.Class<S> clazz,
java.lang.String label)
Retrieves an output previously defined by
TransactionDSLInterpreter.output with a label passed in. |
void |
timeWindow(java.time.Instant time,
java.time.Duration tolerance)
Sets the
class TimeWindow of the transaction. |
void |
timeWindow(TimeWindow data)
Sets the time-window of the transaction.
|
EnforceVerifyOrFail |
tweak(Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)
Creates a local scoped copy of the transaction.
|
EnforceVerifyOrFail |
verifies()
Verifies the ledger/transaction, throws if the verification fails.
|
_attachment, _attachment, _attachment, _tweak, attachment, command, getLedgerInterpreter, input, output, reference, timeWindow
fails, fails with, failsWith, verifies
retrieveOutputStateAndRef
public TransactionDSL(T interpreter, Party notary)
Underlying class for the transaction DSL. Do not instantiate directly, instead use the transaction function.
public NonExistentClass reference(java.lang.String stateLabel)
Looks up the output label and adds the found state as an reference input state.
stateLabel
- The label of the output state specified when calling TransactionDSLInterpreter.output
and friends.public void reference(java.lang.String contractClassName, ContractState state)
Creates an LedgerDSLInterpreter._unverifiedTransaction
with a single reference input state and adds its
reference as in input to the current transaction.
state
- The state to be added.LedgerDSLInterpreter._unverifiedTransaction
public NonExistentClass input(java.lang.String stateLabel)
Looks up the output label and adds the found state as an input.
stateLabel
- The label of the output state specified when calling TransactionDSLInterpreter.output
and friends.public void input(java.lang.String contractClassName, java.lang.String stateLabel)
public void input(java.lang.String contractClassName, ContractState state)
Creates an LedgerDSLInterpreter._unverifiedTransaction
with a single output state and adds its reference as an
input to the current transaction.
state
- The state to be added.LedgerDSLInterpreter._unverifiedTransaction
public void output(java.lang.String contractClassName, java.lang.String label, Party notary, ContractState contractState)
Adds a labelled output to the transaction.
public void output(java.lang.String contractClassName, java.lang.String label, int encumbrance, ContractState contractState)
Adds a labelled output to the transaction.
public void output(java.lang.String contractClassName, java.lang.String label, ContractState contractState)
Adds a labelled output to the transaction.
public void output(java.lang.String contractClassName, Party notary, ContractState contractState)
Adds an output to the transaction.
public void output(java.lang.String contractClassName, int encumbrance, ContractState contractState)
Adds an output to the transaction.
public void output(java.lang.String contractClassName, ContractState contractState)
Adds an output to the transaction.
public NonExistentClass command(java.security.PublicKey signer, CommandData commandData)
Adds a command to the transaction.
public void timeWindow(java.time.Instant time, java.time.Duration tolerance)
Sets the class TimeWindow
of the transaction.
time
- The Instant of the class TimeWindow
.tolerance
- The tolerance of the class TimeWindow
.class TimeWindow
public EnforceVerifyOrFail tweak(Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)
Creates a local scoped copy of the transaction.
public void attachment(java.lang.String contractClassName)
TransactionDSLInterpreter._attachment
public void attachment(java.lang.String contractClassName, SecureHash attachmentId, java.util.List<? extends java.security.PublicKey> signers, java.util.Map<java.lang.String,java.lang.String> jarManifestAttributes)
public void attachment(java.lang.String contractClassName, SecureHash attachmentId)
public NonExistentClass attachments(java.lang.String contractClassNames)
public LedgerDSLInterpreter<net.corda.testing.dsl.TransactionDSLInterpreter> getLedgerInterpreter()
A reference to the enclosing ledger{..}'s interpreter.
public void _attachment(java.lang.String contractClassName)
Attaches an attachment containing the named contract to the transaction
contractClassName
- The contract class to attachpublic void _attachment(java.lang.String contractClassName, SecureHash attachmentId, java.util.List<? extends java.security.PublicKey> signers)
Attaches an attachment containing the named contract to the transaction
contractClassName
- The contract class to attachattachmentId
- The attachmentpublic void _attachment(java.lang.String contractClassName, SecureHash attachmentId, java.util.List<? extends java.security.PublicKey> signers, java.util.Map<java.lang.String,java.lang.String> jarManifestAttributes)
Attaches an attachment containing the named contract to the transaction.
contractClassName
- The contract class to attach.attachmentId
- The attachment.signers
- The signers.jarManifestAttributes
- The JAR manifest file attributes.public EnforceVerifyOrFail _tweak(Function1<? super net.corda.testing.dsl.TransactionDSLInterpreter,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)
Creates a local scoped copy of the transaction.
dsl
- The transaction DSL to be interpreted using the copy.public void attachment(SecureHash attachmentId)
Adds an interface Attachment
reference to the transaction.
attachmentId
- The hash of the attachment, possibly returned by LedgerDSLInterpreter.attachment
.interface Attachment
public void command(java.util.List<? extends java.security.PublicKey> signers, CommandData commandData)
Adds a command to the transaction.
signers
- The signer public keys.commandData
- The contents of the command.public EnforceVerifyOrFail fails()
Asserts that Verifies.verifies
throws, with no condition on the exception message.
Verifies.verifies
public EnforceVerifyOrFail fails with(java.lang.String msg)
Verifies.failsWith
public EnforceVerifyOrFail failsWith(java.lang.String expectedMessage)
Asserts that verifies() throws.
expectedMessage
- An optional string to be searched for in the raised exception.public void input(StateRef stateRef)
Adds an input reference to the transaction. Note that Verifies.verifies
will resolve this reference.
stateRef
- The input class StateRef
.Verifies.verifies
public void output(java.lang.String contractClassName, java.lang.String label, Party notary, java.lang.Integer encumbrance, AttachmentConstraint attachmentConstraint, ContractState contractState)
Adds an output to the transaction.
label
- An optional label that may be later used to retrieve the output probably in other transactions.notary
- The associated notary.encumbrance
- The position of the encumbrance state.attachmentConstraint
- The attachment constraintcontractState
- The state itself.contractClassName
- The class name of the contract that verifies this state.public void reference(StateRef stateRef)
Add a reference input state to the transaction. Note that Verifies.verifies
will resolve this reference.
stateRef
- The input class StateRef
.Verifies.verifies
public <S extends ContractState> StateAndRef<S> retrieveOutputStateAndRef(java.lang.Class<S> clazz, java.lang.String label)
Retrieves an output previously defined by TransactionDSLInterpreter.output
with a label passed in.
clazz
- The class object holding the type of the output state expected.label
- The label of the to-be-retrieved output state.class StateAndRef
.TransactionDSLInterpreter.output
public void timeWindow(TimeWindow data)
Sets the time-window of the transaction.
data
- the class TimeWindow
(validation window).public EnforceVerifyOrFail verifies()
Verifies the ledger/transaction, throws if the verification fails.