### Question:
NetListening implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { return new JsonRpcSuccessResponse( requestContext.getRequest().getId(), p2pNetwork.isListening()); } NetListening(final P2PNetwork p2pNetwork); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldReturnTrueWhenNetworkIsListening() { when(p2PNetwork.isListening()).thenReturn(true); final JsonRpcRequestContext request = netListeningRequest(); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, true); Assertions.assertThat(method.response(request)) .isEqualToComparingFieldByField(expectedResponse); }
@Test public void shouldReturnFalseWhenNetworkIsNotListening() { when(p2PNetwork.isListening()).thenReturn(false); final JsonRpcRequestContext request = netListeningRequest(); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, false); Assertions.assertThat(method.response(request)) .isEqualToComparingFieldByField(expectedResponse); }