Search in sources :

Example 6 with StringValue

use of de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue 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);
}
Also used : DeleteSubmodelByIdRequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.DeleteSubmodelByIdRequestHandler) RequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.RequestHandler) DeleteSubmodelByIdRequestHandler(de.fraunhofer.iosb.ilt.faaast.service.request.handler.DeleteSubmodelByIdRequestHandler) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) StringValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) Test(org.junit.Test)

Example 7 with StringValue

use of de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testGetSubmodelElementByPathRequest.

@Test
public void testGetSubmodelElementByPathRequest() throws ResourceNotFoundException, AssetConnectionException {
    Submodel submodel = environment.getSubmodels().get(0);
    SubmodelElement cur_submodelElement = new DefaultProperty.Builder().idShort("testIdShort").value("testValue").build();
    PropertyValue propertyValue = new PropertyValue.Builder().value(new StringValue("test")).build();
    when(persistence.get(argThat((Reference t) -> true), eq(new OutputModifier()))).thenReturn(cur_submodelElement);
    when(assetConnectionManager.hasValueProvider(any())).thenReturn(true);
    when(assetValueProvider.getValue()).thenReturn(propertyValue);
    GetSubmodelElementByPathRequest request = new GetSubmodelElementByPathRequest.Builder().id(submodel.getIdentification()).outputModifier(new OutputModifier()).path(ReferenceHelper.toKeys(SUBMODEL_ELEMENT_REF)).build();
    GetSubmodelElementByPathResponse response = manager.execute(request);
    SubmodelElement expected_submodelElement = new DefaultProperty.Builder().idShort("testIdShort").value("test").valueType("string").build();
    GetSubmodelElementByPathResponse expected = new GetSubmodelElementByPathResponse.Builder().payload(expected_submodelElement).statusCode(StatusCode.Success).build();
    Assert.assertEquals(expected, response);
}
Also used : Submodel(io.adminshell.aas.v3.model.Submodel) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) GetSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetSubmodelElementByPathRequest) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) AtomicReference(java.util.concurrent.atomic.AtomicReference) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) GetSubmodelElementByPathResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetSubmodelElementByPathResponse) StringValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue) DefaultProperty(io.adminshell.aas.v3.model.impl.DefaultProperty) Test(org.junit.Test)

Aggregations

PropertyValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue)7 StringValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue)7 Test (org.junit.Test)7 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)4 DefaultProperty (io.adminshell.aas.v3.model.impl.DefaultProperty)4 MultiLanguagePropertyValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.MultiLanguagePropertyValue)3 GetSubmodelElementByPathResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetSubmodelElementByPathResponse)2 DataElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue)2 ElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue)2 SubmodelElementCollectionValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.SubmodelElementCollectionValue)2 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)2 DefaultSubmodelElementCollection (io.adminshell.aas.v3.model.impl.DefaultSubmodelElementCollection)2 Response (de.fraunhofer.iosb.ilt.faaast.service.model.api.Response)1 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)1 DeleteAssetAdministrationShellByIdResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteAssetAdministrationShellByIdResponse)1 DeleteConceptDescriptionByIdResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteConceptDescriptionByIdResponse)1 DeleteSubmodelByIdResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelByIdResponse)1 DeleteSubmodelElementByPathResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelElementByPathResponse)1 DeleteSubmodelReferenceResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelReferenceResponse)1 GetAllAssetAdministrationShellsByAssetIdResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsByAssetIdResponse)1