use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FileBatchSourceTest method testDelimitedFormatsInValidSchema.
@Test
public void testDelimitedFormatsInValidSchema() throws Exception {
FileSourceConfig config = new FileSourceConfig();
FailureCollector collector = new MockFailureCollector();
FieldSetter.setField(config, AbstractFileSourceConfig.class.getDeclaredField("referenceName"), "ref");
FieldSetter.setField(config, AbstractFileSourceConfig.class.getDeclaredField("format"), "delimited");
FieldSetter.setField(config, AbstractFileSourceConfig.class.getDeclaredField("schema"), RECORD_SCHEMA_INVALID_DATE.toString());
FieldSetter.setField(config, FileSourceConfig.class.getDeclaredField("path"), "path");
config.validate(collector);
Assert.assertEquals(1, collector.getValidationFailures().size());
List<ValidationFailure.Cause> failureCauses = collector.getValidationFailures().get(0).getCauses();
Assert.assertEquals(2, failureCauses.size());
Assert.assertEquals("format", failureCauses.get(0).getAttribute("stageConfig"));
Assert.assertEquals("date", failureCauses.get(1).getAttribute("outputField"));
Assert.assertEquals("Type 'date' in schema is not supported for 'delimited' format.", collector.getValidationFailures().get(0).getMessage());
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FTPBatchSourceTest method testFTPPathWithSpecialCharactersInAuth.
@Test
public void testFTPPathWithSpecialCharactersInAuth() {
FailureCollector collector = new MockFailureCollector();
FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
config.configuration(String.format("%s://%s:%s@%s:%d%s", FTP_PREFIX, USER, PASSWORD_WITH_SPECIAL_CHARACTERS, HOST, FTP_DEFAULT_PORT, PATH), null);
config.validate(collector);
final HashMap<String, String> fileSystemProperties = new HashMap<>();
fileSystemProperties.put("fs.ftp.host", HOST);
fileSystemProperties.put(String.format("fs.ftp.user.%s", HOST), USER);
fileSystemProperties.put(String.format("fs.ftp.password.%s", HOST), PASSWORD_WITH_SPECIAL_CHARACTERS);
fileSystemProperties.put("fs.ftp.host.port", String.valueOf(FTP_DEFAULT_PORT));
Assert.assertEquals(fileSystemProperties, config.getFileSystemProperties(collector));
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FTPBatchSourceTest method testSFTPPathWithoutSpecialCharactersInAuth.
@Test
public void testSFTPPathWithoutSpecialCharactersInAuth() {
FailureCollector collector = new MockFailureCollector();
FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
config.configuration(String.format("%s://%s:%s@%s:%d%s", SFTP_PREFIX, USER, PASSWORD_WITHOUT_SPECIAL_CHARACTERS, HOST, SFTP_DEFAULT_PORT, PATH), null);
config.validate(collector);
Assert.assertEquals(config.getPathFromConfig(), config.getPath());
Assert.assertEquals(0, config.getFileSystemProperties(collector).size());
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class XMLReaderConfigTest method testEmptyTargetFolder.
@Test
public void testEmptyTargetFolder() {
XMLReaderBatchSource.XMLReaderConfig config = new XMLReaderBatchSource.XMLReaderConfig("emptyTargetFolderReference", "/opt/hdfs/catalog.xml", null, "/catalog/book/", "Move", "", "No", "XMLTrackingTable", 30, "/tmp");
FailureCollector collector = new MockFailureCollector();
config.validate(collector);
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(1, collector.getValidationFailures().get(0).getCauses().size());
Cause expectedCause = new Cause();
expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, XMLReaderBatchSource.XMLReaderConfig.TARGET_FOLDER);
Assert.assertEquals(expectedCause, collector.getValidationFailures().get(0).getCauses().get(0));
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class XMLReaderConfigTest method testEmptyPath.
@Test
public void testEmptyPath() {
XMLReaderBatchSource.XMLReaderConfig config = new XMLReaderBatchSource.XMLReaderConfig("emptyPathReference", "", null, "/catalog/book/", null, null, "Yes", "XMLTrackingTable", 30, "/tmp");
FailureCollector collector = new MockFailureCollector();
config.validate(collector);
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(1, collector.getValidationFailures().get(0).getCauses().size());
Cause expectedCause = new Cause();
expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, XMLReaderBatchSource.XMLReaderConfig.PATH);
Assert.assertEquals(expectedCause, collector.getValidationFailures().get(0).getCauses().get(0));
}
Aggregations