-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* adding test for #349 * fixes #349 filter removedNodeProperties for those belonging to `deletedNodes`
- Loading branch information
1 parent
edd7d51
commit 0f3eedd
Showing
2 changed files
with
75 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/apoc/index/IndexUpdateTransactionEventHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package apoc.index; | ||
|
||
import apoc.util.TestUtil; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.neo4j.graphdb.GraphDatabaseService; | ||
import org.neo4j.kernel.internal.GraphDatabaseAPI; | ||
import org.neo4j.test.TestGraphDatabaseFactory; | ||
|
||
import static apoc.util.TestUtil.*; | ||
import static org.junit.Assert.*; | ||
|
||
public class IndexUpdateTransactionEventHandlerTest { | ||
|
||
private GraphDatabaseService db; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
db = new TestGraphDatabaseFactory().newImpermanentDatabase(); | ||
db.registerTransactionEventHandler(new IndexUpdateTransactionEventHandler((GraphDatabaseAPI) db, false)); | ||
TestUtil.registerProcedure(db, FreeTextSearch.class); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
db.shutdown(); | ||
} | ||
|
||
@Test | ||
public void shouldDeletingIndexedNodesSucceed() { | ||
// setup: create index, add a node | ||
testCallEmpty(db, "call apoc.index.addAllNodesExtended('search_index',{City:['name']},{autoUpdate:true})", null); | ||
testCallEmpty(db, "create (c:City{name:\"Made Up City\",url:\"/places/nowhere/made-up-city\"})", null); | ||
|
||
// check if we find the node | ||
testCallCount(db, "start n=node:search_index('name:\"Made Up\"') return n", null, 1); | ||
|
||
// when | ||
TestUtil.testCall(db, "match (c:City{name:'Made Up City'}) delete c return count(c) as count", map -> assertEquals(1L, map.get("count"))); | ||
|
||
// nothing found in the index after deletion | ||
testCallCount(db, "start n=node:search_index('name:\"Made Up\"') return n", null, 0); | ||
|
||
} | ||
} |