use of io.adminshell.aas.v3.model.Submodel in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointIT method testSubmodelInterfaceGetSubmodelLevelCore.
@Test
public void testSubmodelInterfaceGetSubmodelLevelCore() throws IOException, DeserializationException, InterruptedException, URISyntaxException, SerializationException, MessageBusException {
Submodel expected = DeepCopyHelper.deepCopy(environment.getSubmodels().get(2), Submodel.class);
expected.getSubmodelElements().forEach(x -> {
if (SubmodelElementCollection.class.isAssignableFrom(x.getClass())) {
((SubmodelElementCollection) x).getValues().clear();
}
});
assertEvent(messageBus, ElementReadEventMessage.class, expected, LambdaExceptionHelper.wrap(x -> executeAndAssertSingleEntity(HttpMethod.GET, API_PATHS.submodelRepository().submodelInterface(expected).submodel(Level.CORE), StatusCode.SUCCESS, null, expected, Submodel.class)));
}
use of io.adminshell.aas.v3.model.Submodel in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointIT method testSubmodelInterfaceGetSubmodelLevelCoreContentPath.
@Test
public void testSubmodelInterfaceGetSubmodelLevelCoreContentPath() throws IOException, DeserializationException, InterruptedException, URISyntaxException, SerializationException, MessageBusException {
Submodel submodel = DeepCopyHelper.deepCopy(environment.getSubmodels().get(2), Submodel.class);
submodel.getSubmodelElements().forEach(x -> {
if (SubmodelElementCollection.class.isAssignableFrom(x.getClass())) {
((SubmodelElementCollection) x).getValues().clear();
}
});
Path expected = Path.builder().id("TestSubmodel3").child("ExampleRelationshipElement").child("ExampleAnnotatedRelationshipElement").child("ExampleOperation").child("ExampleCapability").child("ExampleBasicEvent").child(Path.builder().id("ExampleSubmodelCollectionOrdered").child("ExampleProperty").child("ExampleMultiLanguageProperty").child("ExampleRange").build()).child(Path.builder().id("ExampleSubmodelCollectionUnordered").child("ExampleBlob").child("ExampleFile").child("ExampleReferenceElement").build()).build();
assertEvent(messageBus, ElementReadEventMessage.class, submodel, LambdaExceptionHelper.wrap(x -> {
HttpResponse<String> response = HttpHelper.get(API_PATHS.submodelRepository().submodelInterface(submodel).submodel(Level.CORE, Content.PATH));
Assert.assertEquals(toHttpStatusCode(StatusCode.SUCCESS), response.statusCode());
JSONAssert.assertEquals(mapper.writeValueAsString(expected.asCorePath().getPaths()), response.body(), false);
}));
}
use of io.adminshell.aas.v3.model.Submodel in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointIT method testSubmodelRepositoryDeleteSubmodel.
@Test
public void testSubmodelRepositoryDeleteSubmodel() throws IOException, DeserializationException, InterruptedException, URISyntaxException, SerializationException, MessageBusException {
Submodel expected = environment.getSubmodels().get(1);
List<Submodel> before = HttpHelper.getWithMultipleResult(API_PATHS.submodelRepository().submodels(), Submodel.class);
Assert.assertTrue(before.contains(expected));
assertEvent(messageBus, ElementDeleteEventMessage.class, expected, LambdaExceptionHelper.wrap(x -> executeAndAssert(HttpMethod.DELETE, API_PATHS.submodelRepository().submodel(expected), StatusCode.SUCCESS)));
List<Submodel> after = HttpHelper.getWithMultipleResult(API_PATHS.submodelRepository().submodels(), Submodel.class);
Assert.assertFalse(after.contains(expected));
}
use of io.adminshell.aas.v3.model.Submodel in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointIT method testSubmodelRepositoryCreateSubmodel.
@Test
public void testSubmodelRepositoryCreateSubmodel() throws IOException, DeserializationException, InterruptedException, URISyntaxException, SerializationException, MessageBusException {
Submodel expected = new DefaultSubmodel.Builder().identification(new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier("newSubmodel").build()).build();
assertEvent(messageBus, ElementCreateEventMessage.class, expected, LambdaExceptionHelper.wrap(x -> executeAndAssertSingleEntity(HttpMethod.POST, API_PATHS.submodelRepository().submodels(), StatusCode.SUCCESS_CREATED, expected, expected, Submodel.class)));
Assert.assertTrue(HttpHelper.getWithMultipleResult(API_PATHS.submodelRepository().submodels(), Submodel.class).contains(expected));
}
use of io.adminshell.aas.v3.model.Submodel in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointIT method testSubmodelInterfaceGetSubmodelElement.
@Test
public void testSubmodelInterfaceGetSubmodelElement() throws IOException, DeserializationException, InterruptedException, URISyntaxException, SerializationException, MessageBusException {
Submodel submodel = environment.getSubmodels().get(0);
SubmodelElement expected = submodel.getSubmodelElements().get(0);
assertEvent(messageBus, ElementReadEventMessage.class, expected, LambdaExceptionHelper.wrap(x -> executeAndAssertSingleEntity(HttpMethod.GET, API_PATHS.submodelRepository().submodelInterface(submodel).submodelElement(expected), StatusCode.SUCCESS, null, expected, SubmodelElement.class)));
}
Aggregations