Esempio n. 1
0
  @Test
  public void shouldRetrieveMultipleNodesWithSameValueFromIndex() throws Exception {
    // this test was included here for now as a precondition for the following test

    // given
    GraphDatabaseService graph = dbRule.getGraphDatabaseService();
    createIndex(graph, LABEL1, "name");

    Node node1, node2;
    try (Transaction tx = graph.beginTx()) {
      node1 = graph.createNode(LABEL1);
      node1.setProperty("name", "Stefan");

      node2 = graph.createNode(LABEL1);
      node2.setProperty("name", "Stefan");
      tx.success();
    }

    try (Transaction tx = graph.beginTx()) {
      ResourceIterator<Node> result = graph.findNodes(LABEL1, "name", "Stefan");
      assertEquals(asSet(node1, node2), asSet(result));

      tx.success();
    }
  }
Esempio n. 2
0
  @Test
  public void createdNodeShouldShowUpInIndexQuery() throws Exception {
    // GIVEN
    GraphDatabaseService beansAPI = dbRule.getGraphDatabaseService();
    createIndex(beansAPI, LABEL1, "name");
    createNode(beansAPI, map("name", "Mattias"), LABEL1);

    // WHEN
    Transaction tx = beansAPI.beginTx();

    long sizeBeforeDelete = count(beansAPI.findNodes(LABEL1, "name", "Mattias"));
    createNode(beansAPI, map("name", "Mattias"), LABEL1);
    long sizeAfterDelete = count(beansAPI.findNodes(LABEL1, "name", "Mattias"));

    tx.close();

    // THEN
    assertThat(sizeBeforeDelete, equalTo(1l));
    assertThat(sizeAfterDelete, equalTo(2l));
  }