Search in sources :

Example 1 with MultiReadable

use of org.neo4j.csv.reader.MultiReadable in project neo4j by neo4j.

the class DataFactoriesTest method shouldParseHeaderFromFirstLineOfFirstInputFile.

@Test
public void shouldParseHeaderFromFirstLineOfFirstInputFile() throws Exception {
    // GIVEN
    final CharReadable firstSource = wrap("id:ID\tname:String\tbirth_date:long");
    final CharReadable secondSource = wrap("0\tThe node\t123456789");
    DataFactory dataFactory = DataFactories.data(value -> value, () -> new MultiReadable(Readables.iterator(IOFunctions.identity(), firstSource, secondSource)));
    Header.Factory headerFactory = defaultFormatNodeFileHeader();
    Extractors extractors = new Extractors(';');
    // WHEN
    CharSeeker seeker = CharSeekers.charSeeker(new MultiReadable(dataFactory.create(TABS).stream()), TABS, false);
    Header header = headerFactory.create(seeker, TABS, IdType.ACTUAL, groups);
    // THEN
    assertArrayEquals(array(entry("id", Type.ID, extractors.long_()), entry("name", Type.PROPERTY, extractors.string()), entry("birth_date", Type.PROPERTY, extractors.long_())), header.entries());
    seeker.close();
}
Also used : MultiReadable(org.neo4j.csv.reader.MultiReadable) Extractors(org.neo4j.csv.reader.Extractors) DataFactories.defaultFormatNodeFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader) DataFactories.defaultFormatRelationshipFileHeader(org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader) CharSeeker(org.neo4j.csv.reader.CharSeeker) CharReadable(org.neo4j.csv.reader.CharReadable) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 CharReadable (org.neo4j.csv.reader.CharReadable)1 CharSeeker (org.neo4j.csv.reader.CharSeeker)1 Extractors (org.neo4j.csv.reader.Extractors)1 MultiReadable (org.neo4j.csv.reader.MultiReadable)1 DataFactories.defaultFormatNodeFileHeader (org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader)1 DataFactories.defaultFormatRelationshipFileHeader (org.neo4j.internal.batchimport.input.csv.DataFactories.defaultFormatRelationshipFileHeader)1