use of io.adminshell.aas.v3.dataformat.SerializationException in project FAAAST-Service by FraunhoferIOSB.
the class IntegrationTestHttpEndpoint method testGetSpecificSubmodelEvent.
@Test
public void testGetSpecificSubmodelEvent() throws SerializationException {
Submodel expected = environment.getSubmodels().get(1);
String identifier = Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
setUpEventCheck(expected, ElementReadEventMessage.class, () -> getCall(HTTP_SUBMODELS + "/" + identifier + "/submodel"));
}
use of io.adminshell.aas.v3.dataformat.SerializationException in project FAAAST-Service by FraunhoferIOSB.
the class IntegrationTestHttpEndpoint method testPostSubmodelsEvent.
@Test
public void testPostSubmodelsEvent() throws SerializationException {
Submodel expected = new DefaultSubmodel.Builder().identification(new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier("newTestSubmodel").build()).build();
setUpEventCheck(expected, ElementCreateEventMessage.class, () -> postCall(HTTP_SUBMODELS, expected));
}
use of io.adminshell.aas.v3.dataformat.SerializationException 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.SerializationException in project FAAAST-Service by FraunhoferIOSB.
the class IntegrationTestHttpEndpoint method testGetSubmodelsWithSemanticId.
@Test
public void testGetSubmodelsWithSemanticId() throws SerializationException {
Submodel expected = environment.getSubmodels().get(1);
String semnaticId = Base64.getUrlEncoder().encodeToString(new JsonSerializer().write(expected.getSemanticId()).getBytes(StandardCharsets.UTF_8));
List<Submodel> actual = getListCall(HTTP_SUBMODELS + "?semanticId=" + semnaticId, Submodel.class);
Assert.assertEquals(List.of(expected), actual);
}
use of io.adminshell.aas.v3.dataformat.SerializationException in project FAAAST-Service by FraunhoferIOSB.
the class RequestMappingManagerTest method testSetSubmodelElementValueByPath_ContentNormal.
@Test
public void testSetSubmodelElementValueByPath_ContentNormal() throws SerializationException, InvalidRequestException, Exception {
SetSubmodelElementValueByPathRequest expected = SetSubmodelElementValueByPathRequest.<String>builder().id(SUBMODEL.getIdentification()).path(ReferenceHelper.toKeys(SUBMODEL_ELEMENT_REF)).build();
when(serviceContext.getTypeInfo(any())).thenReturn(TypeExtractor.extractTypeInfo(SUBMODEL_ELEMENT));
Request temp = mappingManager.map(HttpRequest.builder().method(HttpMethod.PUT).path("submodels/" + EncodingHelper.base64UrlEncode(SUBMODEL.getIdentification().getIdentifier()) + "/submodel/submodel-elements/" + ElementPathHelper.toElementPath(SUBMODEL_ELEMENT_REF)).query("content=value").body(serializer.write(SUBMODEL_ELEMENT)).build());
SetSubmodelElementValueByPathRequest actual = (SetSubmodelElementValueByPathRequest) temp;
Assert.assertEquals(expected.getId(), actual.getId());
Assert.assertEquals(expected.getPath(), actual.getPath());
Assert.assertEquals(ElementValueMapper.toValue(SUBMODEL_ELEMENT), actual.getValueParser().parse(actual.getRawValue(), SubmodelElement.class));
}
Aggregations