List<Node> nodes = new ArrayList<Node>();
nodes.add(node);
Node masterNode = hudson;
NodeService inst = spy(getInst());
doReturn(nodes).when(hudson).getNodes();
doReturn(hudson).when(inst).getMasterNode();
doReturn(true).when(security).hasPermission(masterNode, Permission.READ);
List<Node> result = inst.getAllNodes();
assertThat(result, not(contains(node)));
assertThat(result, contains(masterNode));
Mockito.verify(security).hasPermission(node, Permission.READ);
Mockito.verify(security).hasPermission(masterNode, Permission.READ);