use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetInformationResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testPutAssetInformationRequest.
@Test
public void testPutAssetInformationRequest() throws ResourceNotFoundException {
when(persistence.get(environment.getAssetAdministrationShells().get(0).getIdentification(), new QueryModifier())).thenReturn(environment.getAssetAdministrationShells().get(0));
when(persistence.put(environment.getAssetAdministrationShells().get(0))).thenReturn(environment.getAssetAdministrationShells().get(0));
PutAssetInformationRequest request = new PutAssetInformationRequest.Builder().id(environment.getAssetAdministrationShells().get(0).getIdentification()).assetInformation(environment.getAssetAdministrationShells().get(0).getAssetInformation()).build();
PutAssetInformationResponse response = manager.execute(request);
PutAssetInformationResponse expected = new PutAssetInformationResponse.Builder().statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetInformationResponse in project FAAAST-Service by FraunhoferIOSB.
the class PutAssetInformationRequestHandler method process.
@Override
public PutAssetInformationResponse process(PutAssetInformationRequest request) {
PutAssetInformationResponse response = new PutAssetInformationResponse();
try {
AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), new QueryModifier());
shell.setAssetInformation(request.getAssetInformation());
persistence.put(shell);
response.setStatusCode(StatusCode.Success);
publishElementUpdateEventMessage(AasUtils.toReference(shell), shell);
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
Aggregations