use of org.neo4j.internal.batchimport.input.Input in project neo4j by neo4j.
the class CsvInputTest method shouldProvideNodesFromCsvInput.
@Test
public void shouldProvideNodesFromCsvInput() throws Exception {
// GIVEN
IdType idType = ACTUAL;
Iterable<DataFactory> data = dataIterable(data("123,Mattias Persson,HACKER"));
Input input = new CsvInput(data, header(entry(null, Type.ID, CsvInput.idExtractor(idType, extractors)), entry("name", Type.PROPERTY, extractors.string()), entry("labels", Type.LABEL, extractors.string())), datas(), defaultFormatRelationshipFileHeader(), idType, config(), NO_MONITOR, INSTANCE);
// WHEN/THEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
assertNextNode(nodes, 123L, properties("name", "Mattias Persson"), labels("HACKER"));
assertFalse(chunk.next(visitor));
}
}
use of org.neo4j.internal.batchimport.input.Input in project neo4j by neo4j.
the class CsvInputTest method shouldParseDateTimePropertyValuesWithTimezoneInHeader.
@Test
public void shouldParseDateTimePropertyValuesWithTimezoneInHeader() throws Exception {
// GIVEN
DataFactory data = data(":ID,name,time:DateTime{timezone:Europe/Stockholm}\n" + "0,Mattias,2018-02-27T13:37\n" + "1,Johan,\"2018-03-01T16:20:01\"\n" + "2,Bob,1981-05-11T07:30-05:00\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", "time", DateTimeValue.datetime(2018, 2, 27, 13, 37, 0, 0, "Europe/Stockholm") }, labels());
assertNextNode(nodes, 1L, new Object[] { "name", "Johan", "time", DateTimeValue.datetime(2018, 3, 1, 16, 20, 1, 0, "Europe/Stockholm") }, labels());
assertNextNode(nodes, 2L, new Object[] { "name", "Bob", "time", DateTimeValue.datetime(1981, 5, 11, 7, 30, 0, 0, "-05:00") }, labels());
assertFalse(readNext(nodes));
}
}
use of org.neo4j.internal.batchimport.input.Input in project neo4j by neo4j.
the class CsvInputTest method shouldParseLocalTimePropertyValues.
@Test
public void shouldParseLocalTimePropertyValues() throws Exception {
// GIVEN
DataFactory data = data(":ID,name,time:LocalTime\n" + "0,Mattias,13:37\n" + "1,Johan,\"16:20:01\"\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", "time", LocalTimeValue.localTime(13, 37, 0, 0) }, labels());
assertNextNode(nodes, 1L, new Object[] { "name", "Johan", "time", LocalTimeValue.localTime(16, 20, 1, 0) }, labels());
assertFalse(readNext(nodes));
}
}
use of org.neo4j.internal.batchimport.input.Input in project neo4j by neo4j.
the class CsvInputTest method shouldIgnoreValuesAfterHeaderEntries.
@Test
public void shouldIgnoreValuesAfterHeaderEntries() throws Exception {
// GIVEN
Iterable<DataFactory> data = dataIterable(data("1,zergling,bubble,bobble\n" + "2,scv,pun,intended"));
Input input = new CsvInput(data, header(entry(null, Type.ID, extractors.long_()), entry("name", Type.PROPERTY, extractors.string())), datas(), defaultFormatRelationshipFileHeader(), ACTUAL, config(), NO_MONITOR, INSTANCE);
// WHEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
// THEN
assertNextNode(nodes, 1L, new Object[] { "name", "zergling" }, labels());
assertNextNode(nodes, 2L, new Object[] { "name", "scv" }, labels());
assertFalse(readNext(nodes));
}
}
use of org.neo4j.internal.batchimport.input.Input in project neo4j by neo4j.
the class CsvInputTest method shouldPropagateExceptionFromFailingDecorator.
@Test
public void shouldPropagateExceptionFromFailingDecorator() throws Exception {
// GIVEN
RuntimeException failure = new RuntimeException("FAILURE");
Iterable<DataFactory> data = datas(CsvInputTest.data(":ID,name\n1,Mattias", new FailingNodeDecorator(failure)));
Input input = new CsvInput(data, defaultFormatNodeFileHeader(), datas(), defaultFormatNodeFileHeader(), IdType.INTEGER, config(), NO_MONITOR, INSTANCE);
// WHEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
readNext(nodes);
} catch (InputException e) {
// THEN
assertSame(e.getCause(), failure);
}
}
Aggregations