Search in sources :

Example 6 with CSVSchemaReader

use of eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader in project hale by halestudio.

the class CSVSchemaReaderTest method failTest.

/**
 * Test for no given property names and only 2 (of 4) given property types
 * (if there are not given 0 or maximum, in this case 4, property types we
 * expect an error)
 *
 * @throws Exception the Exception thrown if the test fails
 */
public void failTest() throws Exception {
    CSVSchemaReader schemaReader = new CSVSchemaReader();
    schemaReader.setSource(new DefaultInputSupplier(getClass().getResource("/data/test1.csv").toURI()));
    schemaReader.setParameter(CommonSchemaConstants.PARAM_TYPENAME, Value.of("TestTyp"));
    schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTY, null);
    schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTYTYPE, Value.of("java.lang.String,java.lang.String"));
    schemaReader.setParameter(CSVSchemaReader.PARAM_SEPARATOR, null);
    schemaReader.setParameter(CSVSchemaReader.PARAM_QUOTE, null);
    schemaReader.setParameter(CSVSchemaReader.PARAM_ESCAPE, null);
    IOReport report = schemaReader.execute(new LogProgressIndicator());
    assertFalse(report.getErrors().isEmpty());
    assertFalse(report.isSuccess());
}
Also used : DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) CSVSchemaReader(eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)

Example 7 with CSVSchemaReader

use of eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader in project hale by halestudio.

the class CSVSchemaReaderTest method failTest2.

/**
 * Test for no given type name. So we expect the reporter not to be
 * successful.
 *
 * @throws Exception the Exception thrown if the test fails
 */
@Test
public void failTest2() throws Exception {
    CSVSchemaReader schemaReader2 = new CSVSchemaReader();
    schemaReader2.setSource(new DefaultInputSupplier(getClass().getResource("/data/test1.csv").toURI()));
    schemaReader2.setParameter(CommonSchemaConstants.PARAM_TYPENAME, null);
    IOReport report = schemaReader2.execute(new LogProgressIndicator());
    assertFalse(report.isSuccess());
}
Also used : DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) CSVSchemaReader(eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) Test(org.junit.Test)

Aggregations

LogProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)7 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)7 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)7 CSVSchemaReader (eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader)7 Test (org.junit.Test)5 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)4 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)4