Search in sources :

Example 1 with DeserializationException

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

the class IntegrationTestHttpEndpoint method testGetSubmodels.

@Test
public void testGetSubmodels() throws IOException, DeserializationException {
    HttpResponse response = getListCall(HTTP_SUBMODELS);
    List<Submodel> actual = retrieveResourceFromResponseList(response, Submodel.class);
    List<Submodel> expected = environment.getSubmodels();
    Assert.assertEquals(expected, actual);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
}
Also used : DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Submodel(io.adminshell.aas.v3.model.Submodel) HttpResponse(org.apache.http.HttpResponse) Test(org.junit.Test)

Example 2 with DeserializationException

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

the class IntegrationTestHttpEndpoint method testGETSpecificShell.

@Test
public void testGETSpecificShell() throws IOException, DeserializationException {
    AssetAdministrationShell expected = environment.getAssetAdministrationShells().get(1);
    HttpResponse actual = getCall(HTTP_SHELLS + "/" + Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8)));
    Assert.assertEquals(expected, retrieveResourceFromResponse(actual, AssetAdministrationShell.class));
    Assert.assertEquals(HttpStatus.SC_OK, actual.getStatusLine().getStatusCode());
}
Also used : DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) HttpResponse(org.apache.http.HttpResponse) Test(org.junit.Test)

Example 3 with DeserializationException

use of io.adminshell.aas.v3.dataformat.DeserializationException 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 DeserializationException

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

the class IntegrationTestHttpEndpoint method testPUT_AASShell.

@Test
public void testPUT_AASShell() throws IOException, DeserializationException {
    AssetAdministrationShell expected = environment.getAssetAdministrationShells().get(1);
    expected.setIdShort("changed");
    String url = HTTP_SHELLS + "/" + Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8)) + "/aas";
    HttpResponse response = putCall(url, expected);
    Assert.assertEquals(expected, retrieveResourceFromResponse(response, AssetAdministrationShell.class));
    // TODO: StatusCode of spec seems to be wrong 204
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    AssetAdministrationShell actual = getCall(url, AssetAdministrationShell.class);
    Assert.assertEquals(expected, actual);
}
Also used : DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) HttpResponse(org.apache.http.HttpResponse) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Example 5 with DeserializationException

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

the class IntegrationTestHttpEndpoint method testGETShellsWithAssetIds.

@Test
public void testGETShellsWithAssetIds() throws IOException, DeserializationException {
    String assetIdValue = "https://acplt.org/Test_Asset";
    List<AssetAdministrationShell> expected = environment.getAssetAdministrationShells().stream().filter(x -> x.getAssetInformation().getGlobalAssetId().getKeys().stream().anyMatch(y -> y.getValue().equalsIgnoreCase(assetIdValue))).collect(Collectors.toList());
    String assetIdsParameter = "[{\"key\": \"globalAssetId\",\"value\":\"" + assetIdValue + "\"}]";
    HttpResponse response = getListCall(HTTP_SHELLS + "?assetIds=" + Base64.getUrlEncoder().encodeToString(assetIdsParameter.getBytes(StandardCharsets.UTF_8)));
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    List<AssetAdministrationShell> actual = retrieveResourceFromResponseList(response, AssetAdministrationShell.class);
    Assert.assertEquals(expected, actual);
}
Also used : SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) ElementReadEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.access.ElementReadEventMessage) AASFull(de.fraunhofer.iosb.ilt.faaast.service.model.AASFull) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) HttpStatus(org.apache.http.HttpStatus) Service(de.fraunhofer.iosb.ilt.faaast.service.Service) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) ServiceConfig(de.fraunhofer.iosb.ilt.faaast.service.config.ServiceConfig) AssetInformation(io.adminshell.aas.v3.model.AssetInformation) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) ArrayList(java.util.ArrayList) MessageBusInternalConfig(de.fraunhofer.iosb.ilt.faaast.service.messagebus.internal.MessageBusInternalConfig) DeserializationException(de.fraunhofer.iosb.ilt.faaast.service.dataformat.DeserializationException) SubscriptionInfo(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionInfo) AssetKind(io.adminshell.aas.v3.model.AssetKind) After(org.junit.After) KeyType(io.adminshell.aas.v3.model.KeyType) LangString(io.adminshell.aas.v3.model.LangString) DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) Util(de.fraunhofer.iosb.ilt.faaast.service.starter.integrationtests.Util) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) ElementDeleteEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementDeleteEventMessage) Before(org.junit.Before) MessageBus(de.fraunhofer.iosb.ilt.faaast.service.messagebus.MessageBus) DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) IdentifierType(io.adminshell.aas.v3.model.IdentifierType) Reference(io.adminshell.aas.v3.model.Reference) HttpEndpointConfig(de.fraunhofer.iosb.ilt.faaast.service.endpoint.http.HttpEndpointConfig) IOException(java.io.IOException) Test(org.junit.Test) SubscriptionId(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionId) ElementCreateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage) SerializationException(de.fraunhofer.iosb.ilt.faaast.service.dataformat.SerializationException) JsonSerializer(de.fraunhofer.iosb.ilt.faaast.service.dataformat.json.JsonSerializer) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Base64(java.util.Base64) List(java.util.List) PersistenceInMemoryConfig(de.fraunhofer.iosb.ilt.faaast.service.persistence.memory.PersistenceInMemoryConfig) CoreConfig(de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) HttpResponse(org.apache.http.HttpResponse) ElementUpdateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementUpdateEventMessage) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Assert(org.junit.Assert) Submodel(io.adminshell.aas.v3.model.Submodel) DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) HttpResponse(org.apache.http.HttpResponse) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)27 HttpResponse (org.apache.http.HttpResponse)21 LangString (io.adminshell.aas.v3.model.LangString)13 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)12 DefaultAssetAdministrationShell (io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell)12 Submodel (io.adminshell.aas.v3.model.Submodel)8 DefaultSubmodel (io.adminshell.aas.v3.model.impl.DefaultSubmodel)8 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)7 DeserializationException (de.fraunhofer.iosb.ilt.faaast.service.dataformat.DeserializationException)6 IOException (java.io.IOException)6 Reference (io.adminshell.aas.v3.model.Reference)5 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 Assert (org.junit.Assert)5 AssetAdministrationShellEnvironment (io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment)4 AssetInformation (io.adminshell.aas.v3.model.AssetInformation)4 ElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue)3 SubmodelElementCollection (io.adminshell.aas.v3.model.SubmodelElementCollection)3 File (java.io.File)3