NodeResourceImpl implements NodeResource { @Override public void setEnabled(final String nodeName, final Boolean enabled) { modifyNode(nodeName, node -> node.setEnabled(enabled)); } @Inject  NodeResourceImpl(final NodeServiceImpl nodeService,
                     final NodeInfo nodeInfo,
                     final ClusterNodeManager clusterNodeManager,
                     final WebTargetFactory webTargetFactory,
                     final DocumentEventLog documentEventLog); @Override List<String> listAllNodes(); @Override List<String> listEnabledNodes(); @Override FetchNodeStatusResponse find(); @Override ClusterNodeInfo info(final String nodeName); @Override Long ping(final String nodeName); @Override void setPriority(final String nodeName, final Integer priority); @Override void setEnabled(final String nodeName, final Boolean enabled);  }
@Test void list() { initNodes(); final String subPath = ""; final FetchNodeStatusResponse expectedResponse = getTestNodes().stream() .map(testNode -> { Node node2 = new Node(); node2.setEnabled(testNode.isEnabled()); node2.setName(testNode.getNodeName()); return new NodeStatusResult(node2, testNode.getNodeName().equals("node1")); }) .collect(FetchNodeStatusResponse.collector(FetchNodeStatusResponse::new)); doGetTest( subPath, FetchNodeStatusResponse.class, expectedResponse); }
@Test void setEnabled() { initNodes(); final String subPath = ResourcePaths.buildPath(NodeResource.ENABLED_PATH_PART, "node2"); doPutTest( subPath, Boolean.FALSE); Node newNode = new Node(); newNode.setName("node2"); newNode.setEnabled(false); verify(nodeServiceMap.get("node1"), Mockito.times(1)) .update(Mockito.eq(newNode)); }