use of io.adminshell.aas.v3.model.impl.DefaultReference in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testReadValueFromAssetConnection.
@Test
public void testReadValueFromAssetConnection() throws AssetConnectionException {
RequestHandler requestHandler = new DeleteSubmodelByIdRequestHandler(persistence, messageBus, assetConnectionManager);
PropertyValue expected = new PropertyValue.Builder().value(new StringValue("test")).build();
when(assetConnectionManager.hasValueProvider(any())).thenReturn(true);
when(assetValueProvider.getValue()).thenReturn(expected);
DataElementValue actual = requestHandler.readDataElementValueFromAssetConnection(new DefaultReference());
Assert.assertEquals(expected, actual);
}
use of io.adminshell.aas.v3.model.impl.DefaultReference in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method setReferenceElementValue.
/**
* Sets the value for the given ReferenceElement.
*
* @param refElement The desired ReferenceElement.
* @param value The new value.
* @throws StatusException If the operation fails
*/
private void setReferenceElementValue(AASReferenceElementType refElement, ReferenceElementValue value) throws StatusException {
if (refElement == null) {
throw new IllegalArgumentException("refElement is null");
} else if (value == null) {
throw new IllegalArgumentException("value is null");
}
try {
DefaultReference ref = new DefaultReference.Builder().keys(value.getKeys()).build();
setAasReferenceData(ref, refElement.getValueNode());
} catch (Throwable ex) {
logger.error("setReferenceElementValue Exception", ex);
throw ex;
}
}
use of io.adminshell.aas.v3.model.impl.DefaultReference in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method setEntityValue.
/**
* Sets the values for the given Entity.
*
* @param entity The desired Entity.
* @param value The new value.
* @throws StatusException If the operation fails
*/
private void setEntityValue(AASEntityType entity, EntityValue value) throws StatusException {
if (entity == null) {
throw new IllegalArgumentException("entity is null");
} else if (value == null) {
throw new IllegalArgumentException("value is null");
}
try {
// EntityType
entity.setEntityType(ValueConverter.getAasEntityType(value.getEntityType()));
// GlobalAssetId
if ((value.getGlobalAssetId() != null) && (value.getGlobalAssetId().size() > 0)) {
DefaultReference ref = new DefaultReference.Builder().keys(value.getGlobalAssetId()).build();
setAasReferenceData(ref, entity.getGlobalAssetIdNode());
}
// Statements
Map<String, ElementValue> valueMap = value.getStatements();
AASSubmodelElementList statementNode = entity.getStatementNode();
if (statementNode != null) {
UaNode[] statementNodes = statementNode.getComponents();
if (statementNodes.length != valueMap.size()) {
logger.warn("Size of Value (" + valueMap.size() + ") doesn't match the number of StatementNodes (" + statementNodes.length + ")");
throw new IllegalArgumentException("Size of Value doesn't match the number of StatementNodes");
}
for (UaNode statementNode1 : statementNodes) {
if (statementNode1 instanceof AASSubmodelElementType) {
if (value.getStatements().containsKey(statementNode1.getBrowseName().getName())) {
setSubmodelElementValue((AASSubmodelElementType) statementNode1, value.getStatements().get(statementNode1.getBrowseName().getName()));
}
}
}
}
} catch (Throwable ex) {
logger.error("setEntityValue Exception", ex);
throw ex;
}
}
use of io.adminshell.aas.v3.model.impl.DefaultReference in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testWriteValueToAssetConnection.
@Test
public void testWriteValueToAssetConnection() throws AssetConnectionException {
RequestHandler requestHandler = new DeleteSubmodelByIdRequestHandler(persistence, messageBus, assetConnectionManager);
PropertyValue expected = new PropertyValue.Builder().value(new StringValue("test")).build();
when(assetConnectionManager.hasValueProvider(any())).thenReturn(true);
requestHandler.writeValueToAssetConnection(new DefaultReference(), expected);
verify(assetValueProvider).setValue(expected);
}
use of io.adminshell.aas.v3.model.impl.DefaultReference in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method getSubmodelsNullTest.
@Test
public void getSubmodelsNullTest() {
String AAS_ID = "Test_AssetAdministrationShell_Mandatory";
List<AssetAdministrationShell> actualAASList = persistence.get(AAS_ID, new DefaultReference(), new QueryModifier());
List<AssetAdministrationShell> expectedAASList = null;
Assert.assertEquals(expectedAASList, actualAASList);
}
Aggregations