use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAssetAdministrationShellByIdResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testGetAssetAdministrationShellByIdRequest.
@Test
public void testGetAssetAdministrationShellByIdRequest() throws ResourceNotFoundException {
when(persistence.get(environment.getAssetAdministrationShells().get(0).getIdentification(), new OutputModifier())).thenReturn(environment.getAssetAdministrationShells().get(0));
GetAssetAdministrationShellByIdRequest request = GetAssetAdministrationShellByIdRequest.builder().id(environment.getAssetAdministrationShells().get(0).getIdentification()).outputModifier(new OutputModifier()).build();
GetAssetAdministrationShellByIdResponse response = manager.execute(request);
GetAssetAdministrationShellByIdResponse expected = new GetAssetAdministrationShellByIdResponse.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.GetAssetAdministrationShellByIdResponse in project FAAAST-Service by FraunhoferIOSB.
the class GetAssetAdministrationShellByIdRequestHandler method process.
@Override
public GetAssetAdministrationShellByIdResponse process(GetAssetAdministrationShellByIdRequest request) {
GetAssetAdministrationShellByIdResponse response = new GetAssetAdministrationShellByIdResponse();
try {
AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), request.getOutputModifier());
response.setPayload(shell);
response.setStatusCode(StatusCode.Success);
publishElementReadEventMessage(AasUtils.toReference(shell), shell);
} catch (ResourceNotFoundException ex) {
response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
Aggregations