Exemplo n.º 1
0
  @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);
  }
Exemplo n.º 2
0
  /**
   * Generates a Dereference reader. This can be either a remote url, a local file or a resource
   *
   * @param uri a uri that can be a remote (http) resource, a local file or a java resource object
   * @return a RDFFirstSuccessReader that tries to resolve 1) remote 2) local 3) resources
   */
  public static RDFReader createDereferenceReader(String uri) {
    Collection<RDFReader> readers = new ArrayList<>();
    if (!IOUtils.isFile(uri)) {
      readers.add(new RDFDereferenceReader(uri));
      readers.add(new RDFaReader(uri));
    } else {
      readers.add(new RDFStreamReader(uri));
      readers.add(RDFReaderFactory.createResourceReader(uri));
    }

    return new RDFFirstSuccessReader(readers);
  }
Exemplo n.º 3
0
 /**
  * createEmptyReader.
  *
  * @return a {@link org.aksw.rdfunit.io.reader.RDFReader} object.
  * @since 0.7.19
  */
 public static RDFReader createEmptyReader() {
   return RDFReaderFactory.createResourceReader("/org/aksw/rdfunit/data/empty.ttl");
 }