use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class ImportCommandTest method shouldImportWithoutTypeSpecifiedInRelationshipHeaderbutWithDefaultTypeInArgument.
@Test
void shouldImportWithoutTypeSpecifiedInRelationshipHeaderbutWithDefaultTypeInArgument() throws Exception {
// GIVEN
List<String> nodeIds = nodeIds();
Configuration config = Configuration.COMMAS;
String type = randomType();
Path dbConfig = prepareDefaultConfigFile();
// WHEN
runImport("--additional-config", dbConfig.toAbsolutePath().toString(), "--nodes", nodeData(true, config, nodeIds, TRUE).toAbsolutePath().toString(), // there will be no :TYPE specified in the header of the relationships below
"--relationships", type + "=" + relationshipData(true, config, nodeIds, TRUE, false).toAbsolutePath().toString());
// THEN
verifyData();
}
use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class ImportCommandTest method importIntoLowerCasedDatabaseName.
@Test
void importIntoLowerCasedDatabaseName() throws Exception {
List<String> nodeIds = nodeIds();
Configuration config = Configuration.COMMAS;
Path dbConfig = prepareDefaultConfigFile();
var mixedCaseDatabaseName = "TestDataBase";
runImport("--additional-config", dbConfig.toAbsolutePath().toString(), "--nodes", nodeData(true, config, nodeIds, TRUE).toAbsolutePath().toString(), "--database", mixedCaseDatabaseName);
var db = getDatabaseApi(mixedCaseDatabaseName.toLowerCase());
assertEquals(mixedCaseDatabaseName.toLowerCase(), db.databaseName());
try (Transaction tx = db.beginTx()) {
int nodeCount = 0;
for (Node node : tx.getAllNodes()) {
assertTrue(node.hasProperty("name"));
nodeCount++;
assertFalse(node.hasRelationship());
}
assertEquals(NODE_COUNT, nodeCount);
tx.commit();
}
}
use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class ImportCommandTest method shouldReportBadDelimiterConfiguration.
@Test
void shouldReportBadDelimiterConfiguration() throws Exception {
// GIVEN
List<String> nodeIds = nodeIds();
Configuration config = Configuration.TABS;
// WHEN
var e = assertThrows(ParameterException.class, () -> runImport("--delimiter", "\\bogus", "--array-delimiter", String.valueOf(config.arrayDelimiter()), "--nodes", nodeData(true, config, nodeIds, TRUE).toAbsolutePath().toString(), "--relationships", relationshipData(true, config, nodeIds, TRUE, true).toAbsolutePath().toString()));
assertThat(e).hasMessageContaining("bogus");
}
use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class ImportCommandTest method shouldImportFromInputDataEncodedWithSpecificCharset.
@Test
void shouldImportFromInputDataEncodedWithSpecificCharset() throws Exception {
// GIVEN
List<String> nodeIds = nodeIds();
Configuration config = Configuration.COMMAS;
Charset charset = StandardCharsets.UTF_16;
Path dbConfig = prepareDefaultConfigFile();
// WHEN
runImport("--additional-config", dbConfig.toAbsolutePath().toString(), "--input-encoding", charset.name(), "--nodes", nodeData(true, config, nodeIds, TRUE, charset).toAbsolutePath().toString(), "--relationships", relationshipData(true, config, nodeIds, TRUE, true, charset).toAbsolutePath().toString());
// THEN
verifyData();
}
use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class ImportCommandTest method shouldImportOnlyNodes.
@Test
void shouldImportOnlyNodes() throws Exception {
// GIVEN
List<String> nodeIds = nodeIds();
Configuration config = Configuration.COMMAS;
Path dbConfig = prepareDefaultConfigFile();
// WHEN
runImport("--additional-config", dbConfig.toAbsolutePath().toString(), "--nodes", nodeData(true, config, nodeIds, TRUE).toAbsolutePath().toString());
// no relationships
// THEN
GraphDatabaseService db = getDatabaseApi();
try (Transaction tx = db.beginTx()) {
int nodeCount = 0;
for (Node node : tx.getAllNodes()) {
assertTrue(node.hasProperty("name"));
nodeCount++;
assertFalse(node.hasRelationship());
}
assertEquals(NODE_COUNT, nodeCount);
tx.commit();
}
}
Aggregations