use of com.prosysopc.ua.stack.core.ReferenceDescription in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkIdentifierKeyValuePairListNode.
/**
* Searches for an IdentifierKeyValuePairList Node with the given Name and
* checks the corresponding values.
*
* @param client The OPC UA Client
* @param baseNode The base node where the desired Node is searched.
* @param aasns The namespace index of the AAS namespace.
* @param name The desired Name of the Node
* @param map The expected values.
* @throws ServiceException If the operation fails
* @throws ServiceResultException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws StatusException If the operation fails
*/
private static void checkIdentifierKeyValuePairListNode(UaClient client, NodeId baseNode, int aasns, String name, Map<String, String> map) throws ServiceException, ServiceResultException, AddressSpaceException, StatusException {
List<RelativePath> relPath = new ArrayList<>();
List<RelativePathElement> browsePath = new ArrayList<>();
browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, name)));
relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(baseNode, relPath.toArray(RelativePath[]::new));
Assert.assertNotNull("checkIdentifierKeyValuePairListNode Browse Result Null", bpres);
Assert.assertTrue("checkIdentifierKeyValuePairListNode Browse Result: size doesn't match", bpres.length == 1);
BrowsePathTarget[] targets = bpres[0].getTargets();
Assert.assertNotNull("checkIdentifierKeyValuePairListNode Browse Target Node Null", targets);
Assert.assertTrue("checkIdentifierKeyValuePairListNode Browse targets empty", targets.length > 0);
NodeId listNode = client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId());
Assert.assertNotNull("checkIdentifierKeyValuePairListNode Ref Node Null", listNode);
Assert.assertNotEquals("checkIdentifierKeyValuePairListNode Ref Node Null", NodeId.NULL, listNode);
checkType(client, listNode, new NodeId(aasns, TestDefines.AAS_ID_KEY_VALUE_PAIR_LIST_ID));
List<NodeId> nodeList = new ArrayList<>();
List<ReferenceDescription> refs = client.getAddressSpace().browse(listNode);
for (ReferenceDescription ref : refs) {
NodeId nid = client.getAddressSpace().getNamespaceTable().toNodeId(ref.getNodeId());
nodeList.add(nid);
}
for (NodeId node : nodeList) {
checkIdentifierKeyValuePairNode(client, node, aasns, map);
}
}
Aggregations