Search in sources :

Example 26 with MockFailureCollector

use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.

the class FTPBatchSourceTest method testFTPPathWithoutSpecialCharactersInAuth.

@Test
public void testFTPPathWithoutSpecialCharactersInAuth() {
    FailureCollector collector = new MockFailureCollector();
    FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
    config.configuration(String.format("%s://%s:%s@%s:%d%s", FTP_PREFIX, USER, PASSWORD_WITHOUT_SPECIAL_CHARACTERS, HOST, FTP_DEFAULT_PORT, PATH), null);
    config.validate(collector);
    Assert.assertEquals(config.getPathFromConfig(), config.getPath());
    Assert.assertEquals(0, config.getFileSystemProperties(collector).size());
}
Also used : MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 27 with MockFailureCollector

use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.

the class FTPBatchSourceTest method testFTPWithFileSystemProperties.

@Test
public void testFTPWithFileSystemProperties() {
    FailureCollector collector = new MockFailureCollector();
    FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
    config.configuration(String.format("%s://%s:%s@%s:%d%s", FTP_PREFIX, USER, PASSWORD_WITHOUT_SPECIAL_CHARACTERS, HOST, FTP_DEFAULT_PORT, PATH), "{\"fs.sftp.impl\": \"org.apache.hadoop.fs.sftp.SFTPFileSystem\"}");
    config.validate(collector);
    Assert.assertEquals(config.getPathFromConfig(), config.getPath());
    Assert.assertEquals(1, config.getFileSystemProperties(collector).size());
    Assert.assertEquals(SFTP_FS_CLASS, config.getFileSystemProperties(collector).get(FS_SFTP_IMPL));
}
Also used : MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 28 with MockFailureCollector

use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.

the class FTPBatchSourceTest method testMissingAuthInPath.

@Test
public void testMissingAuthInPath() {
    FailureCollector collector = new MockFailureCollector();
    FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
    config.configuration(String.format("%s://%s:%d%s", FTP_PREFIX, HOST, FTP_DEFAULT_PORT, PATH), null);
    try {
        config.validate(collector);
        Assert.fail();
    } catch (ValidationException e) {
        Assert.assertEquals(1, e.getFailures().size());
        Assert.assertEquals(String.format("Missing authentication in url: %s.", config.getPathFromConfig()), e.getFailures().get(0).getMessage());
    }
}
Also used : ValidationException(io.cdap.cdap.etl.api.validation.ValidationException) MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 29 with MockFailureCollector

use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.

the class FTPBatchSourceTest method testSFTPPathWithSpecialCharactersInAuth.

@Test
public void testSFTPPathWithSpecialCharactersInAuth() {
    FailureCollector collector = new MockFailureCollector();
    FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
    final HashMap<String, String> fileSystemProperties = new HashMap<>();
    config.configuration(String.format("%s://%s:%s@%s:%d%s", SFTP_PREFIX, USER, PASSWORD_WITH_SPECIAL_CHARACTERS, HOST, SFTP_DEFAULT_PORT, PATH), null);
    config.validate(collector);
    fileSystemProperties.put("fs.sftp.host", HOST);
    fileSystemProperties.put(String.format("fs.sftp.user.%s", HOST), USER);
    fileSystemProperties.put(String.format("fs.sftp.password.%s.%s", HOST, USER), PASSWORD_WITH_SPECIAL_CHARACTERS);
    fileSystemProperties.put("fs.sftp.host.port", String.valueOf(SFTP_DEFAULT_PORT));
    Assert.assertEquals(fileSystemProperties, config.getFileSystemProperties(collector));
}
Also used : HashMap(java.util.HashMap) MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 30 with MockFailureCollector

use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.

the class FTPBatchSourceTest method testSFTPPathWithSystemPropertiesAndSpecialCharactersInAuth.

@Test
public void testSFTPPathWithSystemPropertiesAndSpecialCharactersInAuth() {
    FailureCollector collector = new MockFailureCollector();
    FTPBatchSource.FTPBatchSourceConfig config = new FTPBatchSource.FTPBatchSourceConfig();
    final HashMap<String, String> fileSystemProperties = new HashMap<>();
    config.configuration(String.format("%s://%s:%s@%s:%d%s", SFTP_PREFIX, USER, PASSWORD_WITH_SPECIAL_CHARACTERS, HOST, SFTP_DEFAULT_PORT, PATH), "{\"fs.sftp.impl\": \"org.apache.hadoop.fs.sftp.SFTPFileSystem\"}");
    config.validate(collector);
    fileSystemProperties.put("fs.sftp.host", HOST);
    fileSystemProperties.put(String.format("fs.sftp.user.%s", HOST), USER);
    fileSystemProperties.put(String.format("fs.sftp.password.%s.%s", HOST, USER), PASSWORD_WITH_SPECIAL_CHARACTERS);
    fileSystemProperties.put("fs.sftp.host.port", String.valueOf(SFTP_DEFAULT_PORT));
    fileSystemProperties.put(FS_SFTP_IMPL, SFTP_FS_CLASS);
    Assert.assertEquals(5, config.getFileSystemProperties(collector).size());
    Assert.assertEquals(fileSystemProperties, config.getFileSystemProperties(collector));
}
Also used : HashMap(java.util.HashMap) MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) MockFailureCollector(io.cdap.cdap.etl.mock.validation.MockFailureCollector) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Aggregations

MockFailureCollector (io.cdap.cdap.etl.mock.validation.MockFailureCollector)36 Test (org.junit.Test)36 FailureCollector (io.cdap.cdap.etl.api.FailureCollector)31 Schema (io.cdap.cdap.api.data.schema.Schema)11 AutoJoinerContext (io.cdap.cdap.etl.api.join.AutoJoinerContext)11 HashMap (java.util.HashMap)10 ValidationException (io.cdap.cdap.etl.api.validation.ValidationException)9 Cause (io.cdap.cdap.etl.api.validation.ValidationFailure.Cause)9 JoinDefinition (io.cdap.cdap.etl.api.join.JoinDefinition)6 JoinStage (io.cdap.cdap.etl.api.join.JoinStage)5 ValidationFailure (io.cdap.cdap.etl.api.validation.ValidationFailure)5 JoinField (io.cdap.cdap.etl.api.join.JoinField)2 AbstractFileSourceConfig (io.cdap.plugin.format.plugin.AbstractFileSourceConfig)2 List (java.util.List)2 StructuredRecord (io.cdap.cdap.api.data.format.StructuredRecord)1 JoinCondition (io.cdap.cdap.etl.api.join.JoinCondition)1 MockPipelineConfigurer (io.cdap.cdap.etl.mock.common.MockPipelineConfigurer)1