use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.
the class CsvInputTest method shouldIgnoreEmptyIntPropertyValues.
@Test
public void shouldIgnoreEmptyIntPropertyValues() throws Exception {
// GIVEN
DataFactory data = data(":ID,name,extra:int\n" + // here we leave out "extra" property
"0,Mattias,\n" + "1,Johan,10\n");
Iterable<DataFactory> dataIterable = dataIterable(data);
Input input = new CsvInput(dataIterable, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), ACTUAL, config(), NO_MONITOR, INSTANCE);
// WHEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
// THEN
assertNextNode(nodes, 0L, new Object[] { "name", "Mattias" }, labels());
assertNextNode(nodes, 1L, new Object[] { "name", "Johan", "extra", 10 }, labels());
assertFalse(readNext(nodes));
}
}
use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.
the class CsvInputTest method shouldParsePointPropertyValuesWithCRSInHeader.
@Test
public void shouldParsePointPropertyValuesWithCRSInHeader() throws Exception {
// GIVEN
DataFactory data = data(":ID,name,point:Point{crs:WGS-84-3D}\n" + "0,Johan,\" { height :0.01 ,longitude:5, latitude : -4.2 } \"\n");
Iterable<DataFactory> dataIterable = dataIterable(data);
Input input = new CsvInput(dataIterable, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), ACTUAL, config(), NO_MONITOR, INSTANCE);
// WHEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
// THEN
assertNextNode(nodes, 0L, new Object[] { "name", "Johan", "point", Values.pointValue(CoordinateReferenceSystem.WGS84_3D, 5, -4.2, 0.01) }, labels());
assertFalse(readNext(nodes));
}
}
use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.
the class CsvInputTest method shouldProvideAdditiveLabels.
@Test
public void shouldProvideAdditiveLabels() throws Exception {
// GIVEN
String[] addedLabels = { "Two", "AddTwo" };
DataFactory data = data(":ID,name,:LABEL\n" + "0,First,\n" + "1,Second,One\n" + "2,Third,One;Two", InputEntityDecorators.additiveLabels(addedLabels));
Iterable<DataFactory> dataIterable = dataIterable(data);
Input input = new CsvInput(dataIterable, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), ACTUAL, config(), NO_MONITOR, INSTANCE);
// WHEN/THEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
assertNextNode(nodes, 0L, properties("name", "First"), labels(addedLabels));
assertNextNode(nodes, 1L, properties("name", "Second"), labels(union(new String[] { "One" }, addedLabels)));
assertNextNode(nodes, 2L, properties("name", "Third"), labels(union(new String[] { "One" }, addedLabels)));
assertFalse(readNext(nodes));
}
}
use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.
the class CsvInputTest method shouldNotIncludeEmptyArraysInEntities.
@Test
public void shouldNotIncludeEmptyArraysInEntities() throws Exception {
// GIVEN
Iterable<DataFactory> data = datas(CsvInputTest.data(":ID,sprop:String[],lprop:long[]\n" + "1,,\n" + "2,a;b,10;20"));
Input input = new CsvInput(data, defaultFormatNodeFileHeader(), datas(), defaultFormatNodeFileHeader(), IdType.INTEGER, config(), NO_MONITOR, INSTANCE);
// WHEN/THEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
assertNextNode(nodes, 1L, InputEntity.NO_PROPERTIES, labels());
assertNextNode(nodes, 2L, properties("sprop", new String[] { "a", "b" }, "lprop", new long[] { 10, 20 }), labels());
assertFalse(readNext(nodes));
}
}
use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.
the class CsvInputTest method shouldNotParsePointPropertyValuesWithDuplicateKeys.
@Test
public void shouldNotParsePointPropertyValuesWithDuplicateKeys() throws Exception {
// GIVEN
DataFactory data = data(":ID,name,point:Point\n" + "1,Johan,\" { height :0.01 ,longitude:5, latitude : -4.2, latitude : 4.2 } \"\n");
Iterable<DataFactory> dataIterable = dataIterable(data);
Input input = new CsvInput(dataIterable, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), ACTUAL, config(), NO_MONITOR, INSTANCE);
// WHEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
// THEN
readNext(nodes);
fail("Should have failed when key assigned multiple times, but didn't.");
} catch (InputException ignore) {
// this is fine
}
}
Aggregations