Class CapturingTransport

All Implemented Interfaces:
Closeable, AutoCloseable, org.opensearch.common.lease.Releasable, org.opensearch.common.lifecycle.LifecycleComponent, org.opensearch.transport.Transport

public class CapturingTransport extends MockTransport implements org.opensearch.transport.Transport
A transport class that doesn't send anything but rather captures all requests for inspection from tests
  • Constructor Details

    • CapturingTransport

      public CapturingTransport()
  • Method Details

    • capturedRequests

      public CapturingTransport.CapturedRequest[] capturedRequests()
      returns all requests captured so far. Doesn't clear the captured request list. See clear()
    • getCapturedRequestsAndClear

      public CapturingTransport.CapturedRequest[] getCapturedRequestsAndClear()
      Returns all requests captured so far. This method does clear the captured requests list. If you do not want the captured requests list cleared, use capturedRequests().
      Returns:
      the captured requests
    • capturedRequestsByTargetNode

      public Map<String, List<CapturingTransport.CapturedRequest>> capturedRequestsByTargetNode()
      returns all requests captured so far, grouped by target node. Doesn't clear the captured request list. See clear()
    • getCapturedRequestsByTargetNodeAndClear

      public Map<String, List<CapturingTransport.CapturedRequest>> getCapturedRequestsByTargetNodeAndClear()
      Returns all requests captured so far, grouped by target node. This method does clear the captured request list. If you do not want the captured requests list cleared, use capturedRequestsByTargetNode().
      Returns:
      the captured requests grouped by target node
    • clear

      public void clear()
      clears captured requests
    • onSendRequest

      protected void onSendRequest(long requestId, String action, org.opensearch.transport.TransportRequest request, org.opensearch.cluster.node.DiscoveryNode node)
      Overrides:
      onSendRequest in class MockTransport
    • onSendRequest

      protected void onSendRequest(long requestId, String action, org.opensearch.transport.TransportRequest request, org.opensearch.cluster.node.DiscoveryNode node, org.opensearch.transport.TransportRequestOptions options)
      Overrides:
      onSendRequest in class MockTransport