Search in sources :

Example 1 with DataException

use of org.neo4j.unsafe.impl.batchimport.input.DataException in project neo4j by neo4j.

the class CsvInputTest method shouldFailOnMissingRelationshipType.

@Test
public void shouldFailOnMissingRelationshipType() throws Exception {
    // GIVEN
    String type = "CUSTOM";
    DataFactory<InputRelationship> data = data(":START_ID,:END_ID,:TYPE\n" + "0,1," + type + "\n" + "1,2,");
    Iterable<DataFactory<InputRelationship>> dataIterable = dataIterable(data);
    Input input = new CsvInput(null, null, dataIterable, defaultFormatRelationshipFileHeader(), IdType.ACTUAL, config(COMMAS), silentBadCollector(0), getRuntime().availableProcessors());
    // WHEN/THEN
    try (ResourceIterator<InputRelationship> relationships = input.relationships().iterator()) {
        try {
            assertRelationship(relationships.next(), 0L, 1L, type, NO_PROPERTIES);
            relationships.next();
            fail("Should have failed");
        } catch (DataException e) {
            assertTrue(e.getMessage().contains(Type.TYPE.name()));
        }
    }
}
Also used : DataException(org.neo4j.unsafe.impl.batchimport.input.DataException) Input(org.neo4j.unsafe.impl.batchimport.input.Input) InputRelationship(org.neo4j.unsafe.impl.batchimport.input.InputRelationship) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 DataException (org.neo4j.unsafe.impl.batchimport.input.DataException)1 Input (org.neo4j.unsafe.impl.batchimport.input.Input)1 InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)1