use of org.eclipse.milo.opcua.sdk.server.UaNodeManager in project milo by eclipse.
the class NodeFactoryTest method setup.
@BeforeTest
public void setup() throws Exception {
server = Mockito.mock(OpcUaServer.class);
NamespaceTable namespaceTable = new NamespaceTable();
Mockito.when(server.getNamespaceTable()).thenReturn(namespaceTable);
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)));
Mockito.when(server.getAddressSpaceManager()).thenReturn(addressSpaceManager);
UaNodeContext context = new UaNodeContext() {
@Override
public OpcUaServer getServer() {
return server;
}
@Override
public NodeManager<UaNode> getNodeManager() {
return nodeManager;
}
};
new NodeLoader(context, nodeManager).loadNodes();
ObjectTypeManager objectTypeManager = new ObjectTypeManager();
ObjectTypeInitializer.initialize(server.getNamespaceTable(), objectTypeManager);
VariableTypeManager variableTypeManager = new VariableTypeManager();
VariableTypeInitializer.initialize(server.getNamespaceTable(), variableTypeManager);
nodeFactory = new NodeFactory(context, objectTypeManager, variableTypeManager);
}
Aggregations