LedgerDSL
Keywords: net.corda.testing.dsl.LedgerDSL class
Date: 2023-09-18

net.corda.testing.dsl

## Class LedgerDSL<T extends TransactionDSLInterpreter,L extends LedgerDSLInterpreter<? extends T>>

- net.corda.testing.dsl.LedgerDSL<T,L>

- All Implemented Interfaces:
    LedgerDSLInterpreter<T>, OutputStateLookup, Verifies

      public class LedgerDSL<T extends TransactionDSLInterpreter,L extends LedgerDSLInterpreter<? extends T>>
      implements LedgerDSLInterpreter<T>

  This is the class that defines the syntactic sugar of the ledger Test DSL and delegates to the contained interpreter, and what is actually used in `ledger { (...) }`. Add convenience functions here, or if you want to extend the DSL functionality then first add your primitive to `interface LedgerDSLInterpreter` and then add the convenience defaults/extension methods here.

  See Also:
    `interface LedgerDSLInterpreter`

- - ### Constructor Detail

    - #### LedgerDSL

          public LedgerDSL(@NotNull
                           L interpreter,
                           @NotNull
                           Party notary)

      This is the class that defines the syntactic sugar of the ledger Test DSL and delegates to the contained interpreter, and what is actually used in `ledger { (...) }`. Add convenience functions here, or if you want to extend the DSL functionality then first add your primitive to `interface LedgerDSLInterpreter` and then add the convenience defaults/extension methods here.

      See Also:
        `interface LedgerDSLInterpreter`

  - ### Method Detail

    - #### transaction

          @JvmOverloads
           @NotNull
          public WireTransaction transaction(@Nullable
                                                                     java.lang.String label,
                                                                     @NotNull
                                                                     TransactionBuilder transactionBuilder,
                                                                     @NotNull
                                                                     kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)

      Creates and adds a transaction to the ledger.

    - #### transaction

          @JvmOverloads
           @NotNull
          public WireTransaction transaction(@Nullable
                                                                     java.lang.String label,
                                                                     @NotNull
                                                                     kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)

      Creates and adds a transaction to the ledger.

    - #### transaction

          @JvmOverloads
           @NotNull
          public WireTransaction transaction(@NotNull
                                                                     kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)

      Creates and adds a transaction to the ledger.

    - #### unverifiedTransaction

          @JvmOverloads
           @NotNull
          public WireTransaction unverifiedTransaction(@Nullable
                                                                               java.lang.String label,
                                                                               @NotNull
                                                                               TransactionBuilder transactionBuilder,
                                                                               @NotNull
                                                                               kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,kotlin.Unit> dsl)

      Creates and adds a transaction to the ledger that will not be verified by verifies.

    - #### unverifiedTransaction

          @JvmOverloads
           @NotNull
          public WireTransaction unverifiedTransaction(@Nullable
                                                                               java.lang.String label,
                                                                               @NotNull
                                                                               kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,kotlin.Unit> dsl)

      Creates and adds a transaction to the ledger that will not be verified by verifies.

    - #### unverifiedTransaction

          @JvmOverloads
           @NotNull
          public WireTransaction unverifiedTransaction(@NotNull
                                                                               kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,kotlin.Unit> dsl)

      Creates and adds a transaction to the ledger that will not be verified by verifies.

    - #### tweak

          public void tweak(@NotNull
                            kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.LedgerDSL<? extends T,? extends L>,kotlin.Unit> dsl)

      Creates a local scoped copy of the ledger.

    - #### retrieveOutput

          @NotNull
          public <S extends ContractState> S retrieveOutput(@NotNull
                                                                     java.lang.Class<S> clazz,
                                                                     @NotNull
                                                                     java.lang.String label)

      Retrieves an output previously defined by TransactionDSLInterpreter._output with a label passed in.

      See Also:
        TransactionDSLInterpreter._output

    - #### getInterpreter

          @NotNull
          public L getInterpreter()

    - #### _transaction

          @NotNull
          public WireTransaction _transaction(@Nullable
                                                       java.lang.String transactionLabel,
                                                       @NotNull
                                                       TransactionBuilder transactionBuilder,
                                                       @NotNull
                                                       kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSLInterpreter,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)

      Creates and adds a transaction to the ledger.

      Parameters:
        `transactionLabel` - Optional label of the transaction, to be used in diagnostic messages.
        `transactionBuilder` - The base transactionBuilder that will be used to build the transaction.
        `dsl` - The dsl that should be interpreted for building the transaction.
      Returns:
        The final `class WireTransaction` of the built transaction.

    - #### _tweak

          public void _tweak(@NotNull
                             kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.LedgerDSLInterpreter<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,kotlin.Unit> dsl)

      Creates a local scoped copy of the ledger.

      Parameters:
        `dsl` - The ledger DSL to be interpreted using the copy.

    - #### _unverifiedTransaction

          @NotNull
          public WireTransaction _unverifiedTransaction(@Nullable
                                                                 java.lang.String transactionLabel,
                                                                 @NotNull
                                                                 TransactionBuilder transactionBuilder,
                                                                 @NotNull
                                                                 kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSLInterpreter,kotlin.Unit> dsl)

      Creates and adds a transaction to the ledger that will not be verified by `verifies`.

      Parameters:
        `transactionLabel` - Optional label of the transaction, to be used in diagnostic messages.
        `transactionBuilder` - The base transactionBuilder that will be used to build the transaction.
        `dsl` - The dsl that should be interpreted for building the transaction.
      Returns:
        The final `class WireTransaction` of the built transaction.
      See Also:
        `verifies`

    - #### attachment

          @NotNull
          public SecureHash attachment(@NotNull
                                                java.io.InputStream attachment)

      Adds an attachment to the ledger.

      Parameters:
        `attachment` - The InputStream defining the contents of the attachment.
      Returns:
        The `class SecureHash` that identifies the attachment, to be used in transactions.

    - #### fails

          @NotNull
          public EnforceVerifyOrFail fails()

      Asserts that `verifies` throws, with no condition on the exception message.

      See Also:
        `verifies`

    - #### fails with

          @NotNull
          public EnforceVerifyOrFail fails with(@NotNull
                                                         java.lang.String msg)

      See Also:
        `failsWith`

    - #### failsWith

          @NotNull
          public EnforceVerifyOrFail failsWith(@Nullable
                                                        java.lang.String expectedMessage)

      Asserts that verifies() throws.

      Parameters:
        `expectedMessage` - An optional string to be searched for in the raised exception.

    - #### retrieveOutputStateAndRef

          @NotNull
          public <S extends ContractState> StateAndRef<S> retrieveOutputStateAndRef(@NotNull
                                                                                             java.lang.Class<S> clazz,
                                                                                             @NotNull
                                                                                             java.lang.String label)

      Retrieves an output previously defined by `TransactionDSLInterpreter.output` with a label passed in.

      Parameters:
        `clazz` - The class object holding the type of the output state expected.
        `label` - The label of the to-be-retrieved output state.
      Returns:
        The output `class StateAndRef`.
      See Also:
        `TransactionDSLInterpreter.output`

    - #### verifies

          @NotNull
          public EnforceVerifyOrFail verifies()

      Verifies the ledger/transaction, throws if the verification fails.