Search in sources :

Example 1 with SerializationException

use of io.adminshell.aas.v3.dataformat.SerializationException in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testGetSpecificSubmodelEvent.

@Test
public void testGetSpecificSubmodelEvent() throws SerializationException {
    Submodel expected = environment.getSubmodels().get(1);
    String identifier = Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
    setUpEventCheck(expected, ElementReadEventMessage.class, () -> getCall(HTTP_SUBMODELS + "/" + identifier + "/submodel"));
}
Also used : DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Submodel(io.adminshell.aas.v3.model.Submodel) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Example 2 with SerializationException

use of io.adminshell.aas.v3.dataformat.SerializationException in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testPostSubmodelsEvent.

@Test
public void testPostSubmodelsEvent() throws SerializationException {
    Submodel expected = new DefaultSubmodel.Builder().identification(new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier("newTestSubmodel").build()).build();
    setUpEventCheck(expected, ElementCreateEventMessage.class, () -> postCall(HTTP_SUBMODELS, expected));
}
Also used : DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Submodel(io.adminshell.aas.v3.model.Submodel) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) Test(org.junit.Test)

Example 3 with SerializationException

use of io.adminshell.aas.v3.dataformat.SerializationException in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testGetSpecificSubmodelLevel.

@Test
public void testGetSpecificSubmodelLevel() throws SerializationException, IOException, DeserializationException {
    Submodel expected = environment.getSubmodels().get(2);
    String identifier = Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
    String baseUrl = HTTP_SUBMODELS + "/" + identifier + "/submodel";
    // Level = deep
    String url = baseUrl + "?level=deep";
    HttpResponse response = getCall(url);
    Submodel actual = retrieveResourceFromResponse(response, Submodel.class);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    Assert.assertEquals(expected, actual);
    String finalUrl = url;
    setUpEventCheck(expected, ElementReadEventMessage.class, () -> getCall(finalUrl));
    // Level = core
    url = baseUrl + "?level=core";
    response = getCall(url);
    actual = retrieveResourceFromResponse(response, Submodel.class);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    Assert.assertNotEquals(expected, actual);
    Assert.assertTrue(((SubmodelElementCollection) actual.getSubmodelElements().stream().filter(x -> x.getIdShort().equalsIgnoreCase("ExampleSubmodelCollectionOrdered")).findFirst().get()).getValues().size() == 0);
    String finalUrl2 = url;
    SubmodelElementCollection submodelElementCollection = ((SubmodelElementCollection) expected.getSubmodelElements().get(5));
    submodelElementCollection.setValues(null);
    submodelElementCollection = ((SubmodelElementCollection) expected.getSubmodelElements().get(6));
    submodelElementCollection.setValues(null);
    setUpEventCheck(expected, ElementReadEventMessage.class, () -> getCall(finalUrl2));
}
Also used : DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Submodel(io.adminshell.aas.v3.model.Submodel) HttpResponse(org.apache.http.HttpResponse) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Example 4 with SerializationException

use of io.adminshell.aas.v3.dataformat.SerializationException in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testGetSubmodelsWithSemanticId.

@Test
public void testGetSubmodelsWithSemanticId() throws SerializationException {
    Submodel expected = environment.getSubmodels().get(1);
    String semnaticId = Base64.getUrlEncoder().encodeToString(new JsonSerializer().write(expected.getSemanticId()).getBytes(StandardCharsets.UTF_8));
    List<Submodel> actual = getListCall(HTTP_SUBMODELS + "?semanticId=" + semnaticId, Submodel.class);
    Assert.assertEquals(List.of(expected), actual);
}
Also used : DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Submodel(io.adminshell.aas.v3.model.Submodel) LangString(io.adminshell.aas.v3.model.LangString) JsonSerializer(de.fraunhofer.iosb.ilt.faaast.service.dataformat.json.JsonSerializer) Test(org.junit.Test)

Example 5 with SerializationException

use of io.adminshell.aas.v3.dataformat.SerializationException in project FAAAST-Service by FraunhoferIOSB.

the class RequestMappingManagerTest method testSetSubmodelElementValueByPath_ContentNormal.

@Test
public void testSetSubmodelElementValueByPath_ContentNormal() throws SerializationException, InvalidRequestException, Exception {
    SetSubmodelElementValueByPathRequest expected = SetSubmodelElementValueByPathRequest.<String>builder().id(SUBMODEL.getIdentification()).path(ReferenceHelper.toKeys(SUBMODEL_ELEMENT_REF)).build();
    when(serviceContext.getTypeInfo(any())).thenReturn(TypeExtractor.extractTypeInfo(SUBMODEL_ELEMENT));
    Request temp = mappingManager.map(HttpRequest.builder().method(HttpMethod.PUT).path("submodels/" + EncodingHelper.base64UrlEncode(SUBMODEL.getIdentification().getIdentifier()) + "/submodel/submodel-elements/" + ElementPathHelper.toElementPath(SUBMODEL_ELEMENT_REF)).query("content=value").body(serializer.write(SUBMODEL_ELEMENT)).build());
    SetSubmodelElementValueByPathRequest actual = (SetSubmodelElementValueByPathRequest) temp;
    Assert.assertEquals(expected.getId(), actual.getId());
    Assert.assertEquals(expected.getPath(), actual.getPath());
    Assert.assertEquals(ElementValueMapper.toValue(SUBMODEL_ELEMENT), actual.getValueParser().parse(actual.getRawValue(), SubmodelElement.class));
}
Also used : SetSubmodelElementValueByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.SetSubmodelElementValueByPathRequest) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) GetAllAssetAdministrationShellsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsRequest) InvokeOperationSyncRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.InvokeOperationSyncRequest) PutSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelElementByPathRequest) PutConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutConceptDescriptionByIdRequest) PutSubmodelRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelRequest) SetSubmodelElementValueByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.SetSubmodelElementValueByPathRequest) GetAllConceptDescriptionsByIsCaseOfRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsByIsCaseOfRequest) DeleteAllAssetLinksByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAllAssetLinksByIdRequest) PostSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostSubmodelElementByPathRequest) PostConceptDescriptionRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostConceptDescriptionRequest) PostAssetAdministrationShellRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostAssetAdministrationShellRequest) PostAASXPackageRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostAASXPackageRequest) GetAssetAdministrationShellByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAssetAdministrationShellByIdRequest) InvokeOperationAsyncRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.InvokeOperationAsyncRequest) GetAllSubmodelElementsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelElementsRequest) GetAllAssetLinksByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetLinksByIdRequest) PutSubmodelByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutSubmodelByIdRequest) HttpRequest(de.fraunhofer.iosb.ilt.faaast.service.endpoint.http.model.HttpRequest) PutAssetAdministrationShellRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetAdministrationShellRequest) DeleteConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteConceptDescriptionByIdRequest) GetAssetInformationRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAssetInformationRequest) GetAllSubmodelsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsRequest) DeleteSubmodelReferenceRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelReferenceRequest) PostSubmodelElementRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostSubmodelElementRequest) Request(de.fraunhofer.iosb.ilt.faaast.service.model.api.Request) GetAllSubmodelsBySemanticIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsBySemanticIdRequest) GetSubmodelByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetSubmodelByIdRequest) PostSubmodelRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostSubmodelRequest) DeleteSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelElementByPathRequest) GetAllSubmodelsByIdShortRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsByIdShortRequest) GetSubmodelElementByPathRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetSubmodelElementByPathRequest) GetOperationAsyncResultRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetOperationAsyncResultRequest) GetAllSubmodelReferencesRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelReferencesRequest) PutAssetAdministrationShellByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetAdministrationShellByIdRequest) GetAllConceptDescriptionsByIdShortRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsByIdShortRequest) PostAllAssetLinksByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostAllAssetLinksByIdRequest) DeleteSubmodelByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelByIdRequest) GetAllConceptDescriptionsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsRequest) PutAssetInformationRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetInformationRequest) DeleteAASXPackageByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAASXPackageByIdRequest) GetAllConceptDescriptionsByDataSpecificationReferenceRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsByDataSpecificationReferenceRequest) GetAASXByPackageIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAASXByPackageIdRequest) GetAllAssetAdministrationShellIdsByAssetLinkRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellIdsByAssetLinkRequest) GetAllAssetAdministrationShellsByAssetIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsByAssetIdRequest) GetAssetAdministrationShellRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAssetAdministrationShellRequest) GetSubmodelRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetSubmodelRequest) GetAllAssetAdministrationShellsByIdShortRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsByIdShortRequest) DeleteAssetAdministrationShellByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAssetAdministrationShellByIdRequest) PostSubmodelReferenceRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostSubmodelReferenceRequest) GetAllAASXPackageIdsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAASXPackageIdsRequest) GetConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetConceptDescriptionByIdRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 Submodel (io.adminshell.aas.v3.model.Submodel)4 DefaultSubmodel (io.adminshell.aas.v3.model.impl.DefaultSubmodel)4 HttpRequest (de.fraunhofer.iosb.ilt.faaast.service.endpoint.http.model.HttpRequest)3 Request (de.fraunhofer.iosb.ilt.faaast.service.model.api.Request)3 DeleteAASXPackageByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAASXPackageByIdRequest)3 DeleteAllAssetLinksByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAllAssetLinksByIdRequest)3 DeleteAssetAdministrationShellByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAssetAdministrationShellByIdRequest)3 DeleteConceptDescriptionByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteConceptDescriptionByIdRequest)3 DeleteSubmodelByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelByIdRequest)3 DeleteSubmodelElementByPathRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelElementByPathRequest)3 DeleteSubmodelReferenceRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelReferenceRequest)3 GetAASXByPackageIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAASXByPackageIdRequest)3 GetAllAASXPackageIdsRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAASXPackageIdsRequest)3 GetAllAssetAdministrationShellIdsByAssetLinkRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellIdsByAssetLinkRequest)3 GetAllAssetAdministrationShellsByAssetIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsByAssetIdRequest)3 GetAllAssetAdministrationShellsByIdShortRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsByIdShortRequest)3 GetAllAssetAdministrationShellsRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetAdministrationShellsRequest)3 GetAllAssetLinksByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllAssetLinksByIdRequest)3 GetAllConceptDescriptionsByDataSpecificationReferenceRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllConceptDescriptionsByDataSpecificationReferenceRequest)3