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));
}
Aggregations