Search in sources :

Example 51 with Result

use of org.pentaho.di.core.Result in project pentaho-kettle by pentaho.

the class JobEntryEvalTableContentTest method testNrErrorsNoCustomSql.

@Test
public void testNrErrorsNoCustomSql() throws Exception {
    entry.setLimit("5");
    entry.setSuccessCondition(JobEntryEvalTableContent.SUCCESS_CONDITION_ROWS_COUNT_EQUAL);
    entry.setUseCustomSQL(true);
    entry.setCustomSQL(null);
    Result res = entry.execute(new Result(), 0);
    assertFalse("Eval number of rows should fail", res.getResult());
    assertEquals("Apparently there should be an error", res.getNrErrors(), 1);
    // that should work regardless of old/new behavior flag
    entry.setVariable(Const.KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES, "Y");
    res = entry.execute(new Result(), 0);
    assertFalse("Eval number of rows should fail", res.getResult());
    assertEquals("Apparently there should be an error", res.getNrErrors(), 1);
}
Also used : Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 52 with Result

use of org.pentaho.di.core.Result in project pentaho-kettle by pentaho.

the class JobEntryEvalTableContentTest method testNrErrorsFailureNewBehavior.

@Test
public void testNrErrorsFailureNewBehavior() throws Exception {
    entry.setLimit("1");
    entry.setSuccessCondition(JobEntryEvalTableContent.SUCCESS_CONDITION_ROWS_COUNT_EQUAL);
    entry.setTablename("table");
    Result res = entry.execute(new Result(), 0);
    assertFalse("Eval number of rows should fail", res.getResult());
    assertEquals("No errors should be reported in result object accoding to the new behavior", res.getNrErrors(), 0);
}
Also used : Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 53 with Result

use of org.pentaho.di.core.Result in project pentaho-kettle by pentaho.

the class JobEntryFilesExistTest method testSetNrErrorsOldBehaviorFalseResult.

@Test
public void testSetNrErrorsOldBehaviorFalseResult() throws Exception {
    // this tests backward compatibility settings for PDI-10270
    entry.setArguments(new String[] { "nonExistingFile1.ext", "nonExistingFile2.ext" });
    entry.setVariable(Const.KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES, "Y");
    Result res = entry.execute(new Result(), 0);
    assertFalse("Entry should fail", res.getResult());
    assertEquals("Files not found. Result is false. And... Number of errors should be the same as number of not found files", entry.getArguments().length, res.getNrErrors());
}
Also used : Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 54 with Result

use of org.pentaho.di.core.Result in project pentaho-kettle by pentaho.

the class JobEntryFilesExistTest method testExecuteWithException.

@Test
public void testExecuteWithException() throws Exception {
    entry.setArguments(new String[] { null });
    Result res = entry.execute(new Result(), 0);
    assertFalse("Entry should fail", res.getResult());
    assertEquals("File with wrong name was specified. One error should be reported", 1, res.getNrErrors());
}
Also used : Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 55 with Result

use of org.pentaho.di.core.Result in project pentaho-kettle by pentaho.

the class JobEntryFolderIsEmptyTest method testSetNrErrorsNewBehaviorFail.

@Test
public void testSetNrErrorsNewBehaviorFail() throws Exception {
    entry.setFoldername(nonEmptyDir);
    Result result = entry.execute(new Result(), 0);
    assertFalse("For non-empty folder result should be false", result.getResult());
    assertEquals("There should be still no errors", 0, result.getNrErrors());
}
Also used : Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Aggregations

Result (org.pentaho.di.core.Result)192 Test (org.junit.Test)75 KettleException (org.pentaho.di.core.exception.KettleException)75 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)64 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)57 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)40 FileObject (org.apache.commons.vfs2.FileObject)34 Job (org.pentaho.di.job.Job)32 IOException (java.io.IOException)24 ResultFile (org.pentaho.di.core.ResultFile)20 File (java.io.File)17 ArrayList (java.util.ArrayList)16 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)15 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)12 Pattern (java.util.regex.Pattern)10 KettleFileException (org.pentaho.di.core.exception.KettleFileException)10 Database (org.pentaho.di.core.database.Database)9 Date (java.util.Date)8 Trans (org.pentaho.di.trans.Trans)8 Matcher (java.util.regex.Matcher)7