Search in sources :

Example 16 with DeserializationException

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

the class IntegrationTestHttpEndpoint method testGETSubmodelReferences.

@Test
public void testGETSubmodelReferences() throws IOException, DeserializationException {
    List<Reference> expected = environment.getAssetAdministrationShells().get(0).getSubmodels();
    String identifier = Base64.getUrlEncoder().encodeToString(environment.getAssetAdministrationShells().get(0).getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
    String url = HTTP_SHELLS + "/" + identifier + "/aas/submodels";
    HttpResponse response = getListCall(url);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    List<Reference> actual = retrieveResourceFromResponseList(response, Reference.class);
    Assert.assertEquals(expected, actual);
}
Also used : Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) HttpResponse(org.apache.http.HttpResponse) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Example 17 with DeserializationException

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

the class IntegrationTestHttpEndpoint method testGetSpecificSubmodelContent.

@Test
public void testGetSpecificSubmodelContent() throws SerializationException, IOException, DeserializationException {
    Submodel expected = environment.getSubmodels().get(3);
    String identifier = Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
    String url = HTTP_SUBMODELS + "/" + identifier + "/submodel?content=normal";
    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));
// TODO: Fix value serialization of DefaultOperation
/*
         * url = HTTP_SUBMODELS + "/" + identifier + "/submodel?content=value";
         * response = getCall(url);
         * Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         * Assert.assertEquals(new JsonSerializer().write(expected, new
         * OutputModifier.Builder().content(Content.Value).build()),
         * EntityUtils.toString(response.getEntity()));
         */
}
Also used : DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Submodel(io.adminshell.aas.v3.model.Submodel) HttpResponse(org.apache.http.HttpResponse) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Example 18 with DeserializationException

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

the class IntegrationTestHttpEndpoint method testPOSTSubmodelReference.

@Test
public void testPOSTSubmodelReference() throws IOException, DeserializationException {
    List<Reference> expected = environment.getAssetAdministrationShells().get(0).getSubmodels();
    Reference newReference = new DefaultReference.Builder().key(new DefaultKey.Builder().value("test").idType(KeyType.IRI).build()).build();
    expected.add(newReference);
    String identifier = Base64.getUrlEncoder().encodeToString(environment.getAssetAdministrationShells().get(0).getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
    String url = HTTP_SHELLS + "/" + identifier + "/aas/submodels";
    HttpResponse response = postCall(url, newReference);
    Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode());
    List<Reference> actual = getListCall(url, Reference.class);
    Assert.assertEquals(expected, actual);
}
Also used : Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) HttpResponse(org.apache.http.HttpResponse) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Example 19 with DeserializationException

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

the class IntegrationTestHttpEndpoint method testDELETESpecificShell.

@Test
public void testDELETESpecificShell() throws IOException, DeserializationException {
    AssetAdministrationShell expected = environment.getAssetAdministrationShells().get(1);
    String identifier = Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
    String url = HTTP_SHELLS + "/" + identifier;
    HttpResponse response = deleteCall(url);
    // TODO: StatusCode of spec seems to be wrong 204
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    Assert.assertEquals(0, response.getEntity().getContentLength());
    List<AssetAdministrationShell> actual = getListCall(HTTP_SHELLS, AssetAdministrationShell.class);
    Assert.assertFalse(actual.contains(expected));
}
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 20 with DeserializationException

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

the class StarterTest method testAASEnvironment.

private void testAASEnvironment(String filePath, Deserializer deserializer) throws Exception, FileNotFoundException, DeserializationException {
    AssetAdministrationShellEnvironment expected = deserializer.read(new File(filePath));
    AssetAdministrationShellEnvironment actual = environmentFactory.getAASEnvironment(filePath);
    Assert.assertEquals(expected, actual);
}
Also used : File(java.io.File) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) DefaultAssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment)

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