@Test
public void testSelectNodeId() throws Exception {

    final String EXPECTED_NODE_ID = "100-2";
    DefaultNodeIdCreator generator = new DefaultNodeIdCreator(new MockParameterService(), new MockNodeService() {
        @Override
        public NodeSecurity findNodeSecurity(String nodeId) {
            if (nodeId.equals(EXPECTED_NODE_ID)) {
                NodeSecurity security = new NodeSecurity();
                security.setNodeId(EXPECTED_NODE_ID);
                security.setRegistrationEnabled(true);
                return security;
            } else {
                return null;
            }
        }
    }, SecurityServiceFactory.create());
    Node node = new Node();
    node.setExternalId("100");
    String selectedNodeId = generator.selectNodeId(node, null, null);
    assertEquals(EXPECTED_NODE_ID, selectedNodeId);
}