use of org.eclipse.milo.opcua.sdk.server.nodes.factories.NodeFactory in project milo by eclipse.
the class UaNodeTest method testCreateDeleteComplexInstance.
@Test
public void testCreateDeleteComplexInstance() throws UaException {
NodeId nodeId = new NodeId(1, "TestAnalog");
UaNodeManager nodeManager = new UaNodeManager();
server.getAddressSpaceManager().register(nodeManager);
assertFalse(nodeManager.containsNode(nodeId));
assertEquals(0, nodeManager.getReferences(nodeId).size());
NodeFactory nodeFactory = new NodeFactory(new UaNodeContext() {
@Override
public OpcUaServer getServer() {
return server;
}
@Override
public NodeManager<UaNode> getNodeManager() {
return nodeManager;
}
});
AnalogItemTypeNode analogItem = (AnalogItemTypeNode) nodeFactory.createNode(nodeId, Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {
@Override
public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
return true;
}
});
assertTrue(nodeManager.containsNode(nodeId));
assertTrue(nodeManager.getReferences(nodeId).size() > 0);
analogItem.delete();
assertFalse(nodeManager.containsNode(nodeId));
assertEquals(0, nodeManager.getReferences(nodeId).size());
}
Aggregations