### Question:
EthCoinbase implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { final Optional<Address> coinbase = miningCoordinator.getCoinbase(); if (coinbase.isPresent()) { return new JsonRpcSuccessResponse( requestContext.getRequest().getId(), coinbase.get().toString()); } return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.COINBASE_NOT_SPECIFIED); } EthCoinbase(final MiningCoordinator miningCoordinator); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldReturnExpectedValueWhenMiningCoordinatorExists() { final JsonRpcRequestContext request = requestWithParams(); final String expectedAddressString = "fe3b557e8fb62b89f4916b721be55ceb828dbd73"; final Address expectedAddress = Address.fromHexString(expectedAddressString); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), "0x" + expectedAddressString); when(miningCoordinator.getCoinbase()).thenReturn(Optional.of(expectedAddress)); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); verify(miningCoordinator).getCoinbase(); verifyNoMoreInteractions(miningCoordinator); }
@Test public void shouldReturnErrorWhenCoinbaseNotSpecified() { final JsonRpcRequestContext request = requestWithParams(); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.COINBASE_NOT_SPECIFIED); when(miningCoordinator.getCoinbase()).thenReturn(Optional.empty()); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); }