@Override
    public DataNodeDto removeNode(String nodeId) throws NodeNotFoundException {
        final DataNodeDto node = nodeService.byNodeId(nodeId);
        if (node.getDataNodeStatus() != DataNodeStatus.AVAILABLE) {
            throw new IllegalArgumentException("Only running data nodes can be removed from the cluster.");
        }
        if (nodeService.allActive().values().stream()
                .filter(n -> n.getDataNodeStatus() == DataNodeStatus.AVAILABLE && n.getActionQueue() == null)
                .count() <= 1) {
            throw new IllegalArgumentException("Cannot remove last data node in the cluster.");
        }
        DataNodeLifecycleTrigger trigger = DataNodeLifecycleTrigger.REMOVE;
        DataNodeStatus lockingStatus = DataNodeStatus.REMOVING;
        addToQueue(node, trigger, lockingStatus);
        return node;
    }
@Test
    public void removeNodeFailsForLastNode() throws NodeNotFoundException {
        final String testNodeId = "node";
        nodeService.registerServer(buildTestNode(testNodeId, DataNodeStatus.AVAILABLE));

        Exception e = assertThrows(IllegalArgumentException.class, () -> {
            classUnderTest.removeNode(testNodeId);
        });
        assertEquals("Cannot remove last data node in the cluster.", e.getMessage());
        verifyNoMoreInteractions(clusterEventBus);
    }