Search in sources :

Example 21 with LogMessage

use of org.apache.nifi.util.LogMessage in project kylo by Teradata.

the class TdchUtilsTest method testGetExportHiveToTeradataJobTimeTaken_ValidTimeAndFailureExitCode.

@Test
public void testGetExportHiveToTeradataJobTimeTaken_ValidTimeAndFailureExitCode() {
    TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
    MockComponentLog componentLog = runner.getLogger();
    TdchUtils tdchUtils = new TdchUtils();
    String timeTaken = tdchUtils.getExportHiveToTeradataJobTimeTaken(getTdchProcessResultWithTimeTakenAndFailureExitCode(), componentLog);
    Assert.assertEquals("Unable to determine time taken", timeTaken);
    List<LogMessage> warnMessages = componentLog.getWarnMessages();
    Assert.assertEquals(1, warnMessages.size());
    Assert.assertTrue(warnMessages.get(0).getMsg().endsWith("Skipping attempt to retrieve time taken by TDCH job"));
}
Also used : TdchUtils(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils) LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) Test(org.junit.Test)

Example 22 with LogMessage

use of org.apache.nifi.util.LogMessage in project kylo by Teradata.

the class TdchUtilsTest method testGetExportHiveToTeradataJobTimeTaken_EmptyTimeTaken.

@Test
public void testGetExportHiveToTeradataJobTimeTaken_EmptyTimeTaken() {
    TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
    MockComponentLog componentLog = runner.getLogger();
    TdchUtils tdchUtils = new TdchUtils();
    String timeTaken = tdchUtils.getExportHiveToTeradataJobTimeTaken(getTdchProcessResultWithEmptyTimeTaken(), componentLog);
    Assert.assertEquals("Unable to determine time taken", timeTaken);
    List<LogMessage> warnMessages = componentLog.getWarnMessages();
    Assert.assertEquals(1, warnMessages.size());
    Assert.assertTrue(warnMessages.get(0).getMsg().endsWith("Skipping attempt to retrieve time taken by TDCH job"));
}
Also used : TdchUtils(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils) LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) Test(org.junit.Test)

Example 23 with LogMessage

use of org.apache.nifi.util.LogMessage in project kylo by Teradata.

the class TdchUtilsTest method testGetExportHiveToTeradataOutputRecordsCount_ValidCountAndSuccessExitCode.

@Test
public void testGetExportHiveToTeradataOutputRecordsCount_ValidCountAndSuccessExitCode() {
    TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
    MockComponentLog componentLog = runner.getLogger();
    TdchUtils tdchUtils = new TdchUtils();
    long count = tdchUtils.getExportHiveToTeradataOutputRecordsCount(getTdchProcessResultWithOutputRecordCountAndSuccessExitCodeInfo(), componentLog);
    Assert.assertEquals(5, count);
    List<LogMessage> warnMessages = componentLog.getWarnMessages();
    Assert.assertEquals(0, warnMessages.size());
}
Also used : TdchUtils(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils) LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) Test(org.junit.Test)

Example 24 with LogMessage

use of org.apache.nifi.util.LogMessage in project kylo by Teradata.

the class TdchUtilsTest method testGetExportHiveToTeradataOutputRecordsCount_NoRecordCount.

@Test
public void testGetExportHiveToTeradataOutputRecordsCount_NoRecordCount() {
    TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
    MockComponentLog componentLog = runner.getLogger();
    TdchUtils tdchUtils = new TdchUtils();
    long count = tdchUtils.getExportHiveToTeradataOutputRecordsCount(getTdchProcessResultWithNoOutputRecordCountInfo(), componentLog);
    Assert.assertEquals(-1, count);
    List<LogMessage> warnMessages = componentLog.getWarnMessages();
    Assert.assertEquals(1, warnMessages.size());
    Assert.assertTrue(warnMessages.get(0).getMsg().endsWith("Skipping attempt to retrieve number of output records"));
}
Also used : TdchUtils(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils) LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) Test(org.junit.Test)

Example 25 with LogMessage

use of org.apache.nifi.util.LogMessage in project kylo by Teradata.

the class TdchUtilsTest method testGetExportHiveToTeradataJobExitCode_SuccessCode.

@Test
public void testGetExportHiveToTeradataJobExitCode_SuccessCode() {
    TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
    MockComponentLog componentLog = runner.getLogger();
    TdchUtils tdchUtils = new TdchUtils();
    long code = tdchUtils.getExportHiveToTeradataJobExitCode(getTdchProcessResultWithSuccessExitCode(), componentLog);
    Assert.assertEquals(0, code);
    List<LogMessage> warnMessages = componentLog.getWarnMessages();
    Assert.assertEquals(0, warnMessages.size());
}
Also used : TdchUtils(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils) LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) Test(org.junit.Test)

Aggregations

LogMessage (org.apache.nifi.util.LogMessage)30 Test (org.junit.Test)30 TestRunner (org.apache.nifi.util.TestRunner)29 MockComponentLog (org.apache.nifi.util.MockComponentLog)25 TdchUtils (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils)24 ProcessContext (org.apache.nifi.processor.ProcessContext)3 MockFlowFile (org.apache.nifi.util.MockFlowFile)3 TdchBuilder (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchBuilder)1