From 43b02d47b8427db57ebef39bf00a4342eab3b524 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Mon, 8 Jan 2024 15:49:13 +0300 Subject: [PATCH 1/6] RBS-12926-HTML Generation doesn't render the graph Changes: - add validation of empty Constraint; - add test. --- .../2.2.0/aspect-meta-model-shapes.ttl | 13 +++++++++ .../eclipse/esmf/samm/AbstractShapeTest.java | 6 ++++ .../esmf/samm/ConstraintShapeTest.java | 29 +++++++++++++++---- .../1.0.0/TestConstraintWithoutProperties.ttl | 18 ++++++++++++ 4 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithoutProperties.ttl diff --git a/esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl b/esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl index f76c11b2..5a73d17e 100644 --- a/esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl +++ b/esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl @@ -499,6 +499,19 @@ samm:ConstraintShape sh:maxCount 0 ; sh:name "dataType" ; sh:description "A Constraint may not change the data type of the Characteristic being constrained." ; + ] ; + sh:sparql [ + a sh:SPARQLConstraint ; + sh:message "Constraint '{$this}' must have a baseCharacteristic or a dataType." ; + sh:prefixes samm:prefixDeclarations ; + sh:select """ + select $this ?message ?code + where { + $this rdf:type samm:Constraint . + bind( "It is necessary to use a SubClass and not its parent." as ?message ) + bind( 'ERR_WRONG_DATATYPE' as ?code ) + } + """ ] . samm:OperationShape diff --git a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java index fe7441de..96662833 100644 --- a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java +++ b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java @@ -67,6 +67,10 @@ protected static Stream versionsUpToIncluding1_0_0() { return versionsUpToIncluding( KnownVersion.SAMM_1_0_0 ); } + protected static Stream versionsUpToIncluding2_1_0() { + return versionsUpToIncluding( KnownVersion.SAMM_2_1_0 ); + } + final String violationUrn = "http://www.w3.org/ns/shacl#Violation"; final String warningUrn = "http://www.w3.org/ns/shacl#Warning"; @@ -78,6 +82,8 @@ protected static Stream versionsUpToIncluding1_0_0() { final String messageInvalidLangString = "Value must be a valid literal of type langString"; final String messageDuplicateProperty = "Property may only have 1 value, but found 2"; final String messageMissingDatatype = "No datatype is defined on the Characteristic instance '{$this}'."; + + final String messageHasToUseSubClass = "It is necessary to use a SubClass and not its parent."; final String messageInvalidEntryEntityPropertyList = "Element '{?value}' in the Entity's '{$this}' properties list must be a property - either directly or " + "via a reference to a property with an attribute samm:optional \"true\"^^xsd:boolean and/or samm:payloadName or " diff --git a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java index 141918b4..0adb0e3a 100644 --- a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java +++ b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java @@ -13,6 +13,8 @@ package org.eclipse.esmf.samm; +import org.apache.jena.rdf.model.Model; +import org.eclipse.esmf.samm.validation.ValidationReport; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -20,13 +22,13 @@ public class ConstraintShapeTest extends AbstractShapeTest { @ParameterizedTest - @MethodSource( value = "allVersions" ) + @MethodSource( value = "versionsUpToIncluding2_1_0" ) public void testConstraintValidationExpectSuccess( final KnownVersion metaModelVersion ) { checkValidity( "constraint-shape", "TestConstraint", metaModelVersion ); } @ParameterizedTest - @MethodSource( value = "allVersions" ) + @MethodSource( value = "versionsUpToIncluding2_1_0" ) public void testEmptyPropertiesExpectFailure2( final KnownVersion metaModelVersion ) { final SammUrns sammUrns = new SammUrns( metaModelVersion ); @@ -41,7 +43,24 @@ public void testEmptyPropertiesExpectFailure2( final KnownVersion metaModelVersi } @ParameterizedTest - @MethodSource( value = "allVersions" ) + @MethodSource( value = "versionsStartingWith2_2_0") + public void testConstraint ( final KnownVersion metaModelVersion) { + final SammUrns sammUrns = new SammUrns( metaModelVersion ); + + final String constraintName = "TestConstraintWithoutProperties"; + final String constraintId = testNamespacePrefix + constraintName; + final String value = testNamespacePrefix + constraintName; + + final SemanticError resultForEmptyConstraint = new SemanticError( messageHasToUseSubClass, + constraintId, "", violationUrn, value); + + expectSemanticValidationErrors( "constraint-shape", constraintName, metaModelVersion, resultForEmptyConstraint ); + + } + + + @ParameterizedTest + @MethodSource( value = "versionsUpToIncluding2_1_0" ) public void testLanguageStringNotUniqueExpectFailure( final KnownVersion metaModelVersion ) { final SammUrns sammUrns = new SammUrns( metaModelVersion ); @@ -56,7 +75,7 @@ public void testLanguageStringNotUniqueExpectFailure( final KnownVersion metaMod } @ParameterizedTest - @MethodSource( value = "allVersions" ) + @MethodSource( value = "versionsUpToIncluding2_1_0" ) public void testInvalidLanguageStringsExpectFailure( final KnownVersion metaModelVersion ) { final SammUrns sammUrns = new SammUrns( metaModelVersion ); @@ -71,7 +90,7 @@ public void testInvalidLanguageStringsExpectFailure( final KnownVersion metaMode } @ParameterizedTest - @MethodSource( value = "allVersions" ) + @MethodSource( value = "versionsUpToIncluding2_1_0" ) public void testConstraintDefinesDataTypeExpectFailure( final KnownVersion metaModelVersion ) { final SammUrns sammUrns = new SammUrns( metaModelVersion ); diff --git a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithoutProperties.ttl b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithoutProperties.ttl new file mode 100644 index 00000000..7577e128 --- /dev/null +++ b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithoutProperties.ttl @@ -0,0 +1,18 @@ +# +# Copyright (c) 2023 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 : . +@prefix samm: . +@prefix samm-c: . +@prefix xsd: . + +:TestConstraintWithoutProperties a samm:Constraint. From e59f57c2595862e62f3c353e3db2d309e399a1a8 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Mon, 8 Jan 2024 15:50:36 +0300 Subject: [PATCH 2/6] RBS-12926-Refactoring --- .../test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java index 0adb0e3a..02f90b20 100644 --- a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java +++ b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java @@ -13,8 +13,6 @@ package org.eclipse.esmf.samm; -import org.apache.jena.rdf.model.Model; -import org.eclipse.esmf.samm.validation.ValidationReport; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -55,10 +53,8 @@ public void testConstraint ( final KnownVersion metaModelVersion) { constraintId, "", violationUrn, value); expectSemanticValidationErrors( "constraint-shape", constraintName, metaModelVersion, resultForEmptyConstraint ); - } - @ParameterizedTest @MethodSource( value = "versionsUpToIncluding2_1_0" ) public void testLanguageStringNotUniqueExpectFailure( final KnownVersion metaModelVersion ) { From 262c11179bcd84ea17b07f9488f5ffb81f0d5df3 Mon Sep 17 00:00:00 2001 From: Yauhenikapl Date: Tue, 9 Jan 2024 08:40:30 +0300 Subject: [PATCH 3/6] Refactoring --- .../2.2.0/aspect-meta-model-shapes.ttl | 3 +- .../eclipse/esmf/samm/AbstractShapeTest.java | 6 +- .../esmf/samm/ConstraintShapeTest.java | 66 +------------- .../esmf/samm/ConstraintSubClassCoreTest.java | 90 +++++++++++++++++++ .../1.0.0/TestConstraintWithoutProperties.ttl | 2 +- .../1.0.0/TestConstraint.ttl | 6 +- .../TestConstraintNonUniqueLangStrings.ttl | 6 +- .../1.0.0/TestConstraintWithDataType.ttl | 6 +- .../TestConstraintWithEmptyProperties.ttl | 6 +- .../TestConstraintWithInvalidLangStrings.ttl | 6 +- 10 files changed, 114 insertions(+), 83 deletions(-) create mode 100644 esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintSubClassCoreTest.java rename esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/{constraint-shape => constraint-subclass-core}/org.eclipse.esmf.test/1.0.0/TestConstraint.ttl (79%) rename esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/{constraint-shape => constraint-subclass-core}/org.eclipse.esmf.test/1.0.0/TestConstraintNonUniqueLangStrings.ttl (79%) rename esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/{constraint-shape => constraint-subclass-core}/org.eclipse.esmf.test/1.0.0/TestConstraintWithDataType.ttl (78%) rename esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/{constraint-shape => constraint-subclass-core}/org.eclipse.esmf.test/1.0.0/TestConstraintWithEmptyProperties.ttl (78%) rename esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/{constraint-shape => constraint-subclass-core}/org.eclipse.esmf.test/1.0.0/TestConstraintWithInvalidLangStrings.ttl (77%) diff --git a/esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl b/esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl index 5a73d17e..bf9f7668 100644 --- a/esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl +++ b/esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl @@ -502,13 +502,12 @@ samm:ConstraintShape ] ; sh:sparql [ a sh:SPARQLConstraint ; - sh:message "Constraint '{$this}' must have a baseCharacteristic or a dataType." ; + sh:message "Constraint '{$this}' has invalid type samm:Constraint, only subtypes of samm:Constraint may be used." ; sh:prefixes samm:prefixDeclarations ; sh:select """ select $this ?message ?code where { $this rdf:type samm:Constraint . - bind( "It is necessary to use a SubClass and not its parent." as ?message ) bind( 'ERR_WRONG_DATATYPE' as ?code ) } """ diff --git a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java index 96662833..da0d1f25 100644 --- a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java +++ b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java @@ -67,10 +67,6 @@ protected static Stream versionsUpToIncluding1_0_0() { return versionsUpToIncluding( KnownVersion.SAMM_1_0_0 ); } - protected static Stream versionsUpToIncluding2_1_0() { - return versionsUpToIncluding( KnownVersion.SAMM_2_1_0 ); - } - final String violationUrn = "http://www.w3.org/ns/shacl#Violation"; final String warningUrn = "http://www.w3.org/ns/shacl#Warning"; @@ -83,7 +79,7 @@ protected static Stream versionsUpToIncluding2_1_0() { final String messageDuplicateProperty = "Property may only have 1 value, but found 2"; final String messageMissingDatatype = "No datatype is defined on the Characteristic instance '{$this}'."; - final String messageHasToUseSubClass = "It is necessary to use a SubClass and not its parent."; + final String messageHasToUseSubClass = "Constraint '{$this}' has invalid type samm:Constraint, only subtypes of samm:Constraint may be used."; final String messageInvalidEntryEntityPropertyList = "Element '{?value}' in the Entity's '{$this}' properties list must be a property - either directly or " + "via a reference to a property with an attribute samm:optional \"true\"^^xsd:boolean and/or samm:payloadName or " diff --git a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java index 02f90b20..a7685204 100644 --- a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java +++ b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintShapeTest.java @@ -19,31 +19,9 @@ import org.eclipse.esmf.samm.validation.SemanticError; public class ConstraintShapeTest extends AbstractShapeTest { - @ParameterizedTest - @MethodSource( value = "versionsUpToIncluding2_1_0" ) - public void testConstraintValidationExpectSuccess( final KnownVersion metaModelVersion ) { - checkValidity( "constraint-shape", "TestConstraint", metaModelVersion ); - } - - @ParameterizedTest - @MethodSource( value = "versionsUpToIncluding2_1_0" ) - public void testEmptyPropertiesExpectFailure2( final KnownVersion metaModelVersion ) { - final SammUrns sammUrns = new SammUrns( metaModelVersion ); - - final String constraintName = "TestConstraintWithEmptyProperties"; - final String constraintId = testNamespacePrefix + constraintName; - final SemanticError resultForPreferredName = new SemanticError( messageEmptyProperty, - constraintId, sammUrns.preferredNameUrn, violationUrn, "@en" ); - final SemanticError resultForDescription = new SemanticError( messageEmptyProperty, - constraintId, sammUrns.descriptionUrn, violationUrn, "@en" ); - expectSemanticValidationErrors( "constraint-shape", constraintName, - metaModelVersion, resultForPreferredName, resultForDescription ); - } - @ParameterizedTest @MethodSource( value = "versionsStartingWith2_2_0") - public void testConstraint ( final KnownVersion metaModelVersion) { - final SammUrns sammUrns = new SammUrns( metaModelVersion ); + public void testConstraintWithoutProperties ( final KnownVersion metaModelVersion) { final String constraintName = "TestConstraintWithoutProperties"; final String constraintId = testNamespacePrefix + constraintName; @@ -54,46 +32,4 @@ public void testConstraint ( final KnownVersion metaModelVersion) { expectSemanticValidationErrors( "constraint-shape", constraintName, metaModelVersion, resultForEmptyConstraint ); } - - @ParameterizedTest - @MethodSource( value = "versionsUpToIncluding2_1_0" ) - public void testLanguageStringNotUniqueExpectFailure( final KnownVersion metaModelVersion ) { - final SammUrns sammUrns = new SammUrns( metaModelVersion ); - - final String constraintName = "TestConstraintNonUniqueLangStrings"; - final String constraintId = testNamespacePrefix + constraintName; - final SemanticError resultForPreferredName = new SemanticError( messageLangNotUnique, - constraintId, sammUrns.preferredNameUrn, violationUrn, "" ); - final SemanticError resultForDescription = new SemanticError( messageLangNotUnique, - constraintId, sammUrns.descriptionUrn, violationUrn, "" ); - expectSemanticValidationErrors( "constraint-shape", constraintName, metaModelVersion, resultForPreferredName, - resultForDescription ); - } - - @ParameterizedTest - @MethodSource( value = "versionsUpToIncluding2_1_0" ) - public void testInvalidLanguageStringsExpectFailure( final KnownVersion metaModelVersion ) { - final SammUrns sammUrns = new SammUrns( metaModelVersion ); - - final String constraintName = "TestConstraintWithInvalidLangStrings"; - final String constraintId = testNamespacePrefix + constraintName; - final SemanticError resultForPreferredName = new SemanticError( - messageInvalidLangString, constraintId, sammUrns.preferredNameUrn, violationUrn, "Test Constraint" ); - final SemanticError resultForDescription = new SemanticError( - messageInvalidLangString, constraintId, sammUrns.descriptionUrn, violationUrn, "TestConstraint" ); - expectSemanticValidationErrors( "constraint-shape", constraintName, - metaModelVersion, resultForPreferredName, resultForDescription ); - } - - @ParameterizedTest - @MethodSource( value = "versionsUpToIncluding2_1_0" ) - public void testConstraintDefinesDataTypeExpectFailure( final KnownVersion metaModelVersion ) { - final SammUrns sammUrns = new SammUrns( metaModelVersion ); - - final String constraintName = "TestConstraintWithDataType"; - final String constraintId = testNamespacePrefix + constraintName; - final SemanticError resultForDataType = new SemanticError( messageMoreThanZeroValues, constraintId, - sammUrns.datatypeUrn, violationUrn, "" ); - expectSemanticValidationErrors( "constraint-shape", constraintName, metaModelVersion, resultForDataType ); - } } diff --git a/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintSubClassCoreTest.java b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintSubClassCoreTest.java new file mode 100644 index 00000000..95d01807 --- /dev/null +++ b/esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/ConstraintSubClassCoreTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2023 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 + */ + +package org.eclipse.esmf.samm; + +import org.eclipse.esmf.samm.validation.SemanticError; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +/** + * Moved tests from the 'constraint-shape' to 'constraint-subclass-core' directory for improved code organization. + * The 'constraint-subclass-core' directory now specifically accommodates tests related to the base functionality implemented in one of the subclasses (LengthConstraint) of the parent class (Constraint). + + * From version 2.2.0. + */ + +public class ConstraintSubClassCoreTest extends AbstractShapeTest { + @ParameterizedTest + @MethodSource( value = "versionsStartingWith2_2_0" ) + public void testConstraintValidationExpectSuccess( final KnownVersion metaModelVersion ) { + checkValidity( "constraint-subclass-core", "TestConstraint", metaModelVersion ); + } + + @ParameterizedTest + @MethodSource( value = "versionsStartingWith2_2_0" ) + public void testLanguageStringNotUniqueExpectFailure( final KnownVersion metaModelVersion ) { + final SammUrns sammUrns = new SammUrns( metaModelVersion ); + + final String constraintName = "TestConstraintNonUniqueLangStrings"; + final String constraintId = testNamespacePrefix + constraintName; + final SemanticError resultForPreferredName = new SemanticError( messageLangNotUnique, + constraintId, sammUrns.preferredNameUrn, violationUrn, "" ); + final SemanticError resultForDescription = new SemanticError( messageLangNotUnique, + constraintId, sammUrns.descriptionUrn, violationUrn, "" ); + expectSemanticValidationErrors( "constraint-subclass-core", constraintName, metaModelVersion, resultForPreferredName, + resultForDescription ); + } + + @ParameterizedTest + @MethodSource( value = "versionsStartingWith2_2_0" ) + public void testConstraintDefinesDataTypeExpectFailure( final KnownVersion metaModelVersion ) { + final SammUrns sammUrns = new SammUrns( metaModelVersion ); + + final String constraintName = "TestConstraintWithDataType"; + final String constraintId = testNamespacePrefix + constraintName; + final SemanticError resultForDataType = new SemanticError( messageMoreThanZeroValues, constraintId, + sammUrns.datatypeUrn, violationUrn, "" ); + expectSemanticValidationErrors( "constraint-subclass-core", constraintName, metaModelVersion, resultForDataType ); + } + + @ParameterizedTest + @MethodSource( value = "versionsStartingWith2_2_0" ) + public void testEmptyPropertiesExpectFailure2( final KnownVersion metaModelVersion ) { + final SammUrns sammUrns = new SammUrns( metaModelVersion ); + + final String constraintName = "TestConstraintWithEmptyProperties"; + final String constraintId = testNamespacePrefix + constraintName; + final SemanticError resultForPreferredName = new SemanticError( messageEmptyProperty, + constraintId, sammUrns.preferredNameUrn, violationUrn, "@en" ); + final SemanticError resultForDescription = new SemanticError( messageEmptyProperty, + constraintId, sammUrns.descriptionUrn, violationUrn, "@en" ); + expectSemanticValidationErrors( "constraint-subclass-core", constraintName, + metaModelVersion, resultForPreferredName, resultForDescription ); + } + + @ParameterizedTest + @MethodSource( value = "versionsStartingWith2_2_0" ) + public void testInvalidLanguageStringsExpectFailure( final KnownVersion metaModelVersion ) { + final SammUrns sammUrns = new SammUrns( metaModelVersion ); + + final String constraintName = "TestConstraintWithInvalidLangStrings"; + final String constraintId = testNamespacePrefix + constraintName; + final SemanticError resultForPreferredName = new SemanticError( + messageInvalidLangString, constraintId, sammUrns.preferredNameUrn, violationUrn, "Test Constraint" ); + final SemanticError resultForDescription = new SemanticError( + messageInvalidLangString, constraintId, sammUrns.descriptionUrn, violationUrn, "TestConstraint" ); + expectSemanticValidationErrors( "constraint-subclass-core", constraintName, + metaModelVersion, resultForPreferredName, resultForDescription ); + } +} diff --git a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithoutProperties.ttl b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithoutProperties.ttl index 7577e128..a26c7009 100644 --- a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithoutProperties.ttl +++ b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithoutProperties.ttl @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH +# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH # # See the AUTHORS file(s) distributed with this work for additional # information regarding authorship. diff --git a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraint.ttl b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraint.ttl similarity index 79% rename from esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraint.ttl rename to esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraint.ttl index f6273754..6349ea25 100644 --- a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraint.ttl +++ b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraint.ttl @@ -15,6 +15,8 @@ @prefix samm-c: . @prefix xsd: . -:TestConstraint a samm:Constraint ; +:TestConstraint a samm-c:LengthConstraint ; samm:preferredName "Test Constraint"@en ; - samm:description "TestConstraint"@en . + samm:description "TestConstraint"@en ; + samm-c:minValue "5"^^xsd:nonNegativeInteger ; + samm-c:maxValue "10"^^xsd:nonNegativeInteger . diff --git a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintNonUniqueLangStrings.ttl b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintNonUniqueLangStrings.ttl similarity index 79% rename from esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintNonUniqueLangStrings.ttl rename to esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintNonUniqueLangStrings.ttl index b9f71230..224a0979 100644 --- a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintNonUniqueLangStrings.ttl +++ b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintNonUniqueLangStrings.ttl @@ -15,8 +15,10 @@ @prefix samm-c: . @prefix xsd: . -:TestConstraintNonUniqueLangStrings a samm:Constraint ; +:TestConstraintNonUniqueLangStrings a samm-c:LengthConstraint ; samm:preferredName "Test Constraint"@en ; samm:preferredName "Test Einschränkung"@en ; samm:description "TestConstraint"@en ; - samm:description "Test Einschränkung"@en . + samm:description "Test Einschränkung"@en ; + samm-c:minValue "5"^^xsd:nonNegativeInteger ; + samm-c:maxValue "10"^^xsd:nonNegativeInteger . diff --git a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithDataType.ttl b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithDataType.ttl similarity index 78% rename from esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithDataType.ttl rename to esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithDataType.ttl index 4b964b75..9a66f63f 100644 --- a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithDataType.ttl +++ b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithDataType.ttl @@ -15,5 +15,7 @@ @prefix samm-c: . @prefix xsd: . -:TestConstraintWithDataType a samm:Constraint ; - samm:dataType xsd:float . +:TestConstraintWithDataType a samm-c:LengthConstraint ; + samm:dataType xsd:float ; + samm-c:minValue "5"^^xsd:nonNegativeInteger ; + samm-c:maxValue "10"^^xsd:nonNegativeInteger . diff --git a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithEmptyProperties.ttl b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithEmptyProperties.ttl similarity index 78% rename from esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithEmptyProperties.ttl rename to esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithEmptyProperties.ttl index f045e529..01e308df 100644 --- a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithEmptyProperties.ttl +++ b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithEmptyProperties.ttl @@ -15,6 +15,8 @@ @prefix samm-c: . @prefix xsd: . -:TestConstraintWithEmptyProperties a samm:Constraint ; +:TestConstraintWithEmptyProperties a samm-c:LengthConstraint ; samm:preferredName ""@en ; - samm:description ""@en . + samm:description ""@en ; + samm-c:minValue "5"^^xsd:nonNegativeInteger ; + samm-c:maxValue "10"^^xsd:nonNegativeInteger . diff --git a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithInvalidLangStrings.ttl b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithInvalidLangStrings.ttl similarity index 77% rename from esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithInvalidLangStrings.ttl rename to esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithInvalidLangStrings.ttl index 25a6420b..1e05075a 100644 --- a/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-shape/org.eclipse.esmf.test/1.0.0/TestConstraintWithInvalidLangStrings.ttl +++ b/esmf-semantic-aspect-meta-model/src/test/resources/samm_2_2_0/constraint-subclass-core/org.eclipse.esmf.test/1.0.0/TestConstraintWithInvalidLangStrings.ttl @@ -15,6 +15,8 @@ @prefix samm-c: . @prefix xsd: . -:TestConstraintWithInvalidLangStrings a samm:Constraint ; +:TestConstraintWithInvalidLangStrings a samm-c:LengthConstraint ; samm:preferredName "Test Constraint" ; - samm:description "TestConstraint" . + samm:description "TestConstraint" ; + samm-c:minValue "5"^^xsd:nonNegativeInteger ; + samm-c:maxValue "10"^^xsd:nonNegativeInteger . From 06be7b86936094609faa7b051db8a1a753049064 Mon Sep 17 00:00:00 2001 From: chris-volk <71717528+chris-volk@users.noreply.github.com> Date: Tue, 16 Jan 2024 07:43:55 +0100 Subject: [PATCH 4/6] Update bug_report.md (#261) Co-authored-by: Andreas Textor --- .github/ISSUE_TEMPLATE/bug_report.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index c1bca047..a73d56b1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,15 +7,14 @@ assignees: '' --- -**Describe the bug** -A clear and concise description of what the bug is. +**How: List of performed steps** -**Where** -Indicate the location of the bug (e.g., in which document, section and paragraph you found the bug). +**What: Actual result vs expected result** -**Screenshots** -If applicable, add screenshots to help explain your problem. +**Where: (e.g. component, version, url, your system info)** +**Input (files/screenshots)** -**Additional context** -Add any other context about the problem here. \ No newline at end of file +**Output (files/screenshots)** + +**Additional context (e.g. references)** From b8e735a26eabc1d1b39239501386c8dae42c91b0 Mon Sep 17 00:00:00 2001 From: Yauhenikapl <128151284+Yauhenikapl@users.noreply.github.com> Date: Tue, 16 Jan 2024 17:37:48 +0300 Subject: [PATCH 5/6] Model with contradicting Constraint (#276) * Model with contradicting Constraint Changes: - update documentation for length constraint. Fixes: #267 * Model with contradicting Constraint Changes: - Refactoring. Fixes: #267 --- documentation/modules/ROOT/pages/characteristics.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/documentation/modules/ROOT/pages/characteristics.adoc b/documentation/modules/ROOT/pages/characteristics.adoc index 53befd21..4e8f1a8f 100644 --- a/documentation/modules/ROOT/pages/characteristics.adoc +++ b/documentation/modules/ROOT/pages/characteristics.adoc @@ -592,6 +592,11 @@ At least one of `samm-c:maxValue` or `samm-c:minValue` must be present in a Leng | `samm-c:minValue` | The minimum length. Must be given as `xsd:nonNegativeInteger`. | {nok} |=== +IMPORTANT: When using the `samm-c:minValue` parameter in Length Constraint, it is crucial to consider the following: +* Creating a Model with a <>/<> based on a finite Base Characteristic (<> or <>) +and adding Length Constraint, the `samm-c:minValue` must not exceed the total number of elements in the Base Characteristic. +Models with such conditions are not recognized as invalid, but no valid payloads can exist for them. + [[regular-expression-constraint]] === Regular Expression Constraint [.element-urn] From 5c77e72b837becc9f4333a25d30665108110ba00 Mon Sep 17 00:00:00 2001 From: Andreas Textor Date: Fri, 19 Jan 2024 11:27:01 +0100 Subject: [PATCH 6/6] Add best practice for using metric units (#278) * Add best practice for using metric units * Incorporate PR suggestions --- .../modules/appendix/pages/best-practices.adoc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/documentation/modules/appendix/pages/best-practices.adoc b/documentation/modules/appendix/pages/best-practices.adoc index fe3bcba9..78331633 100644 --- a/documentation/modules/appendix/pages/best-practices.adoc +++ b/documentation/modules/appendix/pages/best-practices.adoc @@ -84,9 +84,16 @@ range, while a Property such as `numberOfProducedItems` is not logically limited [[choosing-a-unit]] == Choosing a Unit -When trying to refer to a physical unit, please see the -xref:appendix:unitcatalog.adoc[Unit Catalog]. When searching for the unit, -remember that the unit catalog uses British English. +When trying to refer to a physical unit, please see the xref:appendix:unitcatalog.adoc[Unit +Catalog]. When searching for the unit, remember that the unit catalog uses British English, e.g., +_metre_ instead of _meter_. + +TIP: If you're modeling quantities for which both the metric system and the imperial system provide +units, such as meter vs feet, it is always recommended to use the metric system (preferably SI units +like meter or others like kilometer if more common in the domain) – unless there are specific +reasons to create the model differently. In any case it is strongly discouraged to add multiple +Properties in the same scope representing the same value only using different units due to the +inherent complexity. [[choosing-a-characteristic]] == Choosing a Characteristic