From 9132d4c38d51fa1db28958db8b51cf8e7a638968 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Tue, 19 Dec 2023 13:09:11 +0300 Subject: [PATCH] bugfix: SAMM-CLI aas generation: add samm:description to ConceptDescription. Add tests Changes: - Add tests; Fixes #434 --- .../aas/AspectModelAASGeneratorTest.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAASGeneratorTest.java b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAASGeneratorTest.java index 15b0de0eb..3d7b161ad 100644 --- a/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAASGeneratorTest.java +++ b/core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAASGeneratorTest.java @@ -32,6 +32,8 @@ import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultDataSpecificationIec61360; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEmbeddedDataSpecification; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultOperation; import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel; import org.eclipse.esmf.metamodel.Aspect; @@ -320,7 +322,7 @@ public void testGeneration( final TestAspect testAspect ) throws IOException, De } @Test - void testGenerateAasxFRomAspectModelWithOperations () throws IOException, DeserializationException { + void testGenerateAasxFromAspectModelWithOperations () throws IOException, DeserializationException { final Environment environment = getAssetAdministrationShellFromAspect( TestAspect.ASPECT_WITH_OPERATION ); List operations = environment.getSubmodels().get( 0 ).getSubmodelElements(); @@ -335,6 +337,25 @@ void testGenerateAasxFRomAspectModelWithOperations () throws IOException, Deseri assertEquals( 7, environment.getConceptDescriptions().size() ); } + @Test + void testGeneratedAasxFromAspectModelWithPropertiesWithDescriptions () throws IOException, DeserializationException { + final Environment environment = getAssetAdministrationShellFromAspect( TestAspect.ASPECT_WITH_PROPERTY_WITH_DESCRIPTIONS ); + + final Property property = (Property) environment.getSubmodels().get( 0 ).getSubmodelElements().get( 0 ); + + assertEquals( 1, environment.getSubmodels().get( 0 ).getSubmodelElements().size() ); + assertEquals( 2, environment.getConceptDescriptions().size() ); + assertEquals( 1, environment.getConceptDescriptions().get( 1 ).getEmbeddedDataSpecifications().size() ); + + final DataSpecificationIec61360 dataSpecificationIec61360 = + (DataSpecificationIec61360) environment.getConceptDescriptions().get( 1 ).getEmbeddedDataSpecifications().get( 0 ).getDataSpecificationContent(); + + assertThat( dataSpecificationIec61360.getDefinition().get( 1 ).getText() ).isEqualTo( "Test Description" ); + + assertThat( property.getDescription() ).isEmpty(); + + } + private void checkDataSpecificationIEC61360( final Set semanticIds, final Environment env ) { semanticIds.forEach( x -> getDataSpecificationIEC61360( x, env ) ); }