示例#1
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);
  }
示例#2
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());
  }
示例#3
0
  // MMB-1860 (4)
  public void testRelateAndDeleteRelation() {

    //  Make a relation between two nodes. Delete the relation again. Commit the transaction.
    // Te relation shouldn't exist

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

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

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

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

    r.delete();

    t.commit();

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

    assertEquals(urlCount + 1, urlCountAfter);

    // But the relation should not exist, because it was deleted angain

    int relCountAfter = Queries.count(cloud.getNodeManager("insrel").createQuery());

    assertEquals(relCount, relCountAfter);
  }
示例#4
0
 // old node as argument
 public void testCreateRelationToNewNode2() {
   Cloud cloud = getCloud();
   Transaction t = cloud.getTransaction("createrelationtrans");
   Node n = t.getNode(newNode);
   NodeManager urls = t.getNodeManager("urls");
   Node url = urls.createNode();
   RelationManager rm = t.getRelationManager("urls", "news", "posrel");
   Relation r = url.createRelation(n, rm);
   t.commit();
 }
示例#5
0
 public void testCreateRelationBetweenNewNodes() {
   Cloud cloud = getCloud();
   Transaction t = cloud.getTransaction("createrelationtrans");
   NodeManager news = t.getNodeManager("news");
   Node n = news.createNode();
   NodeManager urls = t.getNodeManager("urls");
   Node url = urls.createNode();
   RelationManager rm = t.getRelationManager("news", "urls", "posrel");
   Relation r = n.createRelation(url, rm);
   t.commit();
 }
示例#6
0
 public void testTransactionsAreEqual() {
   Cloud cloud = getCloud();
   Transaction t1 = cloud.getTransaction("testequals");
   Transaction t2 = cloud.getTransaction("testequals");
   assertEquals(t1, t2);
   Node n = t1.getNode(newNode);
   NodeManager urls = t2.getNodeManager("urls");
   Node url = urls.createNode();
   RelationManager rm = t2.getRelationManager("urls", "news", "posrel");
   Relation r = url.createRelation(n, rm);
   t2.commit();
   assertTrue(t2.isCommitted());
   assertTrue(t1.isCommitted());
   // assertTrue(t1 == t2); // FAILS IN RMMCI. Perhaps we should simply implement .equals on
   // transactions
 }
示例#7
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);
  }
示例#8
0
  // MMB-1857
  public void testGetNodes() {
    Cloud cloud = getCloud();
    Transaction t = cloud.getTransaction("testgetnodes");
    Node n = t.getNode(newNode);
    Node url = t.getNodeManager("urls").createNode();
    RelationManager rm = t.getRelationManager("urls", "news", "posrel");
    Relation r = url.createRelation(n, rm);

    {
      // should not give NPE's or so
      n.commit();
      url.commit();
      r.commit();
    }

    assertEquals(3, t.getNodes().size()); // 2 nodes and one relation

    for (Node rn : t.getNodes()) {
      // should occur no exceptions
      rn.commit(); // should have little effect in trans
    }
    t.cancel();
  }