private void verifyProperty(
     final String assertionMessage,
     final String pid,
     final String txId,
     final String propertyUri,
     final String propertyValue,
     final boolean shouldExist)
     throws IOException {
   final HttpGet getObjCommitted =
       new HttpGet(serverAddress + (txId != null ? txId + "/" : "") + pid);
   try (final CloseableDataset dataset = getDataset(getObjCommitted)) {
     final boolean exists =
         dataset
             .asDatasetGraph()
             .contains(
                 ANY,
                 createURI(serverAddress + pid),
                 createURI(propertyUri),
                 createLiteral(propertyValue));
     if (shouldExist) {
       assertTrue(assertionMessage, exists);
     } else {
       assertFalse(assertionMessage, exists);
     }
   }
 }
  @Test
  public void testCreateDoStuffAndCommitTransaction() throws IOException {
    /* create a tx */
    final String txLocation = createTransaction();
    /* create a new object inside the tx */
    final String objectInTxCommit = getRandomUniqueId();
    final HttpPost postNew = new HttpPost(txLocation);
    postNew.addHeader("Slug", objectInTxCommit);
    assertEquals(CREATED.getStatusCode(), getStatus(postNew));

    /* fetch the created tx from the endpoint */
    try (CloseableDataset dataset = getDataset(new HttpGet(txLocation + "/" + objectInTxCommit))) {
      assertTrue(
          dataset
              .asDatasetGraph()
              .contains(ANY, createURI(txLocation + "/" + objectInTxCommit), ANY, ANY));
    }
    /* fetch the object-in-tx outside of the tx */
    assertEquals(
        "Expected to not find our object within the scope of the transaction",
        NOT_FOUND.getStatusCode(),
        getStatus(new HttpGet(serverAddress + objectInTxCommit)));
    /* and commit */
    assertEquals(
        NO_CONTENT.getStatusCode(), getStatus(new HttpPost(txLocation + "/fcr:tx/fcr:commit")));

    /* fetch the object-in-tx outside of the tx after it has been committed */
    try (CloseableDataset dataset = getDataset(new HttpGet(serverAddress + objectInTxCommit))) {
      assertTrue(
          "Expected to  find our object after the transaction was committed",
          dataset
              .asDatasetGraph()
              .contains(ANY, createURI(serverAddress + objectInTxCommit), ANY, ANY));
    }
  }
  @Test
  public void testCreateDoStuffAndRollbackTransaction() throws IOException {
    /* create a tx */
    final HttpPost createTx = new HttpPost(serverAddress + "fcr:tx");

    final String txLocation;
    try (final CloseableHttpResponse response = execute(createTx)) {
      assertEquals(CREATED.getStatusCode(), getStatus(response));
      txLocation = getLocation(response);
    }

    /* create a new object inside the tx */
    final HttpPost postNew = new HttpPost(txLocation);
    final String id = getRandomUniqueId();
    postNew.addHeader("Slug", id);
    try (CloseableHttpResponse resp = execute(postNew)) {
      assertEquals(CREATED.getStatusCode(), getStatus(resp));
    }
    /* fetch the created tx from the endpoint */
    try (final CloseableDataset dataset = getDataset(new HttpGet(txLocation + "/" + id))) {
      assertTrue(
          dataset.asDatasetGraph().contains(ANY, createURI(txLocation + "/" + id), ANY, ANY));
    }
    /* fetch the created tx from the endpoint */
    assertEquals(
        "Expected to not find our object within the scope of the transaction",
        NOT_FOUND.getStatusCode(),
        getStatus(new HttpGet(serverAddress + "/" + id)));

    /* and rollback */
    assertEquals(
        NO_CONTENT.getStatusCode(), getStatus(new HttpPost(txLocation + "/fcr:tx/fcr:rollback")));
  }
  /**
   * Tests whether a Sparql update is visible within a transaction and if the update is made
   * persistent along with the commit.
   *
   * @throws IOException exception thrown during this function
   */
  @Test
  public void testIngestNewWithSparqlPatchWithinTransaction() throws IOException {
    final String objectInTxCommit = getRandomUniqueId();

    /* create new tx */
    final String txLocation = createTransaction();

    final HttpPost postNew = new HttpPost(txLocation);
    postNew.addHeader("Slug", objectInTxCommit);
    final String newObjectLocation;
    try (CloseableHttpResponse resp = execute(postNew)) {
      assertEquals(CREATED.getStatusCode(), getStatus(resp));
      newObjectLocation = getLocation(resp);
    }

    /* update sparql */
    final HttpPatch method = new HttpPatch(newObjectLocation);
    method.addHeader(CONTENT_TYPE, "application/sparql-update");
    final String newTitle = "this is a new title";
    method.setEntity(
        new StringEntity(
            "INSERT { <> <http://purl.org/dc/elements/1.1/title> \"" + newTitle + "\" } WHERE {}"));
    assertEquals("Didn't get a NO CONTENT status!", NO_CONTENT.getStatusCode(), getStatus(method));
    /* make sure the change was made within the tx */
    try (final CloseableDataset dataset = getDataset(new HttpGet(newObjectLocation))) {
      assertTrue(
          "The sparql update did not succeed within a transaction",
          dataset
              .asDatasetGraph()
              .contains(
                  ANY, createURI(newObjectLocation), title.asNode(), createLiteral(newTitle)));
    }
    /* commit */
    assertEquals(
        NO_CONTENT.getStatusCode(), getStatus(new HttpPost(txLocation + "/fcr:tx/fcr:commit")));

    /* it must exist after commit */
    try (final CloseableDataset dataset =
        getDataset(new HttpGet(serverAddress + objectInTxCommit))) {
      assertTrue(
          "The inserted triple does not exist after the transaction has committed",
          dataset.asDatasetGraph().contains(ANY, ANY, title.asNode(), createLiteral(newTitle)));
    }
  }