use of com.prosysopc.ua.stack.core.RelativePathElement in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkCategoryNode.
/**
* Searches for the Category Node in the given Node and checks the Category
* value.
*
* @param client The OPC UA client
* @param node The desired node
* @param aasns The namespace index of the AAS namespace
* @param category The expected category value
* @throws ServiceException If the operation fails
* @throws StatusException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws ServiceResultException If the operation fails
*/
public static void checkCategoryNode(UaClient client, NodeId node, int aasns, String category) throws ServiceException, StatusException, AddressSpaceException, ServiceResultException {
List<RelativePath> relPath = new ArrayList<>();
List<RelativePathElement> browsePath = new ArrayList<>();
browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.CATEGORY_NAME)));
relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(node, relPath.toArray(RelativePath[]::new));
Assert.assertNotNull("Category Result Null", bpres);
Assert.assertTrue("Category Result: size doesn't match", bpres.length == 1);
BrowsePathTarget[] targets = bpres[0].getTargets();
Assert.assertNotNull("Browse Category Null", targets);
Assert.assertTrue("Category targets empty", targets.length > 0);
checkType(client, targets[0].getTargetId(), Identifiers.PropertyType);
DataValue value = client.readValue(targets[0].getTargetId());
Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
String str = "";
if (!value.getValue().isEmpty()) {
str = value.getValue().toString();
}
Assert.assertEquals(category.isEmpty(), str.isEmpty());
if (!category.isEmpty()) {
Assert.assertEquals(category, value.getValue().toString());
}
}
Aggregations