### Question:
SyncController { public void onTargetChainsUpdated() { eventThread.checkOnEventThread(); final boolean currentlySyncing = isSyncActive(); final Optional<InProgressSync> newSync = selectNewSyncTarget(currentlySyncing); if (newSync.isEmpty() && currentlySyncing) { return; } if (!currentlySyncing && newSync.isPresent()) { notifySubscribers(true); } currentSync = newSync; } SyncController(
      final EventThread eventThread,
      final Executor subscriberExecutor,
      final RecentChainData recentChainData,
      final ChainSelector finalizedTargetChainSelector,
      final ChainSelector nonfinalizedTargetChainSelector,
      final Sync sync); void onTargetChainsUpdated(); boolean isSyncActive(); SyncingStatus getSyncStatus(); long subscribeToSyncChanges(final SyncSubscriber subscriber); void unsubscribeFromSyncChanges(final long subscriberId);  }### Answer:
@Test void shouldNotOverwriteCurrentSyncWhenChainsUpdatedButNoBetterChainAvailable() { ignoreFuture(startFinalizedSync()); verify(sync).syncToChain(targetChain); onTargetChainsUpdated(); verifyNoMoreInteractions(sync); }
@Test void shouldStartNonFinalizedSyncWhenNoSuitableFinalizedTargetChainAvailable() { when(finalizedChainSelector.selectTargetChain(false)).thenReturn(Optional.empty()); when(nonfinalizedChainSelector.selectTargetChain(false)).thenReturn(Optional.of(targetChain)); when(sync.syncToChain(targetChain)).thenReturn(new SafeFuture<>()); onTargetChainsUpdated(); ignoreFuture(verify(sync).syncToChain(targetChain)); }