use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetAdministrationShellByIdResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testPutAssetAdministrationShellByIdRequest.
@Test
public void testPutAssetAdministrationShellByIdRequest() {
when(persistence.put(environment.getAssetAdministrationShells().get(0))).thenReturn(environment.getAssetAdministrationShells().get(0));
PutAssetAdministrationShellByIdRequest request = new PutAssetAdministrationShellByIdRequest.Builder().aas(environment.getAssetAdministrationShells().get(0)).build();
PutAssetAdministrationShellByIdResponse response = manager.execute(request);
PutAssetAdministrationShellByIdResponse expected = new PutAssetAdministrationShellByIdResponse.Builder().payload(environment.getAssetAdministrationShells().get(0)).statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetAdministrationShellByIdResponse in project FAAAST-Service by FraunhoferIOSB.
the class PutAssetAdministrationShellByIdRequestHandler method process.
@Override
public PutAssetAdministrationShellByIdResponse process(PutAssetAdministrationShellByIdRequest request) {
PutAssetAdministrationShellByIdResponse response = new PutAssetAdministrationShellByIdResponse();
try {
AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getAas().getIdentification(), new OutputModifier());
shell = (AssetAdministrationShell) persistence.put(request.getAas());
response.setPayload(shell);
response.setStatusCode(StatusCode.Success);
publishElementUpdateEventMessage(AasUtils.toReference(shell), shell);
} catch (ResourceNotFoundException ex) {
response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
Aggregations