Search in sources :

Example 1 with PutSubmodelElementByPathRequest

use of de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelElementByPathRequest in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testPutSubmodelElementByPathRequest.

@Test
public void testPutSubmodelElementByPathRequest() throws ResourceNotFoundException, AssetConnectionException {
    SubmodelElement currentSubmodelElement = new DefaultProperty.Builder().idShort("TestIdshort").valueType("string").value("TestValue").build();
    SubmodelElement newSubmodelElement = new DefaultProperty.Builder().idShort("TestIdshort").valueType("string").value("NewTestValue").build();
    when(persistence.get(argThat((Reference t) -> true), any())).thenReturn(currentSubmodelElement);
    when(persistence.put(any(), argThat((Reference t) -> true), any())).thenReturn(newSubmodelElement);
    when(assetConnectionManager.hasValueProvider(any())).thenReturn(true);
    PutSubmodelElementByPathRequest request = new PutSubmodelElementByPathRequest.Builder().id(environment.getSubmodels().get(0).getIdentification()).submodelElement(newSubmodelElement).build();
    PutSubmodelElementByPathResponse response = manager.execute(request);
    PutSubmodelElementByPathResponse expected = new PutSubmodelElementByPathResponse.Builder().payload(newSubmodelElement).statusCode(StatusCode.Success).build();
    Assert.assertEquals(expected, response);
    verify(assetValueProvider).setValue(ElementValueMapper.toValue(newSubmodelElement));
}
Also used : PutSubmodelElementByPathResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutSubmodelElementByPathResponse) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) PutSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelElementByPathRequest) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.Test)

Aggregations

PutSubmodelElementByPathResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutSubmodelElementByPathResponse)1 PutSubmodelElementByPathRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelElementByPathRequest)1 Reference (io.adminshell.aas.v3.model.Reference)1 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)1 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.Test)1