### Question:
StatusMessageHandler extends PeerRequiredLocalMessageHandler<StatusMessage, StatusMessage> { @Override public void onIncomingMessage( final Eth2Peer peer, final StatusMessage message, final ResponseCallback<StatusMessage> callback) { LOG.trace("Peer {} sent status {}", peer.getId(), message); if (!peer.wantToMakeRequest()) { return; } final PeerStatus status = PeerStatus.fromStatusMessage(message); peer.updateStatus(status); final Optional<StatusMessage> localStatus = statusMessageFactory.createStatusMessage(); if (localStatus.isPresent()) { callback.respondAndCompleteSuccessfully(localStatus.get()); } else { LOG.warn( "Node is not ready to receive p2p traffic. Responding to incoming status message with an error."); callback.completeWithErrorResponse(NODE_NOT_READY); } } StatusMessageHandler(final StatusMessageFactory statusMessageFactory); @Override void onIncomingMessage(
      final Eth2Peer peer,
      final StatusMessage message,
      final ResponseCallback<StatusMessage> callback);  }### Answer:
@Test public void shouldReturnLocalStatus() { when(statusMessageFactory.createStatusMessage()).thenReturn(Optional.of(LOCAL_STATUS)); handler.onIncomingMessage(peer, REMOTE_STATUS, callback); verify(peer).updateStatus(PEER_STATUS); verify(callback).respondAndCompleteSuccessfully(LOCAL_STATUS); verifyNoMoreInteractions(callback); }
@Test public void shouldRespondWithErrorIfStatusUnavailable() { when(statusMessageFactory.createStatusMessage()).thenReturn(Optional.empty()); handler.onIncomingMessage(peer, REMOTE_STATUS, callback); verify(peer).updateStatus(PEER_STATUS); verify(callback).completeWithErrorResponse(NODE_NOT_READY); }