TrackingEndpointRunnableFactory implements EndpointRunnableFactory { public Runnable create( OngoingRequest ongoingRequest, RequestContext requestContext, Endpoint endpoint) { incomingCallsGatherer.gatherIncomingCall(ongoingRequest, endpoint); final OngoingRequest trackedRequest = new TrackedOngoingRequestImpl(ongoingRequest, requestTracker); return delegate.create(trackedRequest, requestContext, endpoint); } TrackingEndpointRunnableFactory(
      EndpointRunnableFactory delegate,
      IncomingCallsGatherer incomingCallsGatherer,
      RequestTracker requestTracker); Runnable create(
      OngoingRequest ongoingRequest,
      RequestContext requestContext,
      Endpoint endpoint);  }
@Test public void shouldRunDelegate() throws Exception { endpointRunnableFactory.create(ongoingRequest, requestContext, endpoint).run(); verify(delegateRunnable).run(); }
@Test public void shouldGatherCalls() throws Exception { endpointRunnableFactory.create(ongoingRequest, requestContext, endpoint).run(); verify(incomingCallsGatherer).gatherIncomingCall(eq(ongoingRequest), eq(endpoint)); }