Search in sources :

Example 6 with UaNodeManager

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);
}
Also used : NodeManager(org.eclipse.milo.opcua.sdk.server.api.NodeManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.testng.annotations.Test) ObjectTypeInitializer(org.eclipse.milo.opcua.sdk.server.model.ObjectTypeInitializer) NamespaceTable(org.eclipse.milo.opcua.stack.core.NamespaceTable) Answer(org.mockito.stubbing.Answer) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) BeforeTest(org.testng.annotations.BeforeTest) VariableTypeManager(org.eclipse.milo.opcua.sdk.server.VariableTypeManager) UaMethodNode(org.eclipse.milo.opcua.sdk.server.nodes.UaMethodNode) Reference(org.eclipse.milo.opcua.sdk.core.Reference) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ObjectTypeManager(org.eclipse.milo.opcua.sdk.server.ObjectTypeManager) VariableTypeInitializer(org.eclipse.milo.opcua.sdk.server.model.VariableTypeInitializer) UaVariableNode(org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) UaObjectNode(org.eclipse.milo.opcua.sdk.server.nodes.UaObjectNode) Assert.assertNotNull(org.testng.Assert.assertNotNull) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) Nullable(org.jetbrains.annotations.Nullable) Mockito(org.mockito.Mockito) List(java.util.List) NodeLoader(org.eclipse.milo.opcua.sdk.server.namespaces.loader.NodeLoader) AddressSpaceManager(org.eclipse.milo.opcua.sdk.server.api.AddressSpaceManager) UaNodeContext(org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext) Optional(java.util.Optional) UaNodeManager(org.eclipse.milo.opcua.sdk.server.UaNodeManager) Assert.assertTrue(org.testng.Assert.assertTrue) ServerTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.ServerTypeNode) AnalogItemTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) Optional(java.util.Optional) NodeLoader(org.eclipse.milo.opcua.sdk.server.namespaces.loader.NodeLoader) ObjectTypeManager(org.eclipse.milo.opcua.sdk.server.ObjectTypeManager) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) UaNodeManager(org.eclipse.milo.opcua.sdk.server.UaNodeManager) NamespaceTable(org.eclipse.milo.opcua.stack.core.NamespaceTable) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) UaNodeContext(org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext) List(java.util.List) VariableTypeManager(org.eclipse.milo.opcua.sdk.server.VariableTypeManager) AddressSpaceManager(org.eclipse.milo.opcua.sdk.server.api.AddressSpaceManager) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

UaNodeManager (org.eclipse.milo.opcua.sdk.server.UaNodeManager)6 Test (org.testng.annotations.Test)5 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)4 NamespaceTable (org.eclipse.milo.opcua.stack.core.NamespaceTable)4 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)4 BeforeTest (org.testng.annotations.BeforeTest)4 Reference (org.eclipse.milo.opcua.sdk.core.Reference)3 AddressSpaceManager (org.eclipse.milo.opcua.sdk.server.api.AddressSpaceManager)3 NodeManager (org.eclipse.milo.opcua.sdk.server.api.NodeManager)3 NodeLoader (org.eclipse.milo.opcua.sdk.server.namespaces.loader.NodeLoader)3 UaNode (org.eclipse.milo.opcua.sdk.server.nodes.UaNode)3 UaNodeContext (org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext)3 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)3 List (java.util.List)2 Optional (java.util.Optional)2 ObjectTypeManager (org.eclipse.milo.opcua.sdk.server.ObjectTypeManager)2 VariableTypeManager (org.eclipse.milo.opcua.sdk.server.VariableTypeManager)2 AnalogItemTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode)2 UaVariableNode (org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode)2 Identifiers (org.eclipse.milo.opcua.stack.core.Identifiers)2