Skip to content

Commit 9c363bc

Browse files
committed
Fix bug with rendering of the "bamm:see" attributes on elements on which they were not declared.
1 parent 3a2380a commit 9c363bc

File tree

6 files changed

+110
-5
lines changed

6 files changed

+110
-5
lines changed

core/sds-aspect-model-document-generators/src/main/resources/diagram/bamm_1_0_0/enumeration2boxmodel.sparql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ construct {
107107

108108
optional {
109109
{
110-
select ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
110+
select ?characteristic ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
111111
where {
112112
?characteristic rdf:type/rdfs:subClassOf* bamm:Characteristic .
113113
filter( exists {

core/sds-aspect-model-document-generators/src/main/resources/diagram/bamm_2_0_0/enumeration2boxmodel.sparql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ construct {
109109

110110
optional {
111111
{
112-
select ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
112+
select ?characteristic ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
113113
where {
114114
?characteristic rdf:type/rdfs:subClassOf* bamm:Characteristic .
115115
filter( exists {

core/sds-aspect-model-document-generators/src/test/java/io/openmanufacturing/sds/aspectmodel/generator/diagram/Enumeration2BoxModelTest.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
import org.junit.jupiter.params.ParameterizedTest;
2525
import org.junit.jupiter.params.provider.MethodSource;
2626

27+
import io.openmanufacturing.sds.aspectmetamodel.KnownVersion;
2728
import io.openmanufacturing.sds.test.MetaModelVersions;
2829
import io.openmanufacturing.sds.test.TestAspect;
2930

30-
import io.openmanufacturing.sds.aspectmetamodel.KnownVersion;
31-
3231
public class Enumeration2BoxModelTest extends MetaModelVersions {
3332
private final String sparqlQueryFileName = "enumeration2boxmodel.sparql";
3433
private final int totalNumberOfExpectedEntries = 6;
@@ -52,7 +51,7 @@ public void testOnlyUsedEnumerationsAreProcessedExpectSuccess( final KnownVersio
5251
queryResult.listStatements( context.selector( ":UsedTestEnumerationCharacteristic a :Box" ) ).toList() )
5352
.hasSize( 1 );
5453
assertThat( queryResult.listStatements( context.selector( ":UnusedTestEnumerationCharacteristic a :Box" ) )
55-
.toList() )
54+
.toList() )
5655
.hasSize( 0 );
5756
assertThat( queryResult.listStatements( context.selector( "* :text *" ) ).toList() ).hasSize( 5 );
5857
}
@@ -94,11 +93,32 @@ public void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaMo
9493
totalNumberOfExpectedEntries, indexOfSeeValueEntry );
9594
}
9695

96+
@ParameterizedTest
97+
@MethodSource( value = "allVersions" )
98+
void testOnlyRightSeeAttributeIsSelected( final KnownVersion metaModelVersion ) {
99+
// See attribute was rendered also on elements on which it was not declared:
100+
// https://github.com/OpenManufacturingPlatform/sds-sdk/issues/196
101+
String characteristicIdentifier = "Enum1";
102+
String boxSelectorStatement = getBoxSelectorStatement( characteristicIdentifier );
103+
String entriesSelectorStatement = getEntriesSelectorStatement( characteristicIdentifier );
104+
final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENUM_ONLY_ONE_SEE, metaModelVersion );
105+
context.executeAttributeIsNotPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement,
106+
totalNumberOfExpectedEntries, indexOfSeeValueEntry );
107+
108+
characteristicIdentifier = "Enum2";
109+
boxSelectorStatement = getBoxSelectorStatement( characteristicIdentifier );
110+
entriesSelectorStatement = getEntriesSelectorStatement( characteristicIdentifier );
111+
112+
context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement,
113+
totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, "https://test.com" );
114+
}
115+
97116
private String getBoxSelectorStatement( final String characteristicIdentifier ) {
98117
return String.format( ":%sCharacteristic a :Box", characteristicIdentifier );
99118
}
100119

101120
private String getEntriesSelectorStatement( final String characteristicIdentifier ) {
102121
return String.format( ":%sCharacteristic :entries *", characteristicIdentifier );
103122
}
123+
104124
}

core/sds-test-aspect-models/src/main/java/io/openmanufacturing/sds/test/TestAspect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public enum TestAspect implements TestModel {
181181
ENTITY_INSTANCE_TEST2,
182182
ENTITY_INSTANCE_TEST3,
183183
ENTITY_INSTANCE_TEST4,
184+
ASPECT_WITH_ENUM_ONLY_ONE_SEE,
184185
MOVEMENT;
185186

186187
@Override
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2022 Robert Bosch Manufacturing Solutions GmbH
2+
#
3+
# See the AUTHORS file(s) distributed with this work for additional
4+
# information regarding authorship.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
9+
#
10+
# SPDX-License-Identifier: MPL-2.0
11+
12+
@prefix bamm: <urn:bamm:io.openmanufacturing:meta-model:1.0.0#>.
13+
@prefix bamm-c: <urn:bamm:io.openmanufacturing:characteristic:1.0.0#>.
14+
@prefix bamm-e: <urn:bamm:io.openmanufacturing:entity:1.0.0#>.
15+
@prefix unit: <urn:bamm:io.openmanufacturing:unit:1.0.0#>.
16+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
17+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
18+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
19+
@prefix : <urn:bamm:io.openmanufacturing.test:1.0.0#>.
20+
21+
:AspectWithEnumOnlyOneSee a bamm:Aspect;
22+
bamm:name "Test";
23+
bamm:properties (:prop1 :prop2);
24+
bamm:operations ();
25+
bamm:events ().
26+
27+
:prop1 a bamm:Property;
28+
bamm:name "prop1";
29+
bamm:characteristic :Enum1.
30+
:prop2 a bamm:Property;
31+
bamm:name "prop2";
32+
bamm:characteristic :Enum2.
33+
34+
:Enum1 a bamm-c:Enumeration;
35+
bamm:name "Enum1";
36+
bamm:dataType xsd:string;
37+
bamm-c:values ("a" "b").
38+
:Enum2 a bamm-c:Enumeration;
39+
bamm:name "Enum2";
40+
bamm:dataType xsd:string;
41+
bamm-c:values ("1" "2");
42+
bamm:see <https://test.com>.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2022 Robert Bosch Manufacturing Solutions GmbH
2+
#
3+
# See the AUTHORS file(s) distributed with this work for additional
4+
# information regarding authorship.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
9+
#
10+
# SPDX-License-Identifier: MPL-2.0
11+
12+
@prefix bamm: <urn:bamm:io.openmanufacturing:meta-model:2.0.0#>.
13+
@prefix bamm-c: <urn:bamm:io.openmanufacturing:characteristic:2.0.0#>.
14+
@prefix bamm-e: <urn:bamm:io.openmanufacturing:entity:2.0.0#>.
15+
@prefix unit: <urn:bamm:io.openmanufacturing:unit:2.0.0#>.
16+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
17+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
18+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
19+
@prefix : <urn:bamm:io.openmanufacturing.test:1.0.0#>.
20+
21+
:AspectWithEnumOnlyOneSee a bamm:Aspect;
22+
bamm:name "Test";
23+
bamm:properties (:prop1 :prop2);
24+
bamm:operations ();
25+
bamm:events ().
26+
27+
:prop1 a bamm:Property;
28+
bamm:name "prop1";
29+
bamm:characteristic :Enum1.
30+
:prop2 a bamm:Property;
31+
bamm:name "prop2";
32+
bamm:characteristic :Enum2.
33+
34+
:Enum1 a bamm-c:Enumeration;
35+
bamm:name "Enum1";
36+
bamm:dataType xsd:string;
37+
bamm-c:values ("a" "b").
38+
:Enum2 a bamm-c:Enumeration;
39+
bamm:name "Enum2";
40+
bamm:dataType xsd:string;
41+
bamm-c:values ("1" "2");
42+
bamm:see <https://test.com>.

0 commit comments

Comments
 (0)