### Question:
EthGetUncleByBlockHashAndIndex implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { return new JsonRpcSuccessResponse( requestContext.getRequest().getId(), blockResult(requestContext)); } EthGetUncleByBlockHashAndIndex(final BlockchainQueries blockchain); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldReturnErrorWhenMissingBlockHashParam() { final JsonRpcRequestContext request = getUncleByBlockHashAndIndex(new Object[] {}); final Throwable thrown = catchThrowable(() -> method.response(request)); assertThat(thrown) .isInstanceOf(InvalidJsonRpcParameters.class) .hasMessage("Missing required json rpc parameter at index 0"); }
@Test public void shouldReturnErrorWhenMissingIndexParam() { final JsonRpcRequestContext request = getUncleByBlockHashAndIndex(new Object[] {zeroHash}); final Throwable thrown = catchThrowable(() -> method.response(request)); assertThat(thrown) .isInstanceOf(InvalidJsonRpcParameters.class) .hasMessage("Missing required json rpc parameter at index 1"); }
@Test public void shouldReturnErrorWhenInvalidBlockHashParam() { final JsonRpcRequestContext request = getUncleByBlockHashAndIndex(new Object[] {"not-a-hash"}); final Throwable thrown = catchThrowable(() -> method.response(request)); assertThat(thrown) .isInstanceOf(InvalidJsonRpcParameters.class) .hasMessage("Invalid json rpc parameter at index 0"); }
@Test public void shouldReturnErrorWhenInvalidIndexParam() { final JsonRpcRequestContext request = getUncleByBlockHashAndIndex(new Object[] {zeroHash, "not-an-index"}); final Throwable thrown = catchThrowable(() -> method.response(request)); assertThat(thrown) .isInstanceOf(InvalidJsonRpcParameters.class) .hasMessage("Invalid json rpc parameter at index 1"); }
@Test public void shouldReturnNullResultWhenBlockDoesNotHaveOmmer() { final JsonRpcRequestContext request = getUncleByBlockHashAndIndex(new Object[] {zeroHash, "0x0"}); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, null); when(blockchainQueries.getOmmer(eq(zeroHash), eq(0))).thenReturn(Optional.empty()); final JsonRpcResponse response = method.response(request); assertThat(response).isEqualToComparingFieldByFieldRecursively(expectedResponse); }