Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
Fixes #285
  • Loading branch information
Yauhenikapl committed Mar 21, 2024
1 parent 8254d5d commit c79dfe5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 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:[a-zA-Z0-9._-]+:[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 @@ -38,16 +38,29 @@ void testNamespaceInvalidUrnPattern( final KnownVersion metaModelVersion) {
@ParameterizedTest
@MethodSource( value = "versionsStartingWith2_2_0")
void testNamespaceInvalidUrn( final KnownVersion metaModelVersion) {
final String focusNode = "urn:samm:org.eclipse.esmf.samm+test:1.0.0#";
final String focusNode = "urn:samm:org.eclipse.esmf.samm+:1.0.0#";

final SemanticError resultForInvalidUrnNamespace = new SemanticError(
"Namespace '<urn:samm:org.eclipse.esmf.samm+test:1.0.0#>' uses an invalid URN pattern",
"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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
#
# See the AUTHORS file(s) distributed with this work for additional
# information regarding authorship.
Expand All @@ -10,7 +10,7 @@
#
# SPDX-License-Identifier: MPL-2.0
#
@prefix : <urn:samm:org.eclipse.esmf.samm+test:1.0.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 ;

0 comments on commit c79dfe5

Please sign in to comment.