@Test
public void testGenerateNodeIdExistingAll() throws Exception {

    IParameterService paramService = mock(IParameterService.class);
    Mockito.when(paramService.is(ParameterConstants.EXTERNAL_ID_IS_UNIQUE)).thenReturn(false);
    Mockito.when(paramService.getInt(ParameterConstants.NODE_ID_CREATOR_MAX_NODES, 100)).thenReturn(100);
    
    DefaultNodeIdCreator generator = new DefaultNodeIdCreator(paramService, new MockNodeService() {
        @Override
        public Node findNode(String nodeId) {
            Node node = new Node();
            node.setNodeId(nodeId);
            return node;
        }
        public NodeSecurity findNodeSecurity(String nodeId) {
            NodeSecurity nodeSecurity = new NodeSecurity();
            nodeSecurity.setNodeId(nodeId);
            nodeSecurity.setRegistrationEnabled(false);
            return nodeSecurity;
        }
    }, SecurityServiceFactory.create());
    Node node = new Node();
    node.setExternalId("100");
    try {
        generator.generateNodeId(node, null, null);
        fail("Should have received exception");
    } catch (Exception e) {
        // Expected
    }
}