Search in sources :

Example 31 with TdchConnectionService

use of com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService in project kylo by Teradata.

the class TdchExportHiveToTeradataTest method testTeradataTruncate.

@Test
public void testTeradataTruncate() throws InitializationException {
    final TestRunner runner = TestRunners.newTestRunner(TdchExportHiveToTeradata.class);
    TdchConnectionService tdchConnectionService = new DummyTdchConnectionService();
    runner.addControllerService(CONNECTION_SERVICE_ID, tdchConnectionService);
    runner.assertValid(tdchConnectionService);
    runner.enableControllerService(tdchConnectionService);
    runner.setProperty(TdchExportHiveToTeradata.TDCH_CONNECTION_SERVICE, CONNECTION_SERVICE_ID);
    runner.setProperty(TdchExportHiveToTeradata.HIVE_DATABASE, "hive_db");
    runner.setProperty(TdchExportHiveToTeradata.HIVE_TABLE, "hive_table");
    runner.setProperty(TdchExportHiveToTeradata.TERADATA_DATABASE_TABLE, "teradata_db.teradata_table");
    runner.assertValid();
    Assert.assertEquals("false", runner.getProcessor().getPropertyDescriptor(TdchExportHiveToTeradata.TERADATA_TRUNCATE_TABLE_NAME).getDefaultValue());
    Assert.assertFalse(runner.getProcessor().getPropertyDescriptor(TdchExportHiveToTeradata.TERADATA_TRUNCATE_TABLE_NAME).isRequired());
    Assert.assertTrue(runner.getProcessor().getPropertyDescriptor(TdchExportHiveToTeradata.TERADATA_TRUNCATE_TABLE_NAME).isExpressionLanguageSupported());
    ValidationResult result = runner.setProperty(TdchExportHiveToTeradata.TERADATA_TRUNCATE_TABLE, "true");
    Assert.assertTrue(result.isValid());
    result = runner.setProperty(TdchExportHiveToTeradata.TERADATA_TRUNCATE_TABLE, "");
    Assert.assertFalse(result.isValid());
    result = runner.setProperty(TdchExportHiveToTeradata.TERADATA_TRUNCATE_TABLE, "not-boolean-value");
    Assert.assertFalse(result.isValid());
    runner.removeProperty(TdchExportHiveToTeradata.TERADATA_TRUNCATE_TABLE);
    runner.assertValid();
}
Also used : DevTdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DevTdchConnectionService) DummyTdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DummyTdchConnectionService) TdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService) TestRunner(org.apache.nifi.util.TestRunner) DummyTdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DummyTdchConnectionService) ValidationResult(org.apache.nifi.components.ValidationResult) Test(org.junit.Test)

Example 32 with TdchConnectionService

use of com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService in project kylo by Teradata.

the class StandardTdchConnectionService_Set1_Test method testPassword.

@Test
public void testPassword() throws InitializationException {
    ValidationResult validationResult;
    final TestRunner runner = TestRunners.newTestRunner(TestTdchProcessorForTestingTdchConnectionService.class);
    final TdchConnectionService standardTdchConnectionService = new DummyTdchConnectionService();
    runner.addControllerService(CONNECTION_SERVICE_ID, standardTdchConnectionService);
    runner.assertValid(standardTdchConnectionService);
    // Password
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.PASSWORD, "");
    Assert.assertEquals(StandardTdchConnectionService.PASSWORD.getDisplayName(), validationResult.getSubject());
    Assert.assertFalse(validationResult.isValid());
    runner.assertNotValid(standardTdchConnectionService);
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.PASSWORD, "mypwd");
    Assert.assertEquals(StandardTdchConnectionService.PASSWORD.getDisplayName(), validationResult.getSubject());
    Assert.assertTrue(validationResult.isValid());
    runner.assertValid(standardTdchConnectionService);
}
Also used : TdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService) TestRunner(org.apache.nifi.util.TestRunner) ValidationResult(org.apache.nifi.components.ValidationResult) Test(org.junit.Test)

Example 33 with TdchConnectionService

use of com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService in project kylo by Teradata.

the class StandardTdchConnectionService_Set1_Test method testJdbcConnectionUrl.

@Test
public void testJdbcConnectionUrl() throws InitializationException {
    ValidationResult validationResult;
    final TestRunner runner = TestRunners.newTestRunner(TestTdchProcessorForTestingTdchConnectionService.class);
    final TdchConnectionService standardTdchConnectionService = new DummyTdchConnectionService();
    runner.addControllerService(CONNECTION_SERVICE_ID, standardTdchConnectionService);
    runner.assertValid(standardTdchConnectionService);
    // JDBC Connection URL
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.JDBC_CONNECTION_URL, "");
    Assert.assertEquals(StandardTdchConnectionService.JDBC_CONNECTION_URL.getDisplayName(), validationResult.getSubject());
    Assert.assertFalse(validationResult.isValid());
    runner.assertNotValid(standardTdchConnectionService);
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.JDBC_CONNECTION_URL, StandardTdchConnectionService.DEFAULT_JDBC_CONNECTION_URL + DATABASE_SPEC_IN_CONNECTION_URL);
    Assert.assertEquals(StandardTdchConnectionService.JDBC_CONNECTION_URL.getDisplayName(), validationResult.getSubject());
    Assert.assertFalse(validationResult.isValid());
    runner.assertNotValid(standardTdchConnectionService);
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.JDBC_CONNECTION_URL, StandardTdchConnectionService.DEFAULT_JDBC_CONNECTION_URL);
    Assert.assertEquals(StandardTdchConnectionService.JDBC_CONNECTION_URL.getDisplayName(), validationResult.getSubject());
    Assert.assertTrue(validationResult.isValid());
    runner.assertValid(standardTdchConnectionService);
}
Also used : TdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService) TestRunner(org.apache.nifi.util.TestRunner) ValidationResult(org.apache.nifi.components.ValidationResult) Test(org.junit.Test)

Example 34 with TdchConnectionService

use of com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService in project kylo by Teradata.

the class AbstractTdchProcessorTest method testControllerServiceConfiguration.

@Test
public void testControllerServiceConfiguration() throws InitializationException {
    final String CONNECTION_SERVICE_ID = "tdch-conn-service";
    final TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
    final TdchConnectionService tdchConnectionService = new StandardTdchConnectionService();
    final Map<String, String> tdchConnectionServiceProperties = new HashMap<>();
    runner.addControllerService(CONNECTION_SERVICE_ID, tdchConnectionService, tdchConnectionServiceProperties);
    runner.assertValid();
    String jdbcDriverClass = runner.getControllerService(CONNECTION_SERVICE_ID).getPropertyDescriptor(StandardTdchConnectionService.JDBC_DRIVER_CLASS_NAME.getName()).getDefaultValue();
    Assert.assertEquals("com.teradata.jdbc.TeraDriver", jdbcDriverClass);
    String jdbcConnectionUrl = runner.getControllerService(CONNECTION_SERVICE_ID).getPropertyDescriptor(StandardTdchConnectionService.JDBC_CONNECTION_URL.getName()).getDefaultValue();
    Assert.assertEquals("jdbc:teradata://localhost", jdbcConnectionUrl);
    String user = runner.getControllerService(CONNECTION_SERVICE_ID).getPropertyDescriptor(StandardTdchConnectionService.USERNAME.getName()).getDefaultValue();
    Assert.assertEquals("dbc", user);
    String password = runner.getControllerService(CONNECTION_SERVICE_ID).getPropertyDescriptor(StandardTdchConnectionService.PASSWORD.getName()).getDefaultValue();
    Assert.assertNull(password);
    String tdchJarPath = runner.getControllerService(CONNECTION_SERVICE_ID).getPropertyDescriptor(StandardTdchConnectionService.TDCH_JAR_PATH.getName()).getDefaultValue();
    Assert.assertEquals("/usr/lib/tdch/1.5/lib/teradata-connector-1.5.4.jar", tdchJarPath);
    String hiveConfPath = runner.getControllerService(CONNECTION_SERVICE_ID).getPropertyDescriptor(StandardTdchConnectionService.HIVE_CONF_PATH.getName()).getDefaultValue();
    Assert.assertEquals("/usr/hdp/current/hive-client/conf", hiveConfPath);
    String hiveLibPath = runner.getControllerService(CONNECTION_SERVICE_ID).getPropertyDescriptor(StandardTdchConnectionService.HIVE_LIB_PATH.getName()).getDefaultValue();
    Assert.assertEquals("/usr/hdp/current/hive-client/lib", hiveLibPath);
}
Also used : StandardTdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.StandardTdchConnectionService) StandardTdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.StandardTdchConnectionService) TdchConnectionService(com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService) HashMap(java.util.HashMap) TestRunner(org.apache.nifi.util.TestRunner) Test(org.junit.Test)

Aggregations

TdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService)34 TestRunner (org.apache.nifi.util.TestRunner)33 Test (org.junit.Test)33 DevTdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DevTdchConnectionService)27 DummyTdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DummyTdchConnectionService)27 ValidationResult (org.apache.nifi.components.ValidationResult)23 HashMap (java.util.HashMap)8 MockFlowFile (org.apache.nifi.util.MockFlowFile)8 KerberosConfig (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.common.KerberosConfig)1 StandardTdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.StandardTdchConnectionService)1 TdchProcessResult (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.base.TdchProcessResult)1 TdchProcessRunner (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.base.TdchProcessRunner)1 TdchBuilder (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchBuilder)1 TdchUtils (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils)1 ArrayList (java.util.ArrayList)1 FlowFile (org.apache.nifi.flowfile.FlowFile)1 ComponentLog (org.apache.nifi.logging.ComponentLog)1 StopWatch (org.apache.nifi.util.StopWatch)1