Search in sources :

Example 1 with VariableTypeManager

use of org.eclipse.milo.opcua.sdk.server.VariableTypeManager in project milo by eclipse.

the class UaNodeTest method setup.

@BeforeTest
public void setup() throws Exception {
    server = Mockito.mock(OpcUaServer.class);
    AddressSpaceManager addressSpaceManager = new AddressSpaceManager(server);
    NamespaceTable namespaceTable = new NamespaceTable();
    ObjectTypeManager objectTypeManager = new ObjectTypeManager();
    VariableTypeManager variableTypeManager = new VariableTypeManager();
    Mockito.when(server.getNamespaceTable()).thenReturn(namespaceTable);
    Mockito.when(server.getAddressSpaceManager()).thenReturn(addressSpaceManager);
    Mockito.when(server.getObjectTypeManager()).thenReturn(objectTypeManager);
    Mockito.when(server.getVariableTypeManager()).thenReturn(variableTypeManager);
    UaNodeManager nodeManager = new UaNodeManager();
    addressSpaceManager.register(nodeManager);
    UaNodeContext nodeContext = new UaNodeContext() {

        @Override
        public OpcUaServer getServer() {
            return server;
        }

        @Override
        public NodeManager<UaNode> getNodeManager() {
            return nodeManager;
        }
    };
    new NodeLoader(nodeContext, nodeManager).loadNodes();
    ObjectTypeInitializer.initialize(server.getNamespaceTable(), objectTypeManager);
    VariableTypeInitializer.initialize(server.getNamespaceTable(), variableTypeManager);
}
Also used : OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) UaNodeManager(org.eclipse.milo.opcua.sdk.server.UaNodeManager) NodeLoader(org.eclipse.milo.opcua.sdk.server.namespaces.loader.NodeLoader) NamespaceTable(org.eclipse.milo.opcua.stack.core.NamespaceTable) ObjectTypeManager(org.eclipse.milo.opcua.sdk.server.ObjectTypeManager) VariableTypeManager(org.eclipse.milo.opcua.sdk.server.VariableTypeManager) AddressSpaceManager(org.eclipse.milo.opcua.sdk.server.api.AddressSpaceManager) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with VariableTypeManager

use of org.eclipse.milo.opcua.sdk.server.VariableTypeManager 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

ObjectTypeManager (org.eclipse.milo.opcua.sdk.server.ObjectTypeManager)2 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)2 UaNodeManager (org.eclipse.milo.opcua.sdk.server.UaNodeManager)2 VariableTypeManager (org.eclipse.milo.opcua.sdk.server.VariableTypeManager)2 AddressSpaceManager (org.eclipse.milo.opcua.sdk.server.api.AddressSpaceManager)2 NodeLoader (org.eclipse.milo.opcua.sdk.server.namespaces.loader.NodeLoader)2 NamespaceTable (org.eclipse.milo.opcua.stack.core.NamespaceTable)2 BeforeTest (org.testng.annotations.BeforeTest)2 List (java.util.List)1 Optional (java.util.Optional)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Reference (org.eclipse.milo.opcua.sdk.core.Reference)1 NodeManager (org.eclipse.milo.opcua.sdk.server.api.NodeManager)1 ObjectTypeInitializer (org.eclipse.milo.opcua.sdk.server.model.ObjectTypeInitializer)1 VariableTypeInitializer (org.eclipse.milo.opcua.sdk.server.model.VariableTypeInitializer)1 ServerTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.objects.ServerTypeNode)1 AnalogItemTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode)1 UaMethodNode (org.eclipse.milo.opcua.sdk.server.nodes.UaMethodNode)1 UaNode (org.eclipse.milo.opcua.sdk.server.nodes.UaNode)1 UaNodeContext (org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext)1