Search in sources :

Example 1 with DuplicateHeaderException

use of org.neo4j.unsafe.impl.batchimport.input.DuplicateHeaderException 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();
}
Also used : Extractors(org.neo4j.csv.reader.Extractors) CharSeeker(org.neo4j.csv.reader.CharSeeker) DuplicateHeaderException(org.neo4j.unsafe.impl.batchimport.input.DuplicateHeaderException) Test(org.junit.Test)

Example 2 with DuplicateHeaderException

use of org.neo4j.unsafe.impl.batchimport.input.DuplicateHeaderException 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();
}
Also used : Extractors(org.neo4j.csv.reader.Extractors) CharSeeker(org.neo4j.csv.reader.CharSeeker) DuplicateHeaderException(org.neo4j.unsafe.impl.batchimport.input.DuplicateHeaderException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 CharSeeker (org.neo4j.csv.reader.CharSeeker)2 Extractors (org.neo4j.csv.reader.Extractors)2 DuplicateHeaderException (org.neo4j.unsafe.impl.batchimport.input.DuplicateHeaderException)2