@@ -283,11 +283,11 @@ public void testRegexValidationOnMovieDB() throws Exception {
283283
284284 while (validationResults .hasNext ()) {
285285 Record next = validationResults .next ();
286- if (next .get ("nodeType" ).equals ("Person" )) {
286+ if (next .get ("nodeType" ).asString (). equals ("Person" )) {
287287 assertEquals ("Rosie O'Donnell" , next .get ("offendingValue" ).asString ());
288288 assertEquals ("http://www.w3.org/ns/shacl#PatternConstraintComponent" ,
289289 next .get ("propertyShape" ).asString ());
290- } else if (next .get ("nodeType" ).equals ("Movie" )) {
290+ } else if (next .get ("nodeType" ).asString (). equals ("Movie" )) {
291291 assertEquals (1993 , next .get ("offendingValue" ).asInt ());
292292 assertEquals ("http://www.w3.org/ns/shacl#MinExclusiveConstraintComponent" ,
293293 next .get ("propertyShape" ).asString ());
@@ -297,8 +297,74 @@ public void testRegexValidationOnMovieDB() throws Exception {
297297 }
298298 }
299299
300-
301300 @ Test
301+ public void testBug213 () throws Exception {
302+ try (Driver driver = GraphDatabase .driver (neo4j .boltURI (),
303+ Config .builder ().withoutEncryption ().build ())) {
304+
305+ Session session = driver .session ();
306+
307+ assertFalse (session .run ("MATCH (n) RETURN n" ).hasNext ());
308+
309+ session .run ("CREATE(s:Object) SET s.minVal = \" 200\" ;" );
310+
311+ session .run ("call n10s.validation.shacl.import.inline('\n " +
312+ "\n " +
313+ "@prefix dtc: <http://ttt/#> .\n " +
314+ "@prefix vs: <http:/ttt/vs#>.\n " +
315+ "@prefix sh: <http://www.w3.org/ns/shacl#> .\n " +
316+ "\n " +
317+ "dtc:ObjectShape\n " +
318+ " a sh:NodeShape;\n " +
319+ " sh:targetClass vs:Object; \n " +
320+ " sh:property [ \n " +
321+ " sh:path vs:minVal;\n " +
322+ " sh:datatype xsd:integer ;\n " +
323+ " sh:minInclusive 0;\n " +
324+ " sh:maxInclusive 100;\n " +
325+ " ] ;\n " +
326+ ".\n " +
327+ "\n " +
328+ "','Turtle')" );
329+
330+ Result validationResults = session .run ("CALL n10s.validation.shacl.validate() " );
331+
332+ assertEquals (true , validationResults .hasNext ());
333+
334+ Record next = validationResults .next ();
335+ assertTrue (next .get ("nodeType" ).asString ().equals ("Object" ));
336+ assertTrue (next .get ("resultPath" ).asString ().equals ("minVal" ));
337+ assertEquals ("200" , next .get ("offendingValue" ).asString ());
338+ assertEquals ("http://www.w3.org/ns/shacl#DatatypeConstraintComponent" ,
339+ next .get ("propertyShape" ).asString ());
340+ assertEquals ("property value should be of type integer" ,
341+ next .get ("resultMessage" ).asString ());
342+
343+ assertEquals (false , validationResults .hasNext ());
344+
345+ session .run ("MATCH(s:Object) SET s.minVal = \" hello-world\" ;" );
346+
347+ validationResults = session .run ("CALL n10s.validation.shacl.validate() " );
348+
349+ assertEquals (true , validationResults .hasNext ());
350+
351+ next = validationResults .next ();
352+ assertTrue (next .get ("nodeType" ).asString ().equals ("Object" ));
353+ assertTrue (next .get ("resultPath" ).asString ().equals ("minVal" ));
354+ assertEquals ("hello-world" , next .get ("offendingValue" ).asString ());
355+ assertEquals ("http://www.w3.org/ns/shacl#DatatypeConstraintComponent" ,
356+ next .get ("propertyShape" ).asString ());
357+ assertEquals ("property value should be of type integer" ,
358+ next .get ("resultMessage" ).asString ());
359+
360+ assertEquals (false , validationResults .hasNext ());
361+
362+ }
363+
364+
365+ }
366+
367+ @ Test
302368 public void testValidationBeforeNsDefined () throws Exception {
303369 try (Driver driver = GraphDatabase .driver (neo4j .boltURI (),
304370 Config .builder ().withoutEncryption ().build ())) {
@@ -529,16 +595,17 @@ public void testListAndDropShapesInRDFIgnoreGraph() throws Exception {
529595 && next .get ("param" ).asString ().equals ("maxInclusive" )) {
530596 assertEquals (2019 , next .get ("value" ).asInt ());
531597 }
532- if (next .get ("target" ).equals ("Person" ) && next .get ("propertyOrRelationshipPath" ).isNull ()
533- && next .get ("param" ).equals ("ignoredProperties" )) {
598+ if (next .get ("target" ).asString (). equals ("Person" ) && next .get ("propertyOrRelationshipPath" ).isNull ()
599+ && next .get ("param" ).asString (). equals ("ignoredProperties" )) {
534600 List <Object > expected = new ArrayList <>();
535601 expected .add ("WROTE" );
536602 expected .add ("PRODUCED" );
537603 expected .add ("REVIEWED" );
538604 expected .add ("FOLLOWS" );
539605 expected .add ("DIRECTED" );
540606 expected .add ("born" );
541- assertEquals (expected , next .get ("value" ).asList ());
607+ List <Object > actual = next .get ("value" ).asList ();
608+ assertTrue (expected .containsAll (actual ) && actual .containsAll (expected ));
542609 }
543610 }
544611
@@ -596,17 +663,18 @@ public void testListShapesInRDFShortenGraph() throws Exception {
596663 && next .get ("param" ).asString ().equals ("sh:maxInclusive" )) {
597664 assertEquals (2019 , next .get ("value" ).asInt ());
598665 }
599- if (next .get ("target" ).equals ("neo4j__Person" ) && next .get ("propertyOrRelationshipPath" )
666+ if (next .get ("target" ).asString (). equals ("neo4j__Person" ) && next .get ("propertyOrRelationshipPath" )
600667 .isNull ()
601- && next .get ("param" ).equals ("sh:ignoredProperties" )) {
668+ && next .get ("param" ).asString (). equals ("sh:ignoredProperties" )) {
602669 List <Object > expected = new ArrayList <>();
603670 expected .add ("neo4j__WROTE" );
604671 expected .add ("neo4j__PRODUCED" );
605672 expected .add ("neo4j__REVIEWED" );
606673 expected .add ("neo4j__FOLLOWS" );
607674 expected .add ("neo4j__DIRECTED" );
608675 expected .add ("neo4j__born" );
609- assertEquals (expected , next .get ("value" ).asList ());
676+ List <Object > actual = next .get ("value" ).asList ();
677+ assertTrue (expected .containsAll (actual ) && actual .containsAll (expected ));
610678 }
611679 }
612680
0 commit comments