### Question:
LoadLocalDataStep { public Stream<Task<NodeDataRequest>> loadLocalData( final Task<NodeDataRequest> task, final Pipe<Task<NodeDataRequest>> completedTasks) { final NodeDataRequest request = task.getData(); final Optional<Bytes> existingData = request.getExistingData(worldStateStorage); if (existingData.isPresent()) { existingNodeCounter.inc(); request.setData(existingData.get()); request.setRequiresPersisting(false); completedTasks.put(task); return Stream.empty(); } return Stream.of(task); } LoadLocalDataStep(
      final WorldStateStorage worldStateStorage, final MetricsSystem metricsSystem); Stream<Task<NodeDataRequest>> loadLocalData(
      final Task<NodeDataRequest> task, final Pipe<Task<NodeDataRequest>> completedTasks);  }### Answer:
@Test public void shouldReturnStreamWithUnchangedTaskWhenDataNotPresent() { final Stream<Task<NodeDataRequest>> output = loadLocalDataStep.loadLocalData(task, completedTasks); assertThat(completedTasks.poll()).isNull(); assertThat(output).containsExactly(task); }
@Test public void shouldReturnEmptyStreamAndSendTaskToCompletedPipeWhenDataIsPresent() { when(worldStateStorage.getCode(HASH)).thenReturn(Optional.of(DATA)); final Stream<Task<NodeDataRequest>> output = loadLocalDataStep.loadLocalData(task, completedTasks); assertThat(completedTasks.poll()).isSameAs(task); assertThat(request.getData()).isEqualTo(DATA); assertThat(output).isEmpty(); request.persist(updater); verifyZeroInteractions(updater); }