@Test
  public void testPurgeRelationships() throws Exception {
    String p, o;
    int relNum =
        0; // used to form unique relationships or objects/object literals... addRelationship needs
           // unique predicate x object combinations

    for (String s : subject) {

      p = "urn:p" + relNum++;
      o = "urn:o";
      purgeRelationship(s, p, o, false, null);

      p = "urn:title" + relNum;
      o = "asdf"; // "三国演义"; // test unicode
      purgeRelationship(s, p, o, true, null);

      p = "urn:temperature" + relNum;
      o = "98.6";
      purgeRelationship(s, p, o, true, Constants.RDF_XSD.FLOAT.uri);

      // utf-8 literal with multibyte sequences
      p = "urn:utf8literal" + relNum;
      o = MULTIBYTE_UTF8;
      purgeRelationship(s, p, o, true, null);

      assertFalse(
          "Purging non-existant relation should have failed",
          apim.purgeRelationship(s, "urn:asdf", "867-5309", true, null));

      addRelationship(s, p, o, true, null);
      addRelationship(s, p, "foo", true, null);

      List<RelationshipTuple> tuples = apim.getRelationships(s, p);
      assertNotNull(tuples);
      assertEquals(2, tuples.size());
      assertTrue(
          "Purging relationship with null object should delete all subject/predicate matches",
          apim.purgeRelationship(s, p, null, true, null));
      tuples = apim.getRelationships(s, p);
      assertNotNull(tuples);
      assertEquals(0, tuples.size());
    }
  }
 private void getRelationship(
     String subject, String predicate, String object, boolean isLiteral, String datatype)
     throws Exception {
   addRelationship(subject, predicate, object, isLiteral, datatype);
   List<RelationshipTuple> tuples = apim.getRelationships(subject, predicate);
   assertNotNull(tuples);
   assertEquals(1, tuples.size());
   assertEquals(subjectAsURI(subject), tuples.get(0).getSubject());
   assertEquals(predicate, tuples.get(0).getPredicate());
   assertEquals(object, tuples.get(0).getObject());
   assertEquals(isLiteral, tuples.get(0).isIsLiteral());
   assertEquals(datatype, tuples.get(0).getDatatype());
 }
  private void checkExistsViaGetRelationships(String subject, String predicate, String object)
      throws Exception {
    boolean found = false;

    for (RelationshipTuple tuple : apim.getRelationships(subject, predicate)) {
      if (tuple.getSubject().equals(subjectAsURI(subject))
          && tuple.getPredicate().equals(predicate)
          && tuple.getObject().equals(object)) {
        found = true;
      }
    }
    assertTrue(
        "Relationship not found via getRelationships (subject="
            + subject
            + ", predicate="
            + predicate
            + ", object="
            + object,
        found);
  }
 @Test
 public void testGetAllRelationships() throws Exception {
   // subject uri and pid
   List<RelationshipTuple> tuples = apim.getRelationships("demo:777", null);
   assertEquals(1, tuples.size());
 }