use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetAdministrationShellResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testPutAssetAdministrationShellRequest.
@Test
public void testPutAssetAdministrationShellRequest() throws ResourceNotFoundException {
// @TODO: open/unclear
// expected Identifiable
when(persistence.put(environment.getAssetAdministrationShells().get(0))).thenReturn(environment.getAssetAdministrationShells().get(0));
PutAssetAdministrationShellRequest request = new PutAssetAdministrationShellRequest.Builder().aas(environment.getAssetAdministrationShells().get(0)).id(AAS.getIdentification()).build();
PutAssetAdministrationShellResponse response = manager.execute(request);
PutAssetAdministrationShellResponse expected = new PutAssetAdministrationShellResponse.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.PutAssetAdministrationShellResponse in project FAAAST-Service by FraunhoferIOSB.
the class PutAssetAdministrationShellRequestHandler method process.
@Override
public PutAssetAdministrationShellResponse process(PutAssetAdministrationShellRequest request) {
PutAssetAdministrationShellResponse response = new PutAssetAdministrationShellResponse();
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