Search in sources :

Example 6 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell 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 7 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell 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 8 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell 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)

Example 9 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testPUTAssetInformation.

@Test
public void testPUTAssetInformation() throws IOException, DeserializationException {
    AssetAdministrationShell aas = environment.getAssetAdministrationShells().get(1);
    AssetInformation expected = aas.getAssetInformation();
    expected.setAssetKind(AssetKind.TYPE);
    String url = HTTP_SHELLS + "/" + Base64.getUrlEncoder().encodeToString(aas.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8)) + "/aas/asset-information";
    HttpResponse response = putCall(url, expected);
    // TODO: StatusCode of spec seems to be wrong 204
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    AssetInformation actual = getCall(url, AssetInformation.class);
    Assert.assertEquals(expected, actual);
}
Also used : AssetInformation(io.adminshell.aas.v3.model.AssetInformation) 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 10 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testPUTSpecificShellEvent.

@Test
public void testPUTSpecificShellEvent() {
    AssetAdministrationShell expected = environment.getAssetAdministrationShells().get(1);
    expected.setIdShort("changed");
    String url = HTTP_SHELLS + "/" + Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
    setUpEventCheck(expected, ElementUpdateEventMessage.class, () -> putCall(url, expected, AssetAdministrationShell.class));
}
Also used : DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Aggregations

AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)46 Test (org.junit.Test)29 DefaultAssetAdministrationShell (io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell)22 LangString (io.adminshell.aas.v3.model.LangString)14 HttpResponse (org.apache.http.HttpResponse)13 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)10 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)10 Reference (io.adminshell.aas.v3.model.Reference)8 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)8 AssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification)7 Submodel (io.adminshell.aas.v3.model.Submodel)7 GlobalAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification)6 AssetInformation (io.adminshell.aas.v3.model.AssetInformation)6 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)6 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)6 DefaultKey (io.adminshell.aas.v3.model.impl.DefaultKey)6 AASFull (de.fraunhofer.iosb.ilt.faaast.service.model.AASFull)5 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)5 AssetAdministrationShellEnvironment (io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment)5 IdentifierType (io.adminshell.aas.v3.model.IdentifierType)5