InstanceDeclarationHierarchy { public static InstanceDeclarationHierarchy create( AddressSpaceManager addressSpaceManager, NamespaceTable namespaceTable, NodeId typeDefinitionId ) { Builder builder = new Builder(addressSpaceManager, namespaceTable); return builder.build(typeDefinitionId); } private  InstanceDeclarationHierarchy(
        NodeId typeId,
        NodeTable nodeTable,
        ReferenceTable referenceTable
    ); static InstanceDeclarationHierarchy create(
        AddressSpaceManager addressSpaceManager,
        NamespaceTable namespaceTable,
        NodeId typeDefinitionId
    );  }
@Test public void test() throws Exception { NamespaceTable namespaceTable = new NamespaceTable(); UaNodeManager nodeManager = new UaNodeManager(); AddressSpaceManager addressSpaceManager = Mockito.mock(AddressSpaceManager.class); Mockito .when(addressSpaceManager.getManagedNode(Mockito.any(NodeId.class))) .then( (Answer<Optional<UaNode>>) invocationOnMock -> nodeManager.getNode(invocationOnMock.getArgument(0)) ); Mockito .when(addressSpaceManager.getManagedNode(Mockito.any(ExpandedNodeId.class))) .then( (Answer<Optional<UaNode>>) invocationOnMock -> nodeManager.getNode(invocationOnMock.getArgument(0), namespaceTable) ); Mockito .when(addressSpaceManager.getManagedReferences(Mockito.any(NodeId.class))) .then( (Answer<List<Reference>>) invocationOnMock -> nodeManager.getReferences(invocationOnMock.getArgument(0)) ); OpcUaServer server = Mockito.mock(OpcUaServer.class); Mockito.when(server.getAddressSpaceManager()).thenReturn(addressSpaceManager); Mockito.when(server.getNamespaceTable()).thenReturn(namespaceTable); UaNodeContext context = new UaNodeContext() { @Override public OpcUaServer getServer() { return server; } @Override public NodeManager<UaNode> getNodeManager() { return nodeManager; } }; new NodeLoader(context, nodeManager).loadNodes(); InstanceDeclarationHierarchy idh = InstanceDeclarationHierarchy.create( addressSpaceManager, namespaceTable, Identifiers.AnalogItemType ); System.out.println(idh); assertNotNull(idh); }