use of com.prosysopc.ua.nodes.UaType in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkAasReference.
/**
* Checks the given Reference Node
*
* @param client The OPC UA Client
* @param node The desired Node
* @param aasns The namespace index of the AAS namespace.
* @param refKeys The expected list of Keys
* @throws ServiceException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws ServiceResultException If the operation fails
* @throws StatusException If the operation fails
*/
private static void checkAasReference(UaClient client, NodeId node, int aasns, List<AASKeyDataType> refKeys) throws ServiceException, AddressSpaceException, ServiceResultException, StatusException {
checkType(client, node, new NodeId(aasns, TestDefines.AAS_REFERENCE_TYPE_ID));
List<RelativePathElement> browsePath = new ArrayList<>();
browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, "Keys")));
BrowsePathTarget[] targetsProp = client.getAddressSpace().translateBrowsePathToNodeId(node, browsePath.toArray(RelativePathElement[]::new));
Assert.assertNotNull("Property Keys Null", targetsProp);
Assert.assertTrue("Property Keys empty", targetsProp.length > 0);
checkType(client, targetsProp[0].getTargetId(), Identifiers.PropertyType);
UaVariable variable = (UaVariable) client.getAddressSpace().getNode(targetsProp[0].getTargetId());
UaType dataType = variable.getDataType();
Assert.assertNotNull("DataType null", dataType);
Assert.assertEquals("DataType not equal", new NodeId(aasns, TestDefines.AAS_KEY_DATA_TYPE_ID), dataType.getNodeId());
DataValue value = client.readValue(targetsProp[0].getTargetId());
Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
Assert.assertNotNull("Value null", value.getValue());
Variant var = value.getValue();
Object o = var.getValue();
Assert.assertTrue("Keys no array", var.isArray());
// Assert.assertEquals(AASKeyDataType.class, o.getClass());
AASKeyDataType[] arr = (AASKeyDataType[]) o;
Assert.assertEquals(refKeys.size(), arr.length);
Assert.assertArrayEquals(refKeys.toArray(), arr);
}
Aggregations