NodeFactory { public UaNode createNode( NodeId rootNodeId, NodeId typeDefinitionId ) throws UaException { return createNode(rootNodeId, typeDefinitionId, new InstantiationCallback() {}); } NodeFactory(UaNodeContext context);  NodeFactory(
        UaNodeContext context,
        ObjectTypeManager objectTypeManager,
        VariableTypeManager variableTypeManager
    ); static void invalidateCachedIdh(NodeId typeDefinitionId); UaNode createNode(
        NodeId rootNodeId,
        NodeId typeDefinitionId
    ); UaNode createNode(
        NodeId rootNodeId,
        NodeId typeDefinitionId,
        InstantiationCallback instantiationCallback
    ); UaNode createNode(
        NodeId rootNodeId,
        ExpandedNodeId typeDefinitionId
    ); UaNode createNode(
        NodeId rootNodeId,
        ExpandedNodeId typeDefinitionId,
        InstantiationCallback instantiationCallback
    ); Tree<UaNode> createNodeTree(
        NodeId rootNodeId,
        NodeId typeDefinitionId,
        InstantiationCallback instantiationCallback
    );  }
@Test public void testCreateAnalogItemType() throws Exception { AnalogItemTypeNode analogItem = (AnalogItemTypeNode) nodeFactory.createNode( new NodeId(1, "TestAnalog"), Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() { @Override public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) { return true; } } ); assertNotNull(analogItem); assertTrue(nodeManager.containsNode(analogItem)); }
@Test public void testInstanceListener() throws Exception { final AtomicBoolean methodAdded = new AtomicBoolean(false); final AtomicBoolean objectAdded = new AtomicBoolean(false); final AtomicBoolean variableAdded = new AtomicBoolean(false); ServerTypeNode serverNode = (ServerTypeNode) nodeFactory.createNode( new NodeId(0, "Server"), Identifiers.ServerType, new NodeFactory.InstantiationCallback() { @Override public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) { return true; } @Override public void onMethodAdded(@Nullable UaObjectNode parent, UaMethodNode instance) { String pbn = parent != null ? parent.getBrowseName().getName() : null; System.out.println("onMethodAdded parent=" + pbn + " instance=" + instance.getBrowseName().getName()); methodAdded.set(true); } @Override public void onObjectAdded(@Nullable UaNode parent, UaObjectNode instance, NodeId typeDefinitionId) { String pbn = parent != null ? parent.getBrowseName().getName() : null; System.out.println("onObjectAdded parent=" + pbn + " instance=" + instance.getBrowseName().getName()); objectAdded.set(true); } @Override public void onVariableAdded(@Nullable UaNode parent, UaVariableNode instance, NodeId typeDefinitionId) { String pbn = parent != null ? parent.getBrowseName().getName() : null; System.out.println("onVariableAdded parent=" + pbn + " instance=" + instance.getBrowseName().getName()); variableAdded.set(true); } } ); assertTrue(methodAdded.get()); assertTrue(objectAdded.get()); assertTrue(variableAdded.get()); }