use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testGetAllAssetAdministrationShellRequest.
@Test
public void testGetAllAssetAdministrationShellRequest() {
when(persistence.get(any(), argThat((List<AssetIdentification> t) -> true), any())).thenReturn(environment.getAssetAdministrationShells());
GetAllAssetAdministrationShellsRequest request = new GetAllAssetAdministrationShellsRequest();
GetAllAssetAdministrationShellsResponse response = manager.execute(request);
GetAllAssetAdministrationShellsResponse expected = new GetAllAssetAdministrationShellsResponse.Builder().payload(environment.getAssetAdministrationShells()).statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testGetAllAssetAdministrationShellRequestAsync.
@Test
public void testGetAllAssetAdministrationShellRequestAsync() throws InterruptedException {
when(persistence.get(any(), argThat((List<AssetIdentification> t) -> true), any())).thenReturn(environment.getAssetAdministrationShells());
GetAllAssetAdministrationShellsRequest request = new GetAllAssetAdministrationShellsRequest();
final AtomicReference<GetAllAssetAdministrationShellsResponse> response = new AtomicReference<>();
CountDownLatch condition = new CountDownLatch(1);
manager.executeAsync(request, x -> response.set(x));
condition.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
Assert.assertEquals(environment.getAssetAdministrationShells(), response.get().getPayload());
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllAssetAdministrationShellsResponse in project FAAAST-Service by FraunhoferIOSB.
the class GetAllAssetAdministrationShellsRequestHandler method process.
@Override
public GetAllAssetAdministrationShellsResponse process(GetAllAssetAdministrationShellsRequest request) {
GetAllAssetAdministrationShellsResponse response = new GetAllAssetAdministrationShellsResponse();
try {
List<AssetAdministrationShell> shells = persistence.get(null, (List<AssetIdentification>) null, request.getOutputModifier());
response.setPayload(shells);
response.setStatusCode(StatusCode.Success);
if (shells != null) {
shells.forEach(x -> publishElementReadEventMessage(AasUtils.toReference(x), x));
}
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
Aggregations