use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldUpdateStringArrayPropertiesOnNodesUsingBatchInserter1.
@Test
public void shouldUpdateStringArrayPropertiesOnNodesUsingBatchInserter1() throws Exception {
// Given
BatchInserter batchInserter = globalInserter;
String[] array1 = { "1" };
String[] array2 = { "a" };
long id1 = batchInserter.createNode(map("array", array1));
long id2 = batchInserter.createNode(map());
// When
batchInserter.getNodeProperties(id1).get("array");
batchInserter.setNodeProperty(id1, "array", array1);
batchInserter.setNodeProperty(id2, "array", array2);
batchInserter.getNodeProperties(id1).get("array");
batchInserter.setNodeProperty(id1, "array", array1);
batchInserter.setNodeProperty(id2, "array", array2);
// Then
assertThat((String[]) batchInserter.getNodeProperties(id1).get("array"), equalTo(array1));
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method uniquenessConstraintShouldBeCheckedOnBatchInserterShutdownAndFailIfViolated.
@Test
public void uniquenessConstraintShouldBeCheckedOnBatchInserterShutdownAndFailIfViolated() throws Exception {
// Given
Label label = label("Foo");
String property = "Bar";
String value = "Baz";
BatchInserter inserter = newBatchInserter();
// When
inserter.createDeferredConstraint(label).assertPropertyIsUnique(property).create();
inserter.createNode(Collections.<String, Object>singletonMap(property, value), label);
inserter.createNode(Collections.<String, Object>singletonMap(property, value), label);
// Then
try {
inserter.shutdown();
fail("Node that violates uniqueness constraint was created by batch inserter");
} catch (RuntimeException ex) {
// good
assertEquals(new IndexEntryConflictException(0, 1, value), ex.getCause());
}
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldNotAllowCreationOfDeferredSchemaConstraintAfterIndexOnSameKeys.
@Test
public void shouldNotAllowCreationOfDeferredSchemaConstraintAfterIndexOnSameKeys() throws Exception {
// GIVEN
BatchInserter inserter = globalInserter;
String labelName = "Hacker3-" + denseNodeThreshold;
// WHEN
inserter.createDeferredSchemaIndex(label(labelName)).on("handle").create();
try {
inserter.createDeferredConstraint(label(labelName)).assertPropertyIsUnique("handle").create();
fail("Should have thrown exception.");
} catch (ConstraintViolationException e) {
// THEN Good
}
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInserterImplTest method testCreatesStoreLockFile.
@Test
public void testCreatesStoreLockFile() throws Exception {
// Given
File file = testDirectory.graphDbDir();
// When
BatchInserter inserter = BatchInserters.inserter(file.getAbsoluteFile(), fileSystemRule.get());
// Then
assertThat(new File(file, StoreLocker.STORE_LOCK_FILENAME).exists(), equalTo(true));
inserter.shutdown();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class FileSystemClosingBatchInserterTest method closeFileSystemOnShutdown.
@Test
public void closeFileSystemOnShutdown() throws Exception {
BatchInserter batchInserter = mock(BatchInserter.class);
IndexConfigStoreProvider configStoreProvider = mock(IndexConfigStoreProvider.class);
FileSystemAbstraction fileSystem = mock(FileSystemAbstraction.class);
FileSystemClosingBatchInserter inserter = new FileSystemClosingBatchInserter(batchInserter, configStoreProvider, fileSystem);
inserter.shutdown();
InOrder verificationOrder = inOrder(batchInserter, fileSystem);
verificationOrder.verify(batchInserter).shutdown();
verificationOrder.verify(fileSystem).close();
}
Aggregations