AnalysisScreenPresenter extends AnalysisScreenContract.Presenter { @Override public void stop() { mStopped = true; stopScanAnimation(); if (!mAnalysisCompleted) { deleteUploadedDocuments(); } else if (GiniVision.hasInstance()) { GiniVision.getInstance().internal().getImageMultiPageDocumentMemoryStore() .clear(); } } AnalysisScreenPresenter(
            @NonNull final Activity activity,
            @NonNull final AnalysisScreenContract.View view,
            @NonNull final Document document,
            @Nullable final String documentAnalysisErrorMessage); @VisibleForTesting  AnalysisScreenPresenter(
            @NonNull final Activity activity,
            @NonNull final AnalysisScreenContract.View view,
            @NonNull final Document document,
            @Nullable final String documentAnalysisErrorMessage,
            @NonNull final AnalysisInteractor analysisInteractor); @Override void hideError(); @Override void onNoExtractionsFound(); @Override void onDocumentAnalyzed(); @Override void showError(@NonNull final String message, final int duration); @Override void showError(@NonNull final String message, @NonNull final String buttonTitle,
            @NonNull final View.OnClickListener onClickListener); @Override void startScanAnimation(); @Override void stopScanAnimation(); @Override void setListener(@NonNull final AnalysisFragmentListener listener); @Override void start(); @Override void stop();  }
@Test public void should_stopScanAnimation_whenStopped() throws Exception { final ImageDocument imageDocument = new ImageDocumentFake(); final AnalysisScreenPresenter presenter = createPresenter(imageDocument); presenter.stop(); verify(mView).hideScanAnimation(); }
@Test public void should_deleteUploadedDocument_ifAnalysisDidntComplete_whenStopped() throws Exception { final ImageDocument imageDocument = new ImageDocumentFake(); final AnalysisInteractor analysisInteractor = mock(AnalysisInteractor.class); final AnalysisScreenPresenter presenter = createPresenter(imageDocument, analysisInteractor); presenter.stop(); verify(analysisInteractor).deleteDocument(any(GiniVisionDocument.class)); }
@Test public void should_deleteMultiPageUploadedDocuments_forPdfs_ifAnalysisDidntComplete_whenStopped() throws Exception { final PdfDocument pdfDocument = new PdfDocumentFake(); final AnalysisInteractor analysisInteractor = mock(AnalysisInteractor.class); final AnalysisScreenPresenter presenter = createPresenter(pdfDocument, analysisInteractor); presenter.stop(); verify(analysisInteractor).deleteMultiPageDocument(any(GiniVisionMultiPageDocument.class)); }