@Test
  public void testSubclass() {
    Node p1 = getNode("http://example.org/p1");
    Node p2 = getNode("http://example.org/p2");
    Node p3 = getNode("http://example.org/p3");

    Relationship first =
        getOnlyElement(
            GraphUtil.getRelationships(p3, p1, OwlRelationships.OWL_PROPERTY_CHAIN_AXIOM));
    assertThat(GraphUtil.getProperty(first, "order", Integer.class), is(Optional.of(0)));
    Relationship second =
        getOnlyElement(
            GraphUtil.getRelationships(p3, p2, OwlRelationships.OWL_PROPERTY_CHAIN_AXIOM));
    assertThat(GraphUtil.getProperty(second, "order", Integer.class), is(Optional.of(1)));
  }
示例#2
0
  @Test
  public void testPun() {
    Node i = getNode("http://example.org/i");
    Node j = getNode("http://example.org/j");
    Node k = getNode("http://example.org/k");

    RelationshipType p = DynamicRelationshipType.withName("p");
    Relationship relationship = getOnlyElement(GraphUtil.getRelationships(i, j, p));
    assertThat("OPE edge should start with the subject.", relationship.getStartNode(), is(i));
    assertThat("OPE edge should end with the target.", relationship.getEndNode(), is(j));
    relationship =
        getOnlyElement(GraphUtil.getRelationships(i, k, OwlRelationships.RDFS_SUBCLASS_OF));
    assertThat("Subclass edge should start with i.", relationship.getStartNode(), is(i));
    assertThat("Subclass edge should end with k.", relationship.getEndNode(), is(k));
    assertThat(
        "i is both a class an a named individual",
        i.getLabels(),
        is(
            IsIterableContainingInAnyOrder.containsInAnyOrder(
                OwlLabels.OWL_CLASS, OwlLabels.OWL_NAMED_INDIVIDUAL)));
  }