@Test public void testRead() throws Exception { Model shapesModel = RDFReaderFactory.createResourceReader(shapeResource).read(); List<Shape> shapes = shapesModel .listResourcesWithProperty(RDF.type, SHACL.Shape) .toList() .stream() .map(r -> ShapeReader.create().read(r)) .collect(Collectors.toList()); assertThat(shapes).hasSize(1); Shape sh = shapes.get(0); assertThat(sh.getScopes()).hasSize(ShapeScopeType.values().length); List<ShapeScopeType> scopeTypes = sh.getScopes() .stream() .map(ShapeScope::getScopeType) .distinct() .collect(Collectors.toList()); // distinct scopes assertThat(scopeTypes).hasSize(ShapeScopeType.values().length); }
public Shape testReadAndWriteTheSame(Shape shape, ShapeReader reader, ShapeWriter writer) throws IOException, ParseException { assertNotNull(shape); StringWriter str = new StringWriter(); writer.write(str, shape); // System.out.println( "OUT: "+str.toString()); Shape out = reader.read(new StringReader(str.toString())); StringWriter copy = new StringWriter(); writer.write(copy, out); assertEquals(str.toString(), copy.toString()); return out; }