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');
var e = assertThrows(DuplicateHeaderException.class, () -> defaultFormatNodeFileHeader().create(seeker, TABS, idType, groups));
assertEquals(entry("one", Type.ID, extractors.long_()), e.getFirst());
assertEquals(entry("two", Type.ID, extractors.long_()), e.getOther());
}
use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.
the class DataFactoriesTest method shouldParseDefaultNodeFileHeaderCorrectly.
@Test
public void shouldParseDefaultNodeFileHeaderCorrectly() throws Exception {
// GIVEN
CharSeeker seeker = seeker("ID:ID,label-one:label,also-labels:LABEL,name,age:long,location:Point{crs:WGS-84}");
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("label-one", Type.LABEL, extractors.stringArray()), entry("also-labels", Type.LABEL, extractors.stringArray()), entry("name", Type.PROPERTY, extractors.string()), entry("age", Type.PROPERTY, extractors.long_()), entry("location", Type.PROPERTY, extractors.point(), PointValue.parseHeaderInformation("{crs:WGS-84}"))), header.entries());
seeker.close();
}
use of org.neo4j.csv.reader.Extractors in project neo4j by neo4j.
the class DataFactoriesTest method shouldAllowMissingIdHeaderEntry.
@Test
public void shouldAllowMissingIdHeaderEntry() throws Exception {
// GIVEN
CharSeeker seeker = seeker("one\ttwo");
Extractors extractors = new Extractors(';');
// WHEN
Header header = defaultFormatNodeFileHeader().create(seeker, TABS, IdType.ACTUAL, groups);
// THEN
assertArrayEquals(array(entry("one", Type.PROPERTY, extractors.string()), entry("two", Type.PROPERTY, extractors.string())), header.entries());
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 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();
}
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');
var e = assertThrows(DuplicateHeaderException.class, () -> defaultFormatNodeFileHeader().create(seeker, TABS, idType, groups));
assertEquals(entry("name", Type.PROPERTY, extractors.string()), e.getFirst());
assertEquals(entry("name", Type.PROPERTY, extractors.long_()), e.getOther());
seeker.close();
}
Aggregations