### Question:
SyncManager extends Service { public long subscribeToSyncChanges(final SyncSubscriber subscriber) { return syncSubscribers.subscribe(subscriber); } SyncManager(
      final AsyncRunner asyncRunner,
      final P2PNetwork<Eth2Peer> network,
      final RecentChainData storageClient,
      final PeerSync peerSync); static SyncManager create(
      final AsyncRunner asyncRunner,
      final P2PNetwork<Eth2Peer> network,
      final RecentChainData storageClient,
      final BlockImporter blockImporter,
      final MetricsSystem metricsSystem); long subscribeToSyncChanges(final SyncSubscriber subscriber); void unsubscribeFromSyncChanges(final long subscriberId); SyncingStatus getSyncStatus();  }### Answer:
@Test void subscribeToSyncChanges_notifiedWhenFirstSyncStarts() { syncManager.subscribeToSyncChanges(syncSubscriber); when(network.streamPeers()).then(i -> Stream.of(peer)); when(peerSync.sync(peer)).thenReturn(new SafeFuture<>()); assertThat(syncManager.start()).isCompleted(); verify(syncSubscriber).onSyncingChange(true); verifyNoMoreInteractions(syncSubscriber); }
@Test void subscribeToSyncChanges_notifiedWhenSyncCompletes() { syncManager.subscribeToSyncChanges(syncSubscriber); when(network.streamPeers()).then(i -> Stream.of(peer)); final SafeFuture<PeerSyncResult> syncFuture = new SafeFuture<>(); when(peerSync.sync(peer)).thenReturn(syncFuture); assertThat(syncManager.start()).isCompleted(); verify(syncSubscriber).onSyncingChange(true); verifyNoMoreInteractions(syncSubscriber); syncFuture.complete(PeerSyncResult.SUCCESSFUL_SYNC); verify(syncSubscriber).onSyncingChange(false); verifyNoMoreInteractions(syncSubscriber); }
@Test void subscribeToSyncChanges_notNotifiedWhenSyncFailsToFindPeersToSyncTo() { syncManager.subscribeToSyncChanges(syncSubscriber); when(network.streamPeers()).thenReturn(Stream.empty()); final SafeFuture<PeerSyncResult> sync1Future = new SafeFuture<>(); when(peerSync.sync(peer)).thenReturn(sync1Future); assertThat(syncManager.start()).isCompleted(); verifyNoInteractions(syncSubscriber); }