Exemple #1
0
  // MMB-1893
  public void testDeleteNodeWitRelationsAndCancel() {
    Cloud cloud = getCloud();

    int urlCount0 = Queries.count(cloud.getNodeManager("urls").createQuery());
    int relCount0 = Queries.count(cloud.getNodeManager("insrel").createQuery());

    Node url = cloud.getNodeManager("urls").createNode();
    url.commit();
    Node news = cloud.getNode(newNode);
    RelationManager rm = cloud.getRelationManager("urls", "news", "posrel");
    Relation r = url.createRelation(news, rm);
    r.commit();

    int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery());
    int relCount = Queries.count(cloud.getNodeManager("insrel").createQuery());

    assertEquals(urlCount0 + 1, urlCount);
    assertEquals(relCount0 + 1, relCount);

    Transaction t = cloud.getTransaction("deletewithrelationsandcancel");

    Node turl = t.getNode(url.getNumber());
    turl.delete(true);

    t.cancel();

    int urlCountAfter = Queries.count(cloud.getNodeManager("urls").createQuery());
    assertEquals(urlCount, urlCountAfter);

    int relCountAfter = Queries.count(cloud.getNodeManager("insrel").createQuery());
    assertEquals(relCount, relCountAfter); // MMB-1893
  }
Exemple #2
0
  public void testCreateAndDelete2() {
    // Create new node. Request the node again. Delete  that. Commit the transaction.
    // The new node must not exist.

    Cloud cloud = getCloud();
    int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery());

    Transaction t = cloud.getTransaction("testcreateandelete");
    Node url = t.getNodeManager("urls").createNode();
    url.commit();
    assertEquals(1, t.getNodes().size());

    Node reurl = t.getNode(url.getNumber());
    reurl.delete();

    assertEquals(
        1,
        t.getNodes()
            .size()); // 0 would also be an option, but the node remaisn in the transaction as
                      // 'NOLONGER'

    t.commit();

    int urlCountAfter = Queries.count(cloud.getNodeManager("urls").createQuery());

    assertEquals(urlCount, urlCountAfter);
  }
Exemple #3
0
  // MMB-1889
  public void testCreateRelationAndDeleteNode() {
    // Make a relation to an existing node. Then delete that node with the 'delete relations'
    // option'. Commit the transaction.
    // The new relations should not exist, since the node was deleted.
    // No errors.

    Cloud cloud = getCloud();

    int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery());
    int relCount = Queries.count(cloud.getNodeManager("insrel").createQuery());

    Node url = cloud.getNodeManager("urls").createNode();
    url.commit();

    Transaction t = cloud.getTransaction("relatedandelete");

    Node turl = t.getNode(url.getNumber());
    Node news = t.getNode(newNode);
    RelationManager rm = t.getRelationManager("urls", "news", "posrel");
    Relation r = turl.createRelation(news, rm);
    r.commit();
    turl.delete(true);
    t.commit();

    int urlCountAfter = Queries.count(cloud.getNodeManager("urls").createQuery());
    assertEquals(urlCount, urlCountAfter);
    int relCountAfter = Queries.count(cloud.getNodeManager("insrel").createQuery());
    assertEquals(relCount, relCountAfter);
  }
Exemple #4
0
  // same case as above, only no changes are made to the node.
  public void testDeleteNodeOutsideTransactionNodeInTransactionButNotChanged() {
    Cloud cloud = getCloud();
    Transaction t = cloud.getTransaction("bar11");
    Node nodeInTransaction = t.getNode(newNode2);
    // nodeInTransaction.setStringValue("title", "foo2");
    {
      // now delete the node
      Node nodeOutTransaction = cloud.getNode(newNode2);
      nodeOutTransaction.delete();
      assertFalse(cloud.hasNode(newNode2));
    }

    try {
      // make a relation to the (deleted) node, but in the transaction, where the node still
      // exists.
      // This demonstrate that there is an actual problem if the node ends up non-existing now.
      Node url = t.getNodeManager("urls").createNode();
      RelationManager rm = t.getRelationManager("news", "urls", "posrel");
      Relation r = nodeInTransaction.createRelation(url, rm);
      t.commit();
    } catch (Exception e) {
      // should not give exception. MMB-1680
      log.error(e.getMessage(), e);
      fail(e.getMessage());
    }

    assertTrue(cloud.hasNode(newNode2));
    assertEquals(1, cloud.getNode(newNode2).countRelations());
  }
Exemple #5
0
 public void testCommitDelete() {
   Cloud cloud = getCloud();
   Transaction t = cloud.getTransaction("bar6");
   Node node = t.getNode(newNode);
   node.delete();
   t.commit();
   assertFalse(cloud.hasNode(newNode));
 }
Exemple #6
0
 public void testCancelDelete() {
   Cloud cloud = getCloud();
   Transaction t = cloud.getTransaction("bar5");
   Node node = t.getNode(newNode);
   node.delete();
   t.cancel();
   assertTrue(cloud.hasNode(newNode));
 }
Exemple #7
0
  public void testDeleteNodeOutsideTransaction() {
    Cloud cloud = getCloud();
    Transaction t = cloud.getTransaction("bar11");
    Node nodeInTransaction = t.getNode(newNode2);
    nodeInTransaction.setStringValue("title", "foo2");
    {
      // now delete the node
      Node nodeOutTransaction = cloud.getNode(newNode2);
      nodeOutTransaction.delete();
      assertFalse(cloud.hasNode(newNode2));
    }

    try {
      t.commit();
    } catch (Exception e) {
      // should not give exception. MMB-1680
      log.error(e.getMessage(), e);
      fail(e.getMessage());
    }

    assertTrue(cloud.hasNode(newNode2));
  }
Exemple #8
0
  // MMB-1860 (2)
  public void testCreateRelateAndDelete() {

    // Create new node. Make a relation to it. Delete the node again. Commit the transaction.
    // The new node must not exist, but the relation shouldn't have caused errors

    Cloud cloud = getCloud();
    int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery());

    Transaction t = cloud.getTransaction("testcreateandelete");

    Node news = t.getNode(newNode);
    Node url = t.getNodeManager("urls").createNode();
    RelationManager rm = t.getRelationManager("urls", "news", "posrel");
    Relation r = url.createRelation(news, rm);

    url.delete(true);

    t.commit();

    int urlCountAfter = Queries.count(cloud.getNodeManager("urls").createQuery());

    assertEquals(urlCount, urlCountAfter);
  }