### Question:
PermGetNodesAllowlist implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { try { if (nodeWhitelistPermissioningController.isPresent()) { final List<String> enodeList = nodeWhitelistPermissioningController.get().getNodesAllowlist(); return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), enodeList); } else { return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_NOT_ENABLED); } } catch (P2PDisabledException e) { return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.P2P_DISABLED); } } PermGetNodesAllowlist(
      final Optional<NodeLocalConfigPermissioningController> nodeWhitelistPermissioningController); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldReturnSuccessResponseWhenListPopulated() { final JsonRpcRequestContext request = buildRequest(); final JsonRpcResponse expected = new JsonRpcSuccessResponse( request.getRequest().getId(), Lists.newArrayList(enode1, enode2, enode3)); when(nodeLocalConfigPermissioningController.getNodesAllowlist()) .thenReturn(buildNodesList(enode1, enode2, enode3)); final JsonRpcResponse actual = method.response(request); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist(); verifyNoMoreInteractions(nodeLocalConfigPermissioningController); }
@Test public void shouldReturnSuccessResponseWhenListSetAndEmpty() { final JsonRpcRequestContext request = buildRequest(); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList()); when(nodeLocalConfigPermissioningController.getNodesAllowlist()).thenReturn(buildNodesList()); final JsonRpcResponse actual = method.response(request); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist(); verifyNoMoreInteractions(nodeLocalConfigPermissioningController); }
@Test public void shouldFailWhenP2pDisabled() { method = new PermGetNodesAllowlist(Optional.empty()); final JsonRpcRequestContext request = buildRequest(); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse( request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_NOT_ENABLED); Assertions.assertThat(method.response(request)) .isEqualToComparingFieldByField(expectedResponse); }