Search in sources :

Example 1 with PutAssetInformationResponse

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);
}
Also used : QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) PutAssetInformationResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetInformationResponse) PutAssetInformationRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetInformationRequest) Test(org.junit.Test)

Example 2 with PutAssetInformationResponse

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;
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) PutAssetInformationResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetInformationResponse)

Aggregations

QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)2 PutAssetInformationResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetInformationResponse)2 PutAssetInformationRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetInformationRequest)1 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)1 Test (org.junit.Test)1