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);
}
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()));
*/
}
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);
}
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));
}
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);
}
Aggregations