Exemplo n.º 1
0
  @Test
  public void shouldSortTriplesForDisplay() {
    final Model model = createDefaultModel();

    model.setNsPrefix("prefix", "namespace");
    final Property propertyA = model.createProperty("namespace", "a");
    final Property propertyB = model.createProperty("namespace", "b");
    final Property propertyC = model.createProperty("c");
    final Literal literalA = model.createLiteral("a");
    final Literal literalB = model.createLiteral("b");
    final Resource resourceB = model.createResource("b");
    model.add(resourceB, propertyA, literalA);

    final Resource a = model.createResource("a");
    model.add(a, propertyC, literalA);

    model.add(a, propertyB, literalA);

    model.add(a, propertyA, literalA);
    model.add(a, propertyA, literalB);

    final Iterator<Quad> iterator = DatasetFactory.create(model).asDatasetGraph().find();

    final List<Quad> sortedTriples = testObj.getSortedTriples(model, iterator);

    sortedTriples.get(0).matches(ANY, a.asNode(), propertyA.asNode(), literalA.asNode());
    sortedTriples.get(1).matches(ANY, a.asNode(), propertyA.asNode(), literalB.asNode());
    sortedTriples.get(2).matches(ANY, a.asNode(), propertyB.asNode(), literalA.asNode());
    sortedTriples.get(3).matches(ANY, a.asNode(), propertyC.asNode(), literalA.asNode());
    sortedTriples.get(4).matches(ANY, resourceB.asNode(), propertyC.asNode(), literalA.asNode());
  }
Exemplo n.º 2
0
 /**
  * Test that two literals are semantically equivalent. In some cases this may be the sames as
  * equals, in others equals is stricter. For example, two xsd:int literals with the same value but
  * different language tag are semantically equivalent but distinguished by the java equality
  * function in order to support round tripping.
  */
 public boolean sameValueAs(Literal other) {
   return asNode().sameValueAs(other.asNode());
 }