Search in sources :

Example 11 with InputException

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

the class ParallelInputEntityDeserializer method close.

@Override
public void close() {
    processing.close();
    try {
        decorator.close();
        source.close();
    } catch (IOException e) {
        throw new InputException("Couldn't close source of data chunks", e);
    } finally {
        super.close();
    }
}
Also used : InputException(org.neo4j.unsafe.impl.batchimport.input.InputException) IOException(java.io.IOException)

Example 12 with InputException

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

the class ImportToolTest method shouldFailIfHeaderHasLessColumnsThanData.

@Test
public void shouldFailIfHeaderHasLessColumnsThanData() throws Exception {
    // GIVEN
    List<String> nodeIds = nodeIds();
    Configuration config = Configuration.TABS;
    // WHEN data file contains more columns than header file
    int extraColumns = 3;
    try {
        importTool("--into", dbRule.getStoreDirAbsolutePath(), "--delimiter", "TAB", "--array-delimiter", String.valueOf(config.arrayDelimiter()), "--nodes", nodeHeader(config).getAbsolutePath() + MULTI_FILE_DELIMITER + nodeData(false, config, nodeIds, TRUE, Charset.defaultCharset(), extraColumns).getAbsolutePath(), "--relationships", relationshipHeader(config).getAbsolutePath() + MULTI_FILE_DELIMITER + relationshipData(false, config, nodeIds, TRUE, true).getAbsolutePath());
        fail("Should have thrown exception");
    } catch (InputException e) {
        // THEN
        assertFalse(suppressOutput.getErrorVoice().containsMessage(e.getClass().getName()));
        assertTrue(e.getMessage().contains("Extra column not present in header on line"));
    }
}
Also used : Configuration(org.neo4j.unsafe.impl.batchimport.input.csv.Configuration) InputException(org.neo4j.unsafe.impl.batchimport.input.InputException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 13 with InputException

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

the class DataFactoriesTest method shouldFailOnUnexpectedNodeHeaderType.

@Test
public void shouldFailOnUnexpectedNodeHeaderType() throws Exception {
    // GIVEN
    CharSeeker seeker = seeker(":ID,:START_ID");
    IdType idType = IdType.ACTUAL;
    // WHEN
    try {
        Header header = DataFactories.defaultFormatNodeFileHeader().create(seeker, COMMAS, idType);
        fail("Should have failed");
    } catch (InputException e) {
        // THEN
        assertThat(e.getMessage(), containsString("START_ID"));
    }
}
Also used : CharSeeker(org.neo4j.csv.reader.CharSeeker) DataFactories.defaultFormatNodeFileHeader(org.neo4j.unsafe.impl.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader) InputException(org.neo4j.unsafe.impl.batchimport.input.InputException) Test(org.junit.Test)

Aggregations

InputException (org.neo4j.unsafe.impl.batchimport.input.InputException)13 Test (org.junit.Test)9 IOException (java.io.IOException)4 Input (org.neo4j.unsafe.impl.batchimport.input.Input)4 UnexpectedEndOfInputException (org.neo4j.unsafe.impl.batchimport.input.UnexpectedEndOfInputException)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 CharSeeker (org.neo4j.csv.reader.CharSeeker)2 InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)2 Configuration (org.neo4j.unsafe.impl.batchimport.input.csv.Configuration)2 DataFactories.defaultFormatNodeFileHeader (org.neo4j.unsafe.impl.batchimport.input.csv.DataFactories.defaultFormatNodeFileHeader)2 File (java.io.File)1 DataAfterQuoteException (org.neo4j.csv.reader.DataAfterQuoteException)1 Extractors (org.neo4j.csv.reader.Extractors)1 BadCollector (org.neo4j.unsafe.impl.batchimport.input.BadCollector)1 InputNode (org.neo4j.unsafe.impl.batchimport.input.InputNode)1 CsvInput (org.neo4j.unsafe.impl.batchimport.input.csv.CsvInput)1 DataFactory (org.neo4j.unsafe.impl.batchimport.input.csv.DataFactory)1