Skip to content

Commit 4244d60

Browse files
committed
fixed unit tests for diagram generator
1 parent 8cb4214 commit 4244d60

18 files changed

+170
-163
lines changed

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql

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

6060
bind( iri( concat( func:getNamespace( ?instance ), ?instanceBoxName ) ) as ?from )
6161
bind( concat( ?nestedInstanceName, "EntityInstance" ) as ?nestedInstanceBoxName )
62-
bind( iri( concat( func:getNamespace( if(!isBlank( ?propertyValue ), ?propertyValue, ?listValue )), ?nestedInstanceBoxName ) ) as ?to )
62+
bind( iri( concat( func:getNamespace( if( !isBlank( ?propertyValue ), ?propertyValue, ?listValue )), ?nestedInstanceBoxName ) ) as ?to )
6363
bind( iri( concat( func:getNamespace( ?instance ), ?instanceBoxName, "_To_", ?nestedInstanceBoxName ) ) as ?edge )
6464
bind( concat( ?propertyName, " value" ) as ?title )
6565
}

core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractConstraint2BoxModelTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,20 @@ public abstract class AbstractConstraint2BoxModelTest extends MetaModelVersions
2727

2828
final String sparqlQueryFileName = "constraint2boxmodel.sparql";
2929

30-
protected String boxSelectorStatement( final KnownVersion metaModelVersion, final String constraintIdentifier ) {
30+
protected String boxSelectorStatement( final KnownVersion metaModelVersion, final String constraintIdentifier, boolean isConstraintAnonymous ) {
31+
String ns = isConstraintAnonymous ? ":" : "test:";
3132
if ( metaModelVersion.isNewerThan( KnownVersion.SAMM_1_0_0 ) ) {
32-
return String.format( "%s a :Box", constraintIdentifier.equals( "*" ) ? "*" : ":" + constraintIdentifier );
33+
return String.format( "%s a :Box", constraintIdentifier.equals( "*" ) ? "*" : ns + constraintIdentifier );
3334
}
34-
return ":TestConstraintConstraint a :Box";
35+
return ns + "TestConstraintConstraint a :Box";
3536
}
3637

37-
protected String entriesSelectorStatement( final KnownVersion metaModelVersion, final String constraintIdentifier ) {
38+
protected String entriesSelectorStatement( final KnownVersion metaModelVersion, final String constraintIdentifier, boolean isConstraintAnonymous ) {
39+
String ns = isConstraintAnonymous ? ":" : "test:";
3840
if ( metaModelVersion.isNewerThan( KnownVersion.SAMM_1_0_0 ) ) {
39-
return String.format( "%s :entries *", constraintIdentifier.equals( "*" ) ? "*" : ":" + constraintIdentifier );
41+
return String.format( "%s :entries *", constraintIdentifier.equals( "*" ) ? "*" : ns + constraintIdentifier );
4042
}
41-
return ":TestConstraintConstraint :entries *";
43+
return ns + "TestConstraintConstraint :entries *";
4244
}
4345

4446
@BeforeAll

core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractEntity2BoxModelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void testAbstractEntity( final TestAspect testAspect, final KnownVersion
4949

5050
final Model queryResult = context.executeQuery( sparqlQueryFileName );
5151

52-
assertThat( queryResult.listStatements( context.selector( ":AbstractTestEntityAbstractEntity a :Box" ) ).toList() ).hasSize( 1 );
53-
assertThat( queryResult.listStatements( context.selector( ":AbstractTestEntityAbstractEntity :title AbstractTestEntity" ) ).toList() ).hasSize( 1 );
52+
assertThat( queryResult.listStatements( context.selector( "test:AbstractTestEntityAbstractEntity a :Box" ) ).toList() ).hasSize( 1 );
53+
assertThat( queryResult.listStatements( context.selector( "test:AbstractTestEntityAbstractEntity :title AbstractTestEntity" ) ).toList() ).hasSize( 1 );
5454
}
5555
}

core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Aspect2BoxModelTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public class Aspect2BoxModelTest extends MetaModelVersions {
3333
@MethodSource( value = "allVersions" )
3434
public void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) {
3535
final TestContext context = new TestContext( TestAspect.ASPECT_WITH_SEE_ATTRIBUTE, metaModelVersion );
36-
final String boxSelectorStatement = ":AspectWithSeeAttributeAspect a :Box";
37-
final String entriesSelectorStatement = ":AspectWithSeeAttributeAspect :entries *";
36+
final String boxSelectorStatement = "test:AspectWithSeeAttributeAspect a :Box";
37+
final String entriesSelectorStatement = "test:AspectWithSeeAttributeAspect :entries *";
3838
context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement,
3939
totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" );
4040
}
@@ -43,8 +43,8 @@ public void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModel
4343
@MethodSource( value = "allVersions" )
4444
public void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) {
4545
final TestContext context = new TestContext( TestAspect.ASPECT_WITH_MULTIPLE_SEE_ATTRIBUTES, metaModelVersion );
46-
final String boxSelectorStatement = ":AspectWithMultipleSeeAttributesAspect a :Box";
47-
final String entriesSelectorStatement = ":AspectWithMultipleSeeAttributesAspect :entries *";
46+
final String boxSelectorStatement = "test:AspectWithMultipleSeeAttributesAspect a :Box";
47+
final String entriesSelectorStatement = "test:AspectWithMultipleSeeAttributesAspect :entries *";
4848
context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement,
4949
totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle,
5050
"http://example.com/, http://example.com/me" );
@@ -54,8 +54,8 @@ public void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaMod
5454
@MethodSource( value = "allVersions" )
5555
public void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) {
5656
final TestContext context = new TestContext( TestAspect.ASPECT_WITHOUT_SEE_ATTRIBUTE, metaModelVersion );
57-
final String boxSelectorStatement = ":AspectWithoutSeeAttributeAspect a :Box";
58-
final String entriesSelectorStatement = ":AspectWithoutSeeAttributeAspect :entries *";
57+
final String boxSelectorStatement = "test:AspectWithoutSeeAttributeAspect a :Box";
58+
final String entriesSelectorStatement = "test:AspectWithoutSeeAttributeAspect :entries *";
5959
context.executeAttributeIsNotPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement,
6060
totalNumberOfExpectedEntries, indexOfSeeValueEntry );
6161
}
@@ -67,8 +67,8 @@ public void testAspectWithProperty( final KnownVersion metaModelVersion ) {
6767

6868
final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" );
6969

70-
assertThat( queryResult.listStatements( context.selector( ":AspectWithPropertyAspect_To_testPropertyProperty a :Edge" ) ).toList() ).hasSize( 1 );
71-
assertThat( queryResult.listStatements( context.selector( ":AspectWithPropertyAspect_To_testPropertyProperty :title property" ) ).toList() ).hasSize( 1 );
70+
assertThat( queryResult.listStatements( context.selector( "test:AspectWithPropertyAspect_To_testPropertyProperty a :Edge" ) ).toList() ).hasSize( 1 );
71+
assertThat( queryResult.listStatements( context.selector( "test:AspectWithPropertyAspect_To_testPropertyProperty :title property" ) ).toList() ).hasSize( 1 );
7272
}
7373

7474
@ParameterizedTest
@@ -78,9 +78,9 @@ public void testAspectWithOptionalProperty( final KnownVersion metaModelVersion
7878

7979
final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" );
8080

81-
assertThat( queryResult.listStatements( context.selector( ":AspectWithOptionalPropertyAspect_To_testPropertyProperty a :Edge" ) )
81+
assertThat( queryResult.listStatements( context.selector( "test:AspectWithOptionalPropertyAspect_To_testPropertyProperty a :Edge" ) )
8282
.toList() ).hasSize( 1 );
83-
assertThat( queryResult.listStatements( context.selector( ":AspectWithOptionalPropertyAspect_To_testPropertyProperty :title property (optional)" ) )
83+
assertThat( queryResult.listStatements( context.selector( "test:AspectWithOptionalPropertyAspect_To_testPropertyProperty :title property (optional)" ) )
8484
.toList() ).hasSize( 1 );
8585
}
8686

@@ -91,9 +91,9 @@ public void testAspectWithPropertyWithPayloadName( final KnownVersion metaModelV
9191

9292
final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" );
9393

94-
assertThat( queryResult.listStatements( context.selector( ":AspectWithPropertyWithPayloadNameAspect_To_testPropertyProperty a :Edge" ) )
94+
assertThat( queryResult.listStatements( context.selector( "test:AspectWithPropertyWithPayloadNameAspect_To_testPropertyProperty a :Edge" ) )
9595
.toList() ).hasSize( 1 );
96-
assertThat( queryResult.listStatements( context.selector( ":AspectWithPropertyWithPayloadNameAspect_To_testPropertyProperty :title property (test)" ) )
96+
assertThat( queryResult.listStatements( context.selector( "test:AspectWithPropertyWithPayloadNameAspect_To_testPropertyProperty :title property (test)" ) )
9797
.toList() ).hasSize( 1 );
9898
}
9999

@@ -104,11 +104,11 @@ public void testAspectWithOptionalPropertyWithPayloadName( final KnownVersion me
104104

105105
final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" );
106106

107-
assertThat( queryResult.listStatements( context.selector( ":AspectWithOptionalPropertyWithPayloadNameAspect_To_testPropertyProperty a :Edge" ) )
107+
assertThat( queryResult.listStatements( context.selector( "test:AspectWithOptionalPropertyWithPayloadNameAspect_To_testPropertyProperty a :Edge" ) )
108108
.toList() ).hasSize( 1 );
109109
assertThat(
110110
queryResult.listStatements(
111-
context.selector( ":AspectWithOptionalPropertyWithPayloadNameAspect_To_testPropertyProperty :title property (optional) (test)" ) )
111+
context.selector( "test:AspectWithOptionalPropertyWithPayloadNameAspect_To_testPropertyProperty :title property (optional) (test)" ) )
112112
.toList() ).hasSize( 1 );
113113
}
114114
}

core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Characteristic2BoxModelTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
public class Characteristic2BoxModelTest extends MetaModelVersions {
2727
private final String sparqlQueryFileName = "characteristic2boxmodel.sparql";
28-
private final String boxSelectorStatement = ":TestCharacteristicCharacteristic a :Box";
29-
private final String entriesSelectorStatement = ":TestCharacteristicCharacteristic :entries *";
28+
private final String boxSelectorStatement = "test:TestCharacteristicCharacteristic a :Box";
29+
private final String entriesSelectorStatement = "test:TestCharacteristicCharacteristic :entries *";
3030
private final int totalNumberOfExpectedEntries = 4;
3131
private final int indexOfSeeValueEntry = 3;
3232
private final String expectedSeeEntryTitle = "see";
@@ -38,8 +38,8 @@ public void testOnlyUsedCharacteristicsAreProcessedExpectSuccess( final KnownVer
3838

3939
final Model queryResult = context.executeQuery( sparqlQueryFileName );
4040

41-
assertThat( queryResult.listStatements( context.selector( ":UsedTestCharacteristicCharacteristic a :Box" ) ).toList() ).hasSize( 1 );
42-
assertThat( queryResult.listStatements( context.selector( ":UnusedTestCharacteristicCharacteristic a :Box" ) ).toList() ).hasSize( 0 );
41+
assertThat( queryResult.listStatements( context.selector( "test:UsedTestCharacteristicCharacteristic a :Box" ) ).toList() ).hasSize( 1 );
42+
assertThat( queryResult.listStatements( context.selector( "test:UnusedTestCharacteristicCharacteristic a :Box" ) ).toList() ).hasSize( 0 );
4343
assertThat( queryResult.listStatements( context.selector( "* :text *" ) ).toList() ).hasSize( totalNumberOfExpectedEntries );
4444
}
4545

@@ -78,13 +78,13 @@ public void testAspectWithAbstractEntityExpectSuccess( final KnownVersion metaMo
7878
final Model queryResult = context.executeQuery( "characteristic-entity-edges2boxmodel.sparql" );
7979

8080
assertThat( queryResult
81-
.listStatements( context.selector( ":EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity a :Edge" ) )
81+
.listStatements( context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity a :Edge" ) )
8282
.toList() ).hasSize( 1 );
8383
assertThat( queryResult
84-
.listStatements( context.selector( ":EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :from :EntityCharacteristicCharacteristic" ) )
84+
.listStatements( context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :from test:EntityCharacteristicCharacteristic" ) )
8585
.toList() ).hasSize( 1 );
8686
assertThat( queryResult
87-
.listStatements( context.selector( ":EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :to :ExtendingTestEntityEntity" ) )
87+
.listStatements( context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :to test:ExtendingTestEntityEntity" ) )
8888
.toList() ).hasSize( 1 );
8989
}
9090

@@ -95,13 +95,13 @@ public void testAspectWithAbstractSingleEntityExpectSuccess( final KnownVersion
9595

9696
final Model queryResult = context.executeQuery( "characteristic-entity-edges2boxmodel.sparql" );
9797

98-
assertThat( queryResult.listStatements( context.selector( ":EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity a :Edge" ) )
98+
assertThat( queryResult.listStatements( context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity a :Edge" ) )
9999
.toList() ).hasSize( 1 );
100100
assertThat( queryResult.listStatements(
101-
context.selector( ":EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :from :EntityCharacteristicCharacteristic" ) )
101+
context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :from test:EntityCharacteristicCharacteristic" ) )
102102
.toList() ).hasSize( 1 );
103103
assertThat( queryResult.listStatements(
104-
context.selector( ":EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :to :ExtendingTestEntityEntity" ) )
104+
context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :to test:ExtendingTestEntityEntity" ) )
105105
.toList() ).hasSize( 1 );
106106
}
107107
}

core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Collection2BoxModelTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
public class Collection2BoxModelTest extends MetaModelVersions {
2727
private final String sparqlQueryFileName = "collection2boxmodel.sparql";
28-
private final String boxSelectorStatement = ":TestCollectionCharacteristic a :Box";
29-
private final String entriesSelectorStatement = ":TestCollectionCharacteristic :entries *";
28+
private final String boxSelectorStatement = "test:TestCollectionCharacteristic a :Box";
29+
private final String entriesSelectorStatement = "test:TestCollectionCharacteristic :entries *";
3030
private final int totalNumberOfExpectedEntries = 6;
3131
private final int indexOfSeeValueEntry = 5;
3232
private final String expectedSeeEntryTitle = "see";
@@ -38,8 +38,8 @@ public void testOnlyUsedCollectionsAreProcessedExpectSuccess( final KnownVersion
3838

3939
final Model queryResult = context.executeQuery( sparqlQueryFileName );
4040

41-
assertThat( queryResult.listStatements( context.selector( ":UsedTestCollectionCharacteristic a :Box" ) ).toList() ).hasSize( 1 );
42-
assertThat( queryResult.listStatements( context.selector( ":UnusedTestCollectionCharacteristic a :Box" ) ).toList() ).hasSize( 0 );
41+
assertThat( queryResult.listStatements( context.selector( "test:UsedTestCollectionCharacteristic a :Box" ) ).toList() ).hasSize( 1 );
42+
assertThat( queryResult.listStatements( context.selector( "test:UnusedTestCollectionCharacteristic a :Box" ) ).toList() ).hasSize( 0 );
4343
assertThat( queryResult.listStatements( context.selector( "* :text *" ) ).toList() ).hasSize( totalNumberOfExpectedEntries );
4444
}
4545

@@ -77,13 +77,13 @@ public void testCollectionWithElementCharacteristicExpectSuccess( final KnownVer
7777

7878
final Model queryResult = context.executeQuery( "collection-elementcharacteristic-edges2boxmodel.sparql" );
7979

80-
assertThat( queryResult.listStatements( context.selector( ":TestCollectionTwoCharacteristic_To_TextCharacteristic a :Edge" ) ).toList() ).hasSize( 1 );
81-
assertThat( queryResult.listStatements( context.selector( ":TestCollectionTwoCharacteristic_To_TextCharacteristic :to :TextCharacteristic" ) )
80+
assertThat( queryResult.listStatements( context.selector( "test:TestCollectionTwoCharacteristic_To_TextCharacteristic a :Edge" ) ).toList() ).hasSize( 1 );
81+
assertThat( queryResult.listStatements( context.selector( "test:TestCollectionTwoCharacteristic_To_TextCharacteristic :to samm-c:TextCharacteristic" ) )
8282
.toList() ).hasSize( 1 );
8383
assertThat(
84-
queryResult.listStatements( context.selector( ":TestCollectionTwoCharacteristic_To_TextCharacteristic :from :TestCollectionTwoCharacteristic" ) )
84+
queryResult.listStatements( context.selector( "test:TestCollectionTwoCharacteristic_To_TextCharacteristic :from test:TestCollectionTwoCharacteristic" ) )
8585
.toList() ).hasSize( 1 );
86-
assertThat( queryResult.listStatements( context.selector( ":TestCollectionTwoCharacteristic_To_TextCharacteristic :title element Characteristic" ) )
86+
assertThat( queryResult.listStatements( context.selector( "test:TestCollectionTwoCharacteristic_To_TextCharacteristic :title element Characteristic" ) )
8787
.toList() ).hasSize( 1 );
8888
}
8989

@@ -95,15 +95,15 @@ public void testCollectionWithAbstractEntityExpectSuccess( final KnownVersion me
9595
final Model queryResult = context.executeQuery( "characteristic-entity-edges2boxmodel.sparql" );
9696

9797
assertThat( queryResult
98-
.listStatements( context.selector( ":EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity a :Edge" ) )
98+
.listStatements( context.selector( "test:EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity a :Edge" ) )
9999
.toList() ).hasSize( 1 );
100100
assertThat( queryResult
101101
.listStatements( context.selector(
102-
":EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity :from :EntityCollectionCharacteristicCharacteristic" ) )
102+
"test:EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity :from test:EntityCollectionCharacteristicCharacteristic" ) )
103103
.toList() ).hasSize( 1 );
104104
assertThat( queryResult
105105
.listStatements( context.selector(
106-
":EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity :to :AbstractTestEntityAbstractEntity" ) )
106+
"test:EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity :to test:AbstractTestEntityAbstractEntity" ) )
107107
.toList() ).hasSize( 1 );
108108
}
109109
}

0 commit comments

Comments
 (0)