StartedMockNode
Keywords: net.corda.testing.node.StartedMockNode class
Date: 2023-09-18

net.corda.testing.node

## Class StartedMockNode

- net.corda.testing.node.StartedMockNode

-     public class StartedMockNode

  A class that represents a started mock node for testing.

- - ### Field Detail

    - #### Companion

          public static net.corda.testing.node.StartedMockNode.Companion Companion

  - ### Method Detail

    - #### getServices

          @NotNull
          public ServiceHub getServices()

      The `interface ServiceHub` for the underlying node.

      See Also:
        `interface ServiceHub`

    - #### getId

          public int getId()

      An identifier for the node. By default this is allocated sequentially in a `class MockNetwork`.

      See Also:
        `class MockNetwork`

    - #### getInfo

          @NotNull
          public NodeInfo getInfo()

      The `class NodeInfo` for the underlying node.

      See Also:
        `class NodeInfo`

    - #### startFlow

          @NotNull
          public <T> CordaFuture<T> startFlow(@NotNull
                                                       FlowLogic<? extends T> logic)

      Starts an already constructed flow. Note that you must be on the server thread to call this method.

    - #### registerInitiatedFlow

          @NotNull
          public <F extends FlowLogic<?>> rx.Observable<F> registerInitiatedFlow(@NotNull
                                                                                          java.lang.Class<F> initiatedFlowClass)

      Manually register an initiating-responder flow pair based on the `class FlowLogic` annotations.

      NOTE: There is no need to call this method if the flow pair is defined in the CorDapp and the `class TestCordapp` API is used.

      Parameters:
        `initiatedFlowClass` - `class FlowLogic` class which is annotated with `annotationclass InitiatedBy`.
      Returns:
        An Observable which emits responder flows each time one is executed.
      See Also:
        `class FlowLogic`, `class TestCordapp`

    - #### registerInitiatedFlow

          @NotNull
          public <F extends FlowLogic<?>> rx.Observable<F> registerInitiatedFlow(@NotNull
                                                                                          java.lang.Class<? extends net.corda.core.flows.FlowLogic<?>> initiatingFlowClass,
                                                                                          @NotNull
                                                                                          java.lang.Class<F> initiatedFlowClass)

      Register a custom relationship between initiating and receiving flow on a node-by-node basis. This is used when we want to manually specify that a particular initiating flow class will have a particular responder.

      Note that this change affects only the node on which this method is called, and not the entire network.

      Parameters:
        `initiatingFlowClass` - The `class FlowLogic`-inheriting class to register a new responder for.
        `initiatedFlowClass` - The class of the responder flow.
      Returns:
        An Observable which emits responder flows each time one is executed.

    - #### stop

          public void stop()

      Stop the node.

    - #### pumpReceive

          @Nullable
          public net.corda.testing.node.InMemoryMessagingNetwork.MessageTransfer pumpReceive(boolean block)

      Delivers a single message from the internal queue. If there are no messages waiting to be delivered and block is true, waits until one has been provided on a different thread via send. If block is false, the return result indicates whether a message was delivered or not.

      Returns:
        the message that was processed, if any in this round.

    - #### findStateMachines

          @NotNull
          public <F extends FlowLogic<?>> java.util.List<kotlin.Pair> findStateMachines(@NotNull
                                                                                                 java.lang.Class<F> flowClass)

      Returns the currently live flows of type `flowClass`, and their corresponding result future.

      See Also:
        `flowClass`

    - #### transaction

          public <T> T transaction(@NotNull
                                   kotlin.jvm.functions.Function0<? extends T> statement)

      Executes given statement in the scope of transaction.

      Parameters:
        `statement` - to be executed in the scope of this transaction.