Skip to content

Commit 25022f9

Browse files
authored
Merge pull request #799 from bci-oss/769-take-payload-names-into-account
Set `IdShort` for element when `PayloadName` is present and add corresponding test
2 parents 3fa21ea + ec9f37f commit 25022f9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasVisitor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ private Optional<SubmodelElement> mapText( final Property property, final Contex
285285
final SubmodelElement element = context.getPropertyResult();
286286
element.setSupplementalSemanticIds( updateGlobalReferenceWithSeeReferences( element, property ) );
287287

288+
if ( !property.getPayloadName().isEmpty() ) {
289+
element.setIdShort( property.getPayloadName() );
290+
}
291+
288292
recursiveProperty.remove( property );
289293

290294
return Optional.of( element );

core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAasGeneratorTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void testGenerateAasxFromAspectModelWithEnumeration() throws DeserializationExce
360360
@EnumSource( value = TestAspect.class )
361361
// anonymous enumeration in test has no urn for enum values but is required for Concept
362362
// Description referencing
363-
public void testGeneration( final TestAspect testAspect ) throws DeserializationException {
363+
void testGeneration( final TestAspect testAspect ) throws DeserializationException {
364364
final String aasXmlString = aspectToAasXml( testAspect );
365365
final byte[] aasXmlInput = aasXmlString.getBytes();
366366

@@ -424,6 +424,15 @@ void testGeneratedAasxFromAspectModelSemanticIdsAreGlobalReferences() throws Des
424424
assertThat( property.getSemanticId().getKeys().get( 0 ).getType() ).isEqualTo( KeyTypes.GLOBAL_REFERENCE );
425425
}
426426

427+
@Test
428+
void testAspectWithPayloadName() throws DeserializationException {
429+
final Environment environment = getAssetAdministrationShellFromAspect( TestAspect.ASPECT_WITH_PROPERTY_WITH_PAYLOAD_NAME );
430+
431+
final Property property = (Property) environment.getSubmodels().get( 0 ).getSubmodelElements().get( 0 );
432+
assertThat( environment.getSubmodels().get( 0 ).getSubmodelElements() ).hasSize( 1 );
433+
assertThat( environment.getSubmodels().get( 0 ).getSubmodelElements().get( 0 ).getIdShort() ).isEqualTo( property.getIdShort() );
434+
}
435+
427436
private void checkDataSpecificationIec61360( final Set<String> semanticIds, final Environment env ) {
428437
semanticIds.forEach( semanticId -> getDataSpecificationIec61360( semanticId, env ) );
429438
}

0 commit comments

Comments
 (0)