use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.
the class DataFactoriesTest method shouldParseNodeArrayTypesHeaderCorrectly.
@Test
public void shouldParseNodeArrayTypesHeaderCorrectly() throws Exception {
// GIVEN
CharSeeker seeker = seeker("ID:ID,longArray:long[],pointArray:Point[]{crs:WGS-84},timeArray:time[]{timezone:+02:00}," + "dateTimeArray:datetime[]{timezone:+02:00}");
IdType idType = IdType.STRING;
Extractors extractors = new Extractors(',');
// WHEN
Header header = defaultFormatNodeFileHeader().create(seeker, COMMAS, idType, groups);
// THEN
assertArrayEquals(array(entry("ID", Type.ID, CsvInput.idExtractor(idType, extractors)), entry("longArray", Type.PROPERTY, extractors.longArray()), entry("pointArray", Type.PROPERTY, extractors.pointArray(), PointValue.parseHeaderInformation("{crs:WGS-84}")), entry("timeArray", Type.PROPERTY, extractors.timeArray(), TimeValue.parseHeaderInformation("{timezone:+02:00}")), entry("dateTimeArray", Type.PROPERTY, extractors.dateTimeArray(), DateTimeValue.parseHeaderInformation("{timezone:+02:00}"))), header.entries());
seeker.close();
}
use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.
the class DataFactoriesTest method shouldFailForDuplicatePropertyHeaderEntries.
@Test
public void shouldFailForDuplicatePropertyHeaderEntries() throws Exception {
// GIVEN
CharSeeker seeker = seeker("one:id\tname\tname:long");
IdType idType = IdType.ACTUAL;
Extractors extractors = new Extractors('\t');
// WHEN
try {
DataFactories.defaultFormatNodeFileHeader().create(seeker, TABS, idType);
fail("Should fail");
} catch (DuplicateHeaderException e) {
assertEquals(entry("name", Type.PROPERTY, extractors.string()), e.getFirst());
assertEquals(entry("name", Type.PROPERTY, extractors.long_()), e.getOther());
}
seeker.close();
}
use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.
the class DataFactoriesTest method shouldFailForDuplicateIdHeaderEntries.
@Test
public void shouldFailForDuplicateIdHeaderEntries() throws Exception {
// GIVEN
CharSeeker seeker = seeker("one:id\ttwo:id");
IdType idType = IdType.ACTUAL;
Extractors extractors = new Extractors('\t');
// WHEN
try {
DataFactories.defaultFormatNodeFileHeader().create(seeker, TABS, idType);
fail("Should fail");
} catch (DuplicateHeaderException e) {
assertEquals(entry("one", Type.ID, extractors.long_()), e.getFirst());
assertEquals(entry("two", Type.ID, extractors.long_()), e.getOther());
}
seeker.close();
}
use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.
the class DataFactoriesTest method shouldParseHeaderFromFirstLineOfFirstInputFile.
@Test
public void shouldParseHeaderFromFirstLineOfFirstInputFile() throws Exception {
// GIVEN
final Reader firstSource = new StringReader("id:ID\tname:String\tbirth_date:long");
final Reader secondSource = new StringReader("0\tThe node\t123456789");
DataFactory<InputNode> dataFactory = data(value -> value, () -> {
try {
return sources(firstSource, secondSource);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
Header.Factory headerFactory = defaultFormatNodeFileHeader();
Extractors extractors = new Extractors(';');
// WHEN
CharSeeker seeker = CharSeekers.charSeeker(dataFactory.create(TABS).stream(), TABS, false);
Header header = headerFactory.create(seeker, TABS, IdType.ACTUAL);
// 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();
}
use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.
the class DataFactoriesTest method shouldParseDefaultRelationshipFileHeaderCorrectly.
@Test
public void shouldParseDefaultRelationshipFileHeaderCorrectly() throws Exception {
// GIVEN
CharSeeker seeker = seeker(":START_ID\t:END_ID\ttype:TYPE\tdate:long\tmore:long[]");
IdType idType = IdType.ACTUAL;
Extractors extractors = new Extractors('\t');
// WHEN
Header header = DataFactories.defaultFormatRelationshipFileHeader().create(seeker, TABS, idType);
// THEN
assertArrayEquals(array(entry(null, Type.START_ID, idType.extractor(extractors)), entry(null, Type.END_ID, idType.extractor(extractors)), entry("type", Type.TYPE, extractors.string()), entry("date", Type.PROPERTY, extractors.long_()), entry("more", Type.PROPERTY, extractors.longArray())), header.entries());
seeker.close();
}
Aggregations