### Question:
EthSyncing implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { final Object result = synchronizer.getSyncStatus().map(s -> (Object) new SyncingResult(s)).orElse(false); return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result); } EthSyncing(final Synchronizer synchronizer); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldReturnFalseWhenSyncStatusIsEmpty() { final JsonRpcRequestContext request = requestWithParams(); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), false); final Optional<SyncStatus> optionalSyncStatus = Optional.empty(); when(synchronizer.getSyncStatus()).thenReturn(optionalSyncStatus); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); verify(synchronizer).getSyncStatus(); verifyNoMoreInteractions(synchronizer); }
@Test public void shouldReturnExpectedValueWhenSyncStatusIsNotEmpty() { final JsonRpcRequestContext request = requestWithParams(); final SyncStatus expectedSyncStatus = new DefaultSyncStatus(0, 1, 2, Optional.empty(), Optional.empty()); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse( request.getRequest().getId(), new SyncingResult(expectedSyncStatus)); final Optional<SyncStatus> optionalSyncStatus = Optional.of(expectedSyncStatus); when(synchronizer.getSyncStatus()).thenReturn(optionalSyncStatus); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); verify(synchronizer).getSyncStatus(); verifyNoMoreInteractions(synchronizer); }
@Test public void shouldReturnExpectedValueWhenFastSyncStatusIsNotEmpty() { final JsonRpcRequestContext request = requestWithParams(); final SyncStatus expectedSyncStatus = new DefaultSyncStatus(0, 1, 2, Optional.of(3L), Optional.of(4L)); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse( request.getRequest().getId(), new SyncingResult(expectedSyncStatus)); final Optional<SyncStatus> optionalSyncStatus = Optional.of(expectedSyncStatus); when(synchronizer.getSyncStatus()).thenReturn(optionalSyncStatus); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); verify(synchronizer).getSyncStatus(); verifyNoMoreInteractions(synchronizer); }