62
62
import org .eclipse .esmf .aspectmodel .shacl .violation .UniqueLanguageViolation ;
63
63
import org .eclipse .esmf .aspectmodel .shacl .violation .ValueFromListViolation ;
64
64
import org .eclipse .esmf .aspectmodel .shacl .violation .Violation ;
65
+ import org .eclipse .esmf .aspectmodel .shacl .violation .XoneViolation ;
65
66
import org .eclipse .esmf .aspectmodel .validation .services .ViolationRustLikeFormatter ;
66
67
import org .junit .jupiter .api .Test ;
67
68
@@ -1875,16 +1876,19 @@ public void testXoneConstraint() {
1875
1876
1876
1877
assertThat ( violations .size () ).isEqualTo ( 1 );
1877
1878
final Violation finding = violations .get ( 0 );
1878
- assertThat ( finding ).isInstanceOf ( NodeKindViolation .class );
1879
- final NodeKindViolation violation = (NodeKindViolation ) finding ;
1879
+ assertThat ( finding ).isInstanceOf ( XoneViolation .class );
1880
+ final XoneViolation violation = (XoneViolation ) finding ;
1880
1881
assertThat ( violation .context ().element () ).isEqualTo ( element );
1881
1882
assertThat ( violation .context ().shape ().attributes ().uri () ).hasValue ( namespace + "MyShape" );
1882
1883
assertThat ( violation .propertyName () ).isEqualTo ( ":testProperty" );
1883
1884
assertThat ( violation .elementName () ).isEqualTo ( ":Foo" );
1884
- assertThat ( violation .allowedNodeKind () ).isEqualTo ( Shape .NodeKind .Literal );
1885
- assertThat ( violation .actualNodeKind () ).isEqualTo ( Shape .NodeKind .BlankNode );
1886
- assertThat ( violation .message () ).isEqualTo ( "Property :testProperty on :Foo is an anonymous node, but it must be a value." );
1887
- assertThat ( violation .errorCode () ).isEqualTo ( NodeKindViolation .ERROR_CODE );
1885
+ assertThat ( violation .violations () ).hasSize ( 1 );
1886
+ assertThat ( violation .violations ().get ( 0 ) ).isInstanceOf ( NodeKindViolation .class );
1887
+ final NodeKindViolation nestedViolation = (NodeKindViolation ) violation .violations ().get ( 0 );
1888
+ assertThat ( nestedViolation .allowedNodeKind () ).isEqualTo ( Shape .NodeKind .Literal );
1889
+ assertThat ( nestedViolation .actualNodeKind () ).isEqualTo ( Shape .NodeKind .BlankNode );
1890
+ assertThat ( nestedViolation .message () ).isEqualTo ( "Property :testProperty on :Foo is an anonymous node, but it must be a value." );
1891
+ assertThat ( nestedViolation .errorCode () ).isEqualTo ( NodeKindViolation .ERROR_CODE );
1888
1892
1889
1893
final String formattedMessage = rustLikeFormatter .visit ( finding );
1890
1894
assertTrue ( formattedMessageIsCorrect ( formattedMessage , 3 , ":testProperty [" , ":testProperty" .length () ) );
@@ -1919,18 +1923,14 @@ void testSparqlTargetWithGenericConstraint() {
1919
1923
sh:description "Test shape description" ;
1920
1924
sh:property [
1921
1925
sh:path :testProperty ;
1922
- sh:xone (
1923
- [ sh:nodeKind sh:Literal ]
1924
- ) ;
1926
+ sh:maxLength 2 ;
1925
1927
] .
1926
1928
""" );
1927
1929
1928
1930
final Model dataModel = model ( """
1929
1931
@prefix : <http://example.com#> .
1930
1932
:Foo a :TestClass ;
1931
- :testProperty [
1932
- :testProperty2 42 ;
1933
- ] .
1933
+ :testProperty "abc" .
1934
1934
""" );
1935
1935
1936
1936
final ShaclValidator validator = new ShaclValidator ( shapesModel );
@@ -1939,7 +1939,7 @@ void testSparqlTargetWithGenericConstraint() {
1939
1939
1940
1940
assertThat ( violations .size () ).isEqualTo ( 1 );
1941
1941
final Violation finding = violations .get ( 0 );
1942
- assertThat ( finding ).isInstanceOf ( NodeKindViolation .class );
1942
+ assertThat ( finding ).isInstanceOf ( MaxLengthViolation .class );
1943
1943
}
1944
1944
1945
1945
@ Test
0 commit comments