예제 #1
0
  @Test
  public void clearGraphWithoutRuntimeShouldDeleteBasedOnRelInclusionPolicy() {
    try (Transaction tx = database.beginTx()) {
      String cypher =
          "CREATE "
              + "(purple:Purple {name:'Purple'})<-[:REL]-(red1:Red {name:'Red'})-[:REL]->(black1:Black {name:'Black'})-[:REL]->(green:Green {name:'Green'}),"
              + "(red2:Red {name:'Red'})-[:REL]->(black2:Black {name:'Black'}), (blue1:Blue)-[:REL2]->(blue2:Blue)";

      populateDatabase(cypher);
      tx.success();
    }

    InclusionPolicies inclusionPolicies =
        InclusionPolicies.all().with(new BlueNodeInclusionPolicy()).with(new Rel2InclusionPolicy());
    try (Transaction tx = database.beginTx()) {
      clearGraph(database, inclusionPolicies);
      tx.success();
    }

    try (Transaction tx = database.beginTx()) {
      assertEquals(6, count(at(database).getAllNodes()));
      assertEquals(4, count(at(database).getAllRelationships()));
      tx.success();
    }
  }
예제 #2
0
  @Test
  public void equalArraysWithDifferentTypeShouldBeEqual() {
    try (Transaction tx = database.beginTx()) {
      database.createNode().setProperty("number", new int[] {123, 124});
      tx.success();
    }

    String cypher = "CREATE (n {number:[123,124]})";

    assertSameGraph(database, cypher);
  }
예제 #3
0
  @Test
  public void deletedNewPropsShouldNotInfluenceEquality() { // bug test
    try (Transaction tx = database.beginTx()) {
      database.createNode().setProperty("accident", "dummy");
      database.createNode();
      tx.success();
    }

    try (Transaction tx = database.beginTx()) {
      database.getNodeById(0).delete();
      tx.success();
    }

    String cypher = "CREATE (n)";

    assertSameGraph(database, cypher);
  }
예제 #4
0
  @Test
  public void deletedNewLabelShouldNotInfluenceEquality() { // bug test
    try (Transaction tx = database.beginTx()) {
      database.createNode(DynamicLabel.label("Accident"));
      database.createNode(DynamicLabel.label("RealLabel"));
      tx.success();
    }

    try (Transaction tx = database.beginTx()) {
      database.getNodeById(0).delete();
      tx.success();
    }

    String cypher = "CREATE (n:RealLabel)";

    assertSameGraph(database, cypher);
  }
예제 #5
0
  @Test
  public void deletedRelationshipWithNewTypeShouldNotInfluenceEquality() { // bug test
    try (Transaction tx = database.beginTx()) {
      Node node1 = database.createNode();
      Node node2 = database.createNode();
      node1.createRelationshipTo(node2, DynamicRelationshipType.withName("ACCIDENT"));
      tx.success();
    }

    try (Transaction tx = database.beginTx()) {
      GlobalGraphOperations.at(database).getAllRelationships().iterator().next().delete();
      tx.success();
    }

    String cypher = "CREATE (n), (m)";

    assertSameGraph(database, cypher);
  }
예제 #6
0
  @Test
  public void clearGraphWithoutRuntimeShouldDeleteAllNodesAndRels() {
    try (Transaction tx = database.beginTx()) {
      String cypher =
          "CREATE "
              + "(blue {name:'Blue'})<-[:REL]-(red1 {name:'Red'})-[:REL]->(black1 {name:'Black'})-[:REL]->(green {name:'Green'}),"
              + "(red2 {name:'Red'})-[:REL]->(black2 {name:'Black'})";

      populateDatabase(cypher);
      tx.success();
    }

    try (Transaction tx = database.beginTx()) {
      clearGraph(database);
      tx.success();
    }

    try (Transaction tx = database.beginTx()) {
      assertEquals(0, count(at(database).getAllNodes()));
      tx.success();
    }
  }
예제 #7
0
 private void populateDatabase(String cypher) {
   database.execute(cypher);
 }
예제 #8
0
 @After
 public void tearDown() {
   database.shutdown();
 }