Skip to content

Commit

Permalink
bugfix: SAMM-CLI aas generation: add samm:description to ConceptDescr…
Browse files Browse the repository at this point in the history
…iption. Add tests

Changes:
- Add tests;

Fixes eclipse-esmf#434
  • Loading branch information
Yauhenikapl committed Dec 19, 2023
1 parent fdd9c41 commit 9132d4c
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<SubmodelElement> operations = environment.getSubmodels().get( 0 ).getSubmodelElements();
Expand All @@ -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<String> semanticIds, final Environment env ) {
semanticIds.forEach( x -> getDataSpecificationIEC61360( x, env ) );
}
Expand Down

0 comments on commit 9132d4c

Please sign in to comment.