### Question:
EthGetFilterLogs implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { final String filterId = requestContext.getRequiredParameter(0, String.class); final List<LogWithMetadata> logs = filterManager.logs(filterId); if (logs != null) { return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), new LogsResult(logs)); } return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.LOGS_FILTER_NOT_FOUND); } EthGetFilterLogs(final FilterManager filterManager); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldReturnErrorWhenMissingParams() { final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", "eth_getFilterLogs", new Object[] {})); final Throwable thrown = catchThrowable(() -> method.response(request)); assertThat(thrown) .isInstanceOf(InvalidJsonRpcParameters.class) .hasMessage("Missing required json rpc parameter at index 0"); verifyZeroInteractions(filterManager); }
@Test public void shouldReturnErrorWhenMissingFilterId() { final JsonRpcRequestContext request = requestWithFilterId(); final Throwable thrown = catchThrowable(() -> method.response(request)); assertThat(thrown) .isInstanceOf(InvalidJsonRpcParameters.class) .hasMessage("Missing required json rpc parameter at index 0"); verifyZeroInteractions(filterManager); }
@Test public void shouldReturnFilterNotFoundWhenFilterManagerReturnsNull() { final JsonRpcRequestContext request = requestWithFilterId("NOT FOUND"); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse(null, JsonRpcError.LOGS_FILTER_NOT_FOUND); when(filterManager.logs(eq("NOT FOUND"))).thenReturn(null); final JsonRpcResponse response = method.response(request); assertThat(response).isEqualToComparingFieldByField(expectedResponse); }
@Test public void shouldReturnEmptyListWhenFilterManagerReturnsEmpty() { final JsonRpcRequestContext request = requestWithFilterId("0x1"); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, new LogsResult(new ArrayList<>())); when(filterManager.logs(eq("0x1"))).thenReturn(new ArrayList<>()); final JsonRpcResponse response = method.response(request); assertThat(response).isEqualToComparingFieldByFieldRecursively(expectedResponse); }
@Test public void shouldReturnExpectedLogsWhenFilterManagerReturnsLogs() { final JsonRpcRequestContext request = requestWithFilterId("0x1"); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, new LogsResult(logs())); when(filterManager.logs(eq("0x1"))).thenReturn(logs()); final JsonRpcResponse response = method.response(request); assertThat(response).isEqualToComparingFieldByFieldRecursively(expectedResponse); }