Skip to content

Commit

Permalink
Merge pull request #650 from bci-oss/649-invalid-aspectmodelurn-is-va…
Browse files Browse the repository at this point in the history
…lid-in-latest-version

Invalid AspectModelURN is valid in latest version
  • Loading branch information
atextor authored Sep 9, 2024
2 parents c937607 + 8e05f3c commit 675ee06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ private static String getName( final boolean isSammUrn, final List<String> urnPa
return modelElementName;
}
if ( MODEL_ELEMENT_TYPES.contains( elementType ) ) {
//Check root model element name before current element name
checkElementName( urnParts.get( ASPECT_NAME_INDEX ), "model element" );

final String modelElementName = urnParts.get( MODEL_ELEMENT_NAME_INDEX );
checkElementName( modelElementName, elementType.getValue() + " element" );
return modelElementName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,17 @@ void validNamespaceTest() throws URISyntaxException {
assertThat( elementUrnWithDash.getNamespaceMainPart() ).isNotEmpty();
assertThat( elementUrnWithDash.getNamespaceMainPart() ).isEqualTo( "org.eclipse.esmf-test" );
}

@Test
void invalidModelElementNameTest() throws URISyntaxException {
final URI invalidRootModelElementName = new URI( sammBaseUri + "aspect-model:Er?ors:1.1.0#TestAspect" );
assertThatExceptionOfType( UrnSyntaxException.class )
.isThrownBy( () -> AspectModelUrn.fromUrn( invalidRootModelElementName ) )
.withMessage( "The model element name must match \\p{Alpha}\\p{Alnum}*: Er?ors" );

final URI invalidModelElementName = new URI( sammBaseUri + "aspect-model:Er?ors:1.1.0:dummy#TestAspect" );
assertThatExceptionOfType( UrnSyntaxException.class )
.isThrownBy( () -> AspectModelUrn.fromUrn( invalidModelElementName ) )
.withMessage( "The model element name must match \\p{Alpha}\\p{Alnum}*: Er?ors" );
}
}

0 comments on commit 675ee06

Please sign in to comment.