Search in sources :

Example 1 with JsonSerializer

use of io.adminshell.aas.v3.dataformat.json.JsonSerializer 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);
}
Also used : DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Submodel(io.adminshell.aas.v3.model.Submodel) LangString(io.adminshell.aas.v3.model.LangString) JsonSerializer(de.fraunhofer.iosb.ilt.faaast.service.dataformat.json.JsonSerializer) Test(org.junit.Test)

Example 2 with JsonSerializer

use of io.adminshell.aas.v3.dataformat.json.JsonSerializer 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 3 with JsonSerializer

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

the class IntegrationTestHttpEndpoint method testGetSubmodelsEvent.

@Test
public void testGetSubmodelsEvent() throws SerializationException {
    Submodel expected = environment.getSubmodels().get(1);
    String semnaticId = Base64.getUrlEncoder().encodeToString(new JsonSerializer().write(expected.getSemanticId()).getBytes(StandardCharsets.UTF_8));
    setUpEventCheck(expected, ElementReadEventMessage.class, () -> getListCall(HTTP_SUBMODELS + "?semanticId=" + semnaticId));
}
Also used : DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Submodel(io.adminshell.aas.v3.model.Submodel) LangString(io.adminshell.aas.v3.model.LangString) JsonSerializer(de.fraunhofer.iosb.ilt.faaast.service.dataformat.json.JsonSerializer) Test(org.junit.Test)

Aggregations

LangString (io.adminshell.aas.v3.model.LangString)3 Submodel (io.adminshell.aas.v3.model.Submodel)3 DefaultSubmodel (io.adminshell.aas.v3.model.impl.DefaultSubmodel)3 Test (org.junit.Test)3 JsonSerializer (de.fraunhofer.iosb.ilt.faaast.service.dataformat.json.JsonSerializer)2 HttpResponse (org.apache.http.HttpResponse)1