Search in sources :

Example 31 with InputIterator

use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.

the class CsvInputTest method shouldParseLocalDateTimePropertyValues.

@Test
public void shouldParseLocalDateTimePropertyValues() throws Exception {
    // GIVEN
    DataFactory data = data(":ID,name,time:LocalDateTime\n" + "0,Mattias,2018-02-27T13:37\n" + "1,Johan,\"2018-03-01T16: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", LocalDateTimeValue.localDateTime(2018, 2, 27, 13, 37, 0, 0) }, labels());
        assertNextNode(nodes, 1L, new Object[] { "name", "Johan", "time", LocalDateTimeValue.localDateTime(2018, 3, 1, 16, 20, 1, 0) }, labels());
        assertFalse(readNext(nodes));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Example 32 with InputIterator

use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.

the class CsvInputTest method shouldParseDateTimePropertyValues.

@Test
public void shouldParseDateTimePropertyValues() throws Exception {
    // GIVEN
    DataFactory data = data(":ID,name,time:DateTime\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, "+00:00") }, labels());
        assertNextNode(nodes, 1L, new Object[] { "name", "Johan", "time", DateTimeValue.datetime(2018, 3, 1, 16, 20, 1, 0, "+00:00") }, labels());
        assertNextNode(nodes, 2L, new Object[] { "name", "Bob", "time", DateTimeValue.datetime(1981, 5, 11, 7, 30, 0, 0, "-05:00") }, labels());
        assertFalse(readNext(nodes));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Example 33 with InputIterator

use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.

the class CsvInputTest method shouldParsePointPropertyValues.

@Test
public void shouldParsePointPropertyValues() throws Exception {
    // GIVEN
    DataFactory data = data(":ID,name,point:Point\n" + "0,Mattias,\"{x: 2.7, y:3.2 }\"\n" + "1,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", "Mattias", "point", Values.pointValue(CoordinateReferenceSystem.Cartesian, 2.7, 3.2) }, labels());
        assertNextNode(nodes, 1L, new Object[] { "name", "Johan", "point", Values.pointValue(CoordinateReferenceSystem.WGS84_3D, 5, -4.2, 0.01) }, labels());
        assertFalse(readNext(nodes));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Example 34 with InputIterator

use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.

the class CsvInputTest method shouldIgnoreEmptyPropertyValues.

@Test
public void shouldIgnoreEmptyPropertyValues() throws Exception {
    // GIVEN
    DataFactory data = data(":ID,name,extra\n" + // here we leave out "extra" property
    "0,Mattias,\n" + "1,Johan,Additional\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", "Additional" }, labels());
        assertFalse(readNext(nodes));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Example 35 with InputIterator

use of org.neo4j.internal.batchimport.InputIterator in project neo4j by neo4j.

the class CsvInputTest method shouldParseTimePropertyValuesWithTimezoneInHeader.

@Test
public void shouldParseTimePropertyValuesWithTimezoneInHeader() throws Exception {
    // GIVEN
    DataFactory data = data(":ID,name,time:Time{timezone:+02:00}\n" + "0,Mattias,13:37\n" + "1,Johan,\"16:20:01\"\n" + "2,Bob,07: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", TimeValue.time(13, 37, 0, 0, "+02:00") }, labels());
        assertNextNode(nodes, 1L, new Object[] { "name", "Johan", "time", TimeValue.time(16, 20, 1, 0, "+02:00") }, labels());
        assertNextNode(nodes, 2L, new Object[] { "name", "Bob", "time", TimeValue.time(7, 30, 0, 0, "-05:00") }, labels());
        assertFalse(readNext(nodes));
    }
}
Also used : InputIterator(org.neo4j.internal.batchimport.InputIterator) Input(org.neo4j.internal.batchimport.input.Input) Test(org.junit.Test)

Aggregations

InputIterator (org.neo4j.internal.batchimport.InputIterator)37 Test (org.junit.Test)36 Input (org.neo4j.internal.batchimport.input.Input)36 IdType (org.neo4j.internal.batchimport.input.IdType)5 Matchers.containsString (org.hamcrest.Matchers.containsString)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Group (org.neo4j.internal.batchimport.input.Group)2 Groups (org.neo4j.internal.batchimport.input.Groups)2 InputException (org.neo4j.internal.batchimport.input.InputException)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 Configuration (org.neo4j.csv.reader.Configuration)1 Collector (org.neo4j.internal.batchimport.input.Collector)1