Skip to content

Commit 137dc61

Browse files
committed
Update URN rules
1 parent 3ba23a8 commit 137dc61

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ private String iriToReversedHostNameNotation( final IRI iri ) {
200200
final String[] pathParts = uri.getPath().split( "/" );
201201
final String path = Arrays.stream( pathParts )
202202
.filter( StringUtils::isNotBlank )
203-
.limit( Math.max( 0, pathParts.length - 2 ) )
204203
.collect( Collectors.joining( "." ) );
205204

206-
return reversedHost + ( path.isEmpty() ? "" : "." + path );
205+
return reversedHost + "." + path;
207206
}
208207

209208
private Optional<IRI> iri( final String lexicalRepresentation ) {

core/esmf-aspect-model-urn/src/test/java/org/eclipse/esmf/aspectmodel/urn/AspectModelUrnTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,19 @@ void validNamespaceTest() throws URISyntaxException {
343343
assertThat( elementUrnWithDash.getNamespaceMainPart() ).isEqualTo( "org.eclipse.esmf-test" );
344344
}
345345

346+
@Test
347+
void invalidNamespaceTest() throws URISyntaxException {
348+
final URI validNamespaceUrnUnderscore = new URI( "urn:samm:com.bosch.nexeed.digitaltwin:aspect-model:Er?ors:1.1.0#TestAspect" );
349+
final AspectModelUrn elementUrnWithUnderscore = AspectModelUrn.fromUrn( validNamespaceUrnUnderscore );
350+
assertThat( elementUrnWithUnderscore.getNamespaceMainPart() ).isNotEmpty();
351+
assertThat( elementUrnWithUnderscore.getNamespaceMainPart() ).isEqualTo( "org.eclipse.esmf_test" );
352+
353+
final URI invalidNamespaceUrnDash = new URI( "urn:samm:org.eclipse.esmf-test:0.0.1#TestAspect" );
354+
final AspectModelUrn elementUrnWithDash = AspectModelUrn.fromUrn( invalidNamespaceUrnDash );
355+
assertThat( elementUrnWithDash.getNamespaceMainPart() ).isNotEmpty();
356+
assertThat( elementUrnWithDash.getNamespaceMainPart() ).isEqualTo( "org.eclipse.esmf-test" );
357+
}
358+
346359
@Test
347360
void invalidModelElementNameTest() throws URISyntaxException {
348361
final URI invalidRootModelElementName = new URI( sammBaseUri + "aspect-model:Er?ors:1.1.0#TestAspect" );

0 commit comments

Comments
 (0)