AnalysisInteractor { public CompletableFuture<NetworkRequestResult<GiniVisionDocument>> deleteDocument( final GiniVisionDocument document) { if (GiniVision.hasInstance()) { final NetworkRequestsManager networkRequestsManager = GiniVision.getInstance() .internal().getNetworkRequestsManager(); if (networkRequestsManager != null) { networkRequestsManager.cancel(document); return networkRequestsManager.delete(document); } } return CompletableFuture.completedFuture(null); } AnalysisInteractor(@NonNull final Application app); CompletableFuture<ResultHolder> analyzeMultiPageDocument(
            final GiniVisionMultiPageDocument<GiniVisionDocument, GiniVisionDocumentError>
                    multiPageDocument); CompletableFuture<Void> deleteMultiPageDocument(
            final GiniVisionMultiPageDocument<GiniVisionDocument, GiniVisionDocumentError>
                    multiPageDocument); CompletableFuture<NetworkRequestResult<GiniVisionDocument>> deleteDocument(
            final GiniVisionDocument document);  }
@Test public void should_notDeleteDocument_whenGiniVision_isNotAvailable() throws Exception { final GiniVisionDocument document = mock(GiniVisionDocument.class); final CompletableFuture<NetworkRequestResult<GiniVisionDocument>> future = mAnalysisInteractor.deleteDocument( document); assertThat(future.get()).isNull(); }
@Test public void should_notDeleteDocument_whenNetworkRequestsManager_isNotAvailable() throws Exception { final GiniVisionDocument document = mock(GiniVisionDocument.class); createGiniVision(null); final CompletableFuture<NetworkRequestResult<GiniVisionDocument>> future = mAnalysisInteractor.deleteDocument( document); assertThat(future.get()).isNull(); }
@Test public void should_deleteDocument() throws Exception { final GiniVisionDocument document = mock(GiniVisionDocument.class); final NetworkRequestResult<GiniVisionDocument> deletionRequestResult = mock( NetworkRequestResult.class); final NetworkRequestsManager networkRequestsManager = createtNetworkRequestsManager( deletionRequestResult); createGiniVision(networkRequestsManager); mAnalysisInteractor.deleteDocument(document); verify(networkRequestsManager).cancel(document); verify(networkRequestsManager).delete(document); }