### Question:
EthChainId implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { return new JsonRpcSuccessResponse( requestContext.getRequest().getId(), chainId.map(Quantity::create).orElse(null)); } EthChainId(final Optional<BigInteger> chainId); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldReturnChainId() { final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, Quantity.create(CHAIN_ID)); final JsonRpcResponse response = method.response(request()); assertThat(response).isEqualToComparingFieldByField(expectedResponse); }
@Test public void shouldReturnNullWhenNoChainId() { method = new EthChainId(Optional.empty()); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, null); final JsonRpcResponse response = method.response(request()); assertThat(response).isEqualToComparingFieldByField(expectedResponse); }