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);
}
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());
}
}
}
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());
}
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);
}
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);
}
Aggregations