### Question:
StoreStreamingProcess { void perform( ChannelHandlerContext ctx ) throws IOException { CheckPointer checkPointer = checkPointerSupplier.get(); Resource checkPointLock = mutex.storeCopy( () -> checkPointer.tryCheckPoint( new SimpleTriggerInfo( "Store copy" ) ) ); Future<Void> completion = null; try ( RawCursor<StoreResource,IOException> resources = resourceStreamFactory.create() ) { while ( resources.next() ) { StoreResource resource = resources.get(); protocol.stream( ctx, resource ); } completion = protocol.end( ctx, SUCCESS ); } finally { if ( completion != null ) { completion.addListener( f -> checkPointLock.close() ); } else { checkPointLock.close(); } } } StoreStreamingProcess( StoreFileStreamingProtocol protocol, Supplier<CheckPointer> checkPointerSupplier, StoreCopyCheckPointMutex mutex,
            StoreResourceStreamFactory resourceStreamFactory ); void fail( ChannelHandlerContext ctx, StoreCopyFinishedResponse.Status failureCode );  }### Answer:
@Test public void shouldPerformSuccessfulStoreCopyProcess() throws Exception { StoreStreamingProcess process = new StoreStreamingProcess( protocol, checkPointerSupplier, mutex, resourceStream ); ImmediateEventExecutor eventExecutor = ImmediateEventExecutor.INSTANCE; Promise<Void> completionPromise = eventExecutor.newPromise(); long lastCheckpointedTxId = 1000L; RawCursor<StoreResource,IOException> resources = rawCursorOf(); when( checkPointer.tryCheckPoint( any() ) ).thenReturn( lastCheckpointedTxId ); when( checkPointer.lastCheckPointedTransactionId() ).thenReturn( lastCheckpointedTxId ); when( protocol.end( ctx, SUCCESS ) ).thenReturn( completionPromise ); when( resourceStream.create() ).thenReturn( resources ); process.perform( ctx ); InOrder inOrder = Mockito.inOrder( protocol, checkPointer ); inOrder.verify( checkPointer ).tryCheckPoint( any() ); inOrder.verify( protocol ).end( ctx, SUCCESS ); inOrder.verifyNoMoreInteractions(); assertEquals( 1, lock.getReadLockCount() ); completionPromise.setSuccess( null ); assertEquals( 0, lock.getReadLockCount() ); }