Search in sources :

Example 1 with StatusCode

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.StatusCode in project FAAAST-Service by FraunhoferIOSB.

the class HttpEndpointTest method testGetAllSubmodelElements_ValueOnly.

@Test
public void testGetAllSubmodelElements_ValueOnly() throws Exception {
    List<SubmodelElement> submodelElements = List.of(new DefaultProperty.Builder().idShort("property1").value("hello world").valueType("string").build(), new DefaultRange.Builder().idShort("range1").min("1.1").max("2.0").valueType("double").build());
    when(serviceContext.execute(any())).thenReturn(GetAllSubmodelElementsResponse.builder().statusCode(StatusCode.Success).payload(submodelElements).build());
    ContentResponse response = execute(HttpMethod.GET, "/submodels/foo/submodel/submodel-elements", new OutputModifier.Builder().content(Content.Value).build());
    Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
    List<ElementValue> actual = deserializer.readValueList(new String(response.getContent()), TypeExtractor.extractTypeInfo(submodelElements));
    List<ElementValue> expected = submodelElements.stream().map(x -> (ElementValue) ElementValueMapper.toValue(x)).collect(Collectors.toList());
    Assert.assertEquals(expected, actual);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) TypeExtractor(de.fraunhofer.iosb.ilt.faaast.service.typing.TypeExtractor) BeforeClass(org.junit.BeforeClass) Date(java.util.Date) DefaultRange(io.adminshell.aas.v3.model.impl.DefaultRange) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) LoggerFactory(org.slf4j.LoggerFactory) ServiceContext(de.fraunhofer.iosb.ilt.faaast.service.ServiceContext) AASFull(de.fraunhofer.iosb.ilt.faaast.service.model.AASFull) HttpJsonDeserializer(de.fraunhofer.iosb.ilt.faaast.service.endpoint.http.serialization.HttpJsonDeserializer) Request(org.eclipse.jetty.client.api.Request) Identifier(io.adminshell.aas.v3.model.Identifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) DefaultProperty(io.adminshell.aas.v3.model.impl.DefaultProperty) ServerSocket(java.net.ServerSocket) HttpClient(org.eclipse.jetty.client.HttpClient) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) Message(de.fraunhofer.iosb.ilt.faaast.service.model.api.Message) StatusCode(de.fraunhofer.iosb.ilt.faaast.service.model.api.StatusCode) StringRequestContent(org.eclipse.jetty.client.util.StringRequestContent) Map(java.util.Map) HttpStatus(org.eclipse.jetty.http.HttpStatus) AfterClass(org.junit.AfterClass) Logger(org.slf4j.Logger) EncodingHelper(de.fraunhofer.iosb.ilt.faaast.service.util.EncodingHelper) ElementValueMapper(de.fraunhofer.iosb.ilt.faaast.service.model.value.mapper.ElementValueMapper) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) de.fraunhofer.iosb.ilt.faaast.service.model.api.response(de.fraunhofer.iosb.ilt.faaast.service.model.api.response) Collectors(java.util.stream.Collectors) Result(de.fraunhofer.iosb.ilt.faaast.service.model.api.Result) List(java.util.List) HttpMethod(org.eclipse.jetty.http.HttpMethod) Ignore(org.junit.Ignore) CoreConfig(de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig) ElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Assert(org.junit.Assert) MessageType(de.fraunhofer.iosb.ilt.faaast.service.model.api.MessageType) Content(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Content) Mockito.mock(org.mockito.Mockito.mock) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) ElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue) DefaultProperty(io.adminshell.aas.v3.model.impl.DefaultProperty) Test(org.junit.Test)

Aggregations

ServiceContext (de.fraunhofer.iosb.ilt.faaast.service.ServiceContext)1 CoreConfig (de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig)1 HttpJsonDeserializer (de.fraunhofer.iosb.ilt.faaast.service.endpoint.http.serialization.HttpJsonDeserializer)1 AASFull (de.fraunhofer.iosb.ilt.faaast.service.model.AASFull)1 Message (de.fraunhofer.iosb.ilt.faaast.service.model.api.Message)1 MessageType (de.fraunhofer.iosb.ilt.faaast.service.model.api.MessageType)1 Result (de.fraunhofer.iosb.ilt.faaast.service.model.api.Result)1 StatusCode (de.fraunhofer.iosb.ilt.faaast.service.model.api.StatusCode)1 Content (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Content)1 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)1 de.fraunhofer.iosb.ilt.faaast.service.model.api.response (de.fraunhofer.iosb.ilt.faaast.service.model.api.response)1 ElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue)1 ElementValueMapper (de.fraunhofer.iosb.ilt.faaast.service.model.value.mapper.ElementValueMapper)1 TypeExtractor (de.fraunhofer.iosb.ilt.faaast.service.typing.TypeExtractor)1 EncodingHelper (de.fraunhofer.iosb.ilt.faaast.service.util.EncodingHelper)1 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)1 Identifier (io.adminshell.aas.v3.model.Identifier)1 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)1 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)1 DefaultProperty (io.adminshell.aas.v3.model.impl.DefaultProperty)1