### Question:
NodeServiceImpl extends ServiceSupport implements NodeService { public List<Node> getNodes() { List<Node> nodesToCheck = getHudson().getNodes(); List<Node> nodesToReturn = new ArrayList<Node>(nodesToCheck.size()); for (hudson.model.Node node : nodesToCheck) { if (this.security.hasPermission(node, Permission.READ)) { nodesToReturn.add(node); } } return nodesToReturn; } @Inject  NodeServiceImpl(final SecurityService security); Node getNode(String nodeName); Node findNode(final String nodeName); Node getMasterNode(); List<Node> getAllNodes(); List<Node> getNodes(); Node getCurrentNode();  }### Answer:
@Test public void getNodesSecurity() { List<Node> nodes = new ArrayList<Node>(); nodes.add(node); NodeService inst = spy(getInst()); doReturn(nodes).when(hudson).getNodes(); doReturn(true).when(security).hasPermission(node, Permission.READ); List<Node> result = inst.getNodes(); assertThat(result, contains(node)); Mockito.verify(security).hasPermission(node, Permission.READ); }