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