### Question:
PersistentSnapshotDownloader implements Runnable { @Override public void run() { if ( !moveToRunningState() ) { return; } try { monitor.startedDownloadingSnapshot(); applicationProcess.pauseApplier( OPERATION_NAME ); while ( keepRunning && !downloader.downloadSnapshot( addressProvider ) ) { Thread.sleep( timeout.getMillis() ); timeout.increment(); } } catch ( InterruptedException e ) { Thread.currentThread().interrupt(); log.warn( "Persistent snapshot downloader was interrupted" ); } catch ( DatabaseShutdownException e ) { log.warn( "Store copy aborted due to shut down", e ); } catch ( Throwable e ) { log.error( "Unrecoverable error during store copy", e ); dbHealth.get().panic( e ); } finally { applicationProcess.resumeApplier( OPERATION_NAME ); monitor.downloadSnapshotComplete(); state = State.COMPLETED; } } PersistentSnapshotDownloader( CatchupAddressProvider addressProvider, CommandApplicationProcess applicationProcess,
            CoreStateDownloader downloader, Log log, TimeoutStrategy.Timeout pauseStrategy,
            Supplier<DatabaseHealth> dbHealth, Monitors monitors ); @Override void run();  }### Answer:
@Test public void shouldNotStartDownloadIfAlreadyCompleted() throws Exception { CoreStateDownloader coreStateDownloader = mock( CoreStateDownloader.class ); when( coreStateDownloader.downloadSnapshot( any() ) ).thenReturn( true ); final CommandApplicationProcess applicationProcess = mock( CommandApplicationProcess.class ); final Log log = mock( Log.class ); PersistentSnapshotDownloader persistentSnapshotDownloader = new PersistentSnapshotDownloader( catchupAddressProvider, applicationProcess, coreStateDownloader, log, new NoTimeout(), () -> dbHealth, new Monitors() ); persistentSnapshotDownloader.run(); persistentSnapshotDownloader.run(); verify( coreStateDownloader, times( 1 ) ).downloadSnapshot( catchupAddressProvider ); verify( applicationProcess, times( 1 ) ).pauseApplier( OPERATION_NAME ); verify( applicationProcess, times( 1 ) ).resumeApplier( OPERATION_NAME ); }