Skip to content

Commit

Permalink
Merge pull request #289 from eclipse-esmf/285-specify-format-for-urn-…
Browse files Browse the repository at this point in the history
…namespace-parts

Specify namespace in URN structure
  • Loading branch information
Yauhenikapl authored Mar 21, 2024
2 parents 1141285 + c79dfe5 commit 35864c7
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ samm:NamespaceShape
select $this ?value ?code
where {
bind( str( $this ) as ?value )
filter( !regex( ?value, "^urn:samm:[^:]+:[0-9]+.[0-9]+.[0-9]+#$" ))
filter( !regex( ?value, "^urn:samm:[a-zA-Z][a-zA-Z0-9]{1,62}.[a-zA-Z0-9-]{1,63}(.[a-zA-Z0-9_-]{1,63})+:[0-9]+.[0-9]+.[0-9]+#$" ))
bind( 'ERR_WRONG_URN' as ?code )
}
""" ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,52 @@ void testEmptyPropertiesExpectFailureSamm_2_2_0( final KnownVersion metaModelVer

@ParameterizedTest
@MethodSource( value = "versionsStartingWith2_2_0")
void testNamespaceInvalidUrn( final KnownVersion metaModelVersion) {
void testNamespaceInvalidUrnPattern( final KnownVersion metaModelVersion) {
final String focusNode = "urn:samm:org.eclipse.esmf.samm.test:1.q.0#";

final SemanticError resultForInvalidUrnNamespace = new SemanticError(
"Namespace '<urn:samm:org.eclipse.esmf.samm.test:1.q.0#>' uses an invalid URN pattern",
focusNode, "", violationUrn, focusNode
);
expectSemanticValidationErrors( "namespace", "TestNamespaceInvalidUrn",
expectSemanticValidationErrors( "namespace", "TestNamespaceInvalidUrnVersion",
metaModelVersion, resultForInvalidUrnNamespace );
}

@ParameterizedTest
@MethodSource( value = "versionsStartingWith2_2_0")
void testNamespaceInvalidUrn( final KnownVersion metaModelVersion) {
final String focusNode = "urn:samm:org.eclipse.esmf.samm+:1.0.0#";

final SemanticError resultForInvalidUrnNamespace = new SemanticError(
"Namespace '<urn:samm:org.eclipse.esmf.samm+:1.0.0#>' uses an invalid URN pattern",
focusNode, "", violationUrn, focusNode
);
expectSemanticValidationErrors( "namespace", "TestNamespaceInvalidUrn",
metaModelVersion, resultForInvalidUrnNamespace );
}

@ParameterizedTest
@MethodSource( value = "versionsStartingWith2_2_0")
void testNamespaceInvalidUrnStructure( final KnownVersion metaModelVersion) {
final String focusNode = "urn:samm:org:1.0.0#";

final SemanticError resultForInvalidUrnNamespace = new SemanticError(
"Namespace '<urn:samm:org:1.0.0#>' uses an invalid URN pattern",
focusNode, "", violationUrn, focusNode
);
expectSemanticValidationErrors( "namespace", "TestNamespaceInvalidUrnStructure",
metaModelVersion, resultForInvalidUrnNamespace );
}

@ParameterizedTest
@MethodSource( value = "versionsStartingWith2_2_0")
void testNamespaceValidWithDash( final KnownVersion metaModelVersion) {
checkValidity( "namespace", "TestNamespaceValidWithDash", metaModelVersion );
}

@ParameterizedTest
@MethodSource( value = "versionsStartingWith2_2_0")
void testNamespaceValidWithUnderscore( final KnownVersion metaModelVersion) {
checkValidity( "namespace", "TestNamespaceValidWithUnderscore", metaModelVersion );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# SPDX-License-Identifier: MPL-2.0
#
@prefix : <urn:samm:org.eclipse.esmf.samm.test:1.q.0#> .
@prefix : <urn:samm:org.eclipse.esmf.samm+:1.0.0#> .
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
#
# See the AUTHORS file(s) distributed with this work for additional
# information regarding authorship.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
@prefix : <urn:samm:org:1.0.0#> .
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

: a samm:Namespace ;
samm:preferredName "Test Preferred Name"@en ;
samm:description "Test description"@en ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
#
# See the AUTHORS file(s) distributed with this work for additional
# information regarding authorship.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
@prefix : <urn:samm:org.eclipse.esmf.samm.test:1.q.0#> .
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

: a samm:Namespace ;
samm:preferredName "Test Preferred Name"@en ;
samm:description "Test description"@en ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
#
# See the AUTHORS file(s) distributed with this work for additional
# information regarding authorship.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
@prefix : <urn:samm:org.eclipse.esmf.samm-test:1.0.0#> .
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

: a samm:Namespace ;
samm:preferredName "Test Preferred Name"@en ;
samm:description "Test description"@en ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
#
# See the AUTHORS file(s) distributed with this work for additional
# information regarding authorship.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
@prefix : <urn:samm:org.eclipse.esmf.samm_test:1.0.0#> .
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

: a samm:Namespace ;
samm:preferredName "Test Preferred Name"@en ;
samm:description "Test description"@en ;

0 comments on commit 35864c7

Please sign in to comment.