Search in sources :

Example 91 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project kylo by Teradata.

the class StandardTdchConnectionService_Set2_Test method testHdpHiveConf_WithValidDirectory.

// checked
@Test
public void testHdpHiveConf_WithValidDirectory() throws Exception {
    ValidationResult validationResult;
    final TestRunner runner = TestRunners.newTestRunner(TestTdchProcessorForTestingTdchConnectionService.class);
    final TdchConnectionService standardTdchConnectionService = new DummyTdchConnectionService();
    runner.addControllerService(CONNECTION_SERVICE_ID, standardTdchConnectionService);
    runner.assertValid(standardTdchConnectionService);
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.HIVE_CONF_PATH, tempFolder.getRoot().getAbsolutePath());
    Assert.assertEquals(StandardTdchConnectionService.HIVE_CONF_PATH.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 92 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project kylo by Teradata.

the class StandardTdchConnectionService_Set2_Test method testHiveLib.

// checked
private void testHiveLib(String expectedTdchLibraryJarsPath) throws Exception {
    List<String> paths = Arrays.stream(expectedTdchLibraryJarsPath.split(",")).map(String::trim).collect(Collectors.toList());
    StandardTdchConnectionService mockedStandardTdchConnectionService = Mockito.mock(StandardTdchConnectionService.class);
    Mockito.when(mockedStandardTdchConnectionService.getIdentifier()).thenReturn(CONNECTION_SERVICE_ID);
    ValidationResult validationResult;
    final TestRunner runner = TestRunners.newTestRunner(TestTdchProcessorForTestingTdchConnectionService.class);
    runner.addControllerService(CONNECTION_SERVICE_ID, mockedStandardTdchConnectionService);
    runner.setProperty(mockedStandardTdchConnectionService, StandardTdchConnectionService.PASSWORD, "mydbpwd");
    for (int i = 0; i < paths.size(); i++) {
        final File currentFolder = tempFolder.newFolder(Integer.toString(i));
        setupMockPaths(paths.subList(0, i), currentFolder);
        validationResult = runner.setProperty(mockedStandardTdchConnectionService, StandardTdchConnectionService.HIVE_LIB_PATH, currentFolder.getAbsolutePath());
        if (i < paths.size() - 1) {
            Assert.assertFalse(validationResult.isValid());
            switch(i) {
                case 0:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_AVRO_IDENTIFIER));
                    break;
                case 1:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_ANTLR_IDENTIFIER));
                    break;
                case 2:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_ANTLR_RUNTIME_IDENTIFIER));
                    break;
                case 3:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_COMMONS_DBCP_IDENTIFIER));
                    break;
                case 4:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_COMMONS_POOL_IDENTIFIER));
                    break;
                case 5:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_DATANUCLEUS_API_JDO_IDENTIFIER));
                    break;
                case 6:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_DATANUCLEUS_CORE_IDENTIFIER));
                    break;
                case 7:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_DATANUCLEUS_RDBMS_IDENTIFIER));
                    break;
                case 8:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_HIVE_CLI_IDENTIFIER));
                    break;
                case 9:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_HIVE_EXEC_IDENTIFIER));
                    break;
                case 10:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_STANDALONE_IDENTIFIER));
                    break;
                case 11:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_HIVE_METASTORE_IDENTIFIER));
                    break;
                case 12:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_JDO_API_IDENTIFIER));
                    break;
                case 13:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_LIBFB303_IDENTIFIER));
                    break;
                case 14:
                    Assert.assertTrue(validationResult.getExplanation().contains(StandardTdchConnectionService.HIVE_DEPENDENCY_LIBTHRIFT_IDENTIFIER));
                    break;
                default:
                    Assert.fail("More paths than expected");
                    break;
            }
        } else {
            Assert.assertEquals(15, i);
            Assert.assertTrue(validationResult.isValid());
        }
    }
}
Also used : TestRunner(org.apache.nifi.util.TestRunner) ValidationResult(org.apache.nifi.components.ValidationResult) File(java.io.File)

Example 93 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project kylo by Teradata.

the class StandardTdchConnectionService_Set2_Test method testTdchJarPath.

// checked
@Test
public void testTdchJarPath() throws Exception {
    StandardTdchConnectionService mockedStandardTdchConnectionService = Mockito.mock(StandardTdchConnectionService.class);
    Mockito.when(mockedStandardTdchConnectionService.getIdentifier()).thenReturn(CONNECTION_SERVICE_ID);
    ValidationResult validationResult;
    final TestRunner runner = TestRunners.newTestRunner(TestTdchProcessorForTestingTdchConnectionService.class);
    runner.addControllerService(CONNECTION_SERVICE_ID, mockedStandardTdchConnectionService);
    runner.setProperty(mockedStandardTdchConnectionService, StandardTdchConnectionService.PASSWORD, "mydbpwd");
    validationResult = runner.setProperty(mockedStandardTdchConnectionService, StandardTdchConnectionService.TDCH_JAR_PATH, tempFolder.newFile("teradata-fail.jar").getAbsolutePath());
    Assert.assertEquals(StandardTdchConnectionService.TDCH_JAR_PATH.getDisplayName(), validationResult.getSubject());
    Assert.assertFalse(validationResult.isValid());
    validationResult = runner.setProperty(mockedStandardTdchConnectionService, StandardTdchConnectionService.TDCH_JAR_PATH, tempFolder.newFile("teradata-connector-1.4.jar").getAbsolutePath());
    Assert.assertEquals(StandardTdchConnectionService.TDCH_JAR_PATH.getDisplayName(), validationResult.getSubject());
    Assert.assertTrue(validationResult.isValid());
    validationResult = runner.setProperty(mockedStandardTdchConnectionService, StandardTdchConnectionService.TDCH_JAR_PATH, tempFolder.getRoot().getAbsolutePath());
    Assert.assertEquals(StandardTdchConnectionService.TDCH_JAR_PATH.getDisplayName(), validationResult.getSubject());
    Assert.assertFalse(validationResult.isValid());
    validationResult = runner.setProperty(mockedStandardTdchConnectionService, StandardTdchConnectionService.TDCH_JAR_PATH, tempFolder.newFile("teradata-connector-1.5.jar").getAbsolutePath());
    Assert.assertEquals(StandardTdchConnectionService.TDCH_JAR_PATH.getDisplayName(), validationResult.getSubject());
    Assert.assertTrue(validationResult.isValid());
    validationResult = runner.setProperty(mockedStandardTdchConnectionService, StandardTdchConnectionService.TDCH_JAR_PATH, tempFolder.newFile("my-teradata-connector.jar").getAbsolutePath());
    Assert.assertEquals(StandardTdchConnectionService.TDCH_JAR_PATH.getDisplayName(), validationResult.getSubject());
    Assert.assertFalse(validationResult.isValid());
}
Also used : TestRunner(org.apache.nifi.util.TestRunner) ValidationResult(org.apache.nifi.components.ValidationResult) Test(org.junit.Test)

Example 94 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project kylo by Teradata.

the class StandardTdchConnectionService_Set1_Test method testJdbcDriverClass.

@Test
public void testJdbcDriverClass() 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 Driver Class
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.JDBC_DRIVER_CLASS_NAME, "");
    Assert.assertEquals(StandardTdchConnectionService.JDBC_DRIVER_CLASS_NAME.getDisplayName(), validationResult.getSubject());
    Assert.assertFalse(validationResult.isValid());
    runner.assertNotValid(standardTdchConnectionService);
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.JDBC_DRIVER_CLASS_NAME, StandardTdchConnectionService.DEFAULT_JDBC_DRIVER_CLASS);
    Assert.assertEquals(StandardTdchConnectionService.JDBC_DRIVER_CLASS_NAME.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 95 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project kylo by Teradata.

the class StandardTdchConnectionService_Set1_Test method testUsername.

@Test
public void testUsername() 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);
    // Username
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.USERNAME, "");
    Assert.assertEquals(StandardTdchConnectionService.USERNAME.getDisplayName(), validationResult.getSubject());
    Assert.assertFalse(validationResult.isValid());
    runner.assertNotValid(standardTdchConnectionService);
    validationResult = runner.setProperty(standardTdchConnectionService, StandardTdchConnectionService.USERNAME, StandardTdchConnectionService.DEFAULT_USERNAME);
    Assert.assertEquals(StandardTdchConnectionService.USERNAME.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)

Aggregations

ValidationResult (org.apache.nifi.components.ValidationResult)179 Test (org.junit.Test)80 ArrayList (java.util.ArrayList)64 TestRunner (org.apache.nifi.util.TestRunner)46 ValidationContext (org.apache.nifi.components.ValidationContext)37 MockProcessContext (org.apache.nifi.util.MockProcessContext)26 TdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService)23 Validator (org.apache.nifi.components.Validator)21 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)20 DevTdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DevTdchConnectionService)18 DummyTdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DummyTdchConnectionService)18 HashSet (java.util.HashSet)18 ProcessContext (org.apache.nifi.processor.ProcessContext)15 File (java.io.File)12 HashMap (java.util.HashMap)12 Collection (java.util.Collection)11 SSLContextService (org.apache.nifi.ssl.SSLContextService)11 Map (java.util.Map)10 List (java.util.List)9 ComponentLog (org.apache.nifi.logging.ComponentLog)9