Search in sources :

Example 46 with Result

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

the class JobEntryCopyFilesTest method fileNotCopied.

@Test
public void fileNotCopied() throws Exception {
    entry.source_filefolder = new String[] { EMPTY };
    entry.destination_filefolder = new String[] { EMPTY };
    entry.wildcard = new String[] { EMPTY };
    entry.execute(new Result(), 0);
    verify(entry, never()).processFileFolder(anyString(), anyString(), anyString(), any(Job.class), any(Result.class));
}
Also used : Job(org.pentaho.di.job.Job) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 47 with Result

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

the class JobEntryDeleteFilesTest method filesPath_AreProcessed_ArgsOfPreviousMeta.

@Test
public void filesPath_AreProcessed_ArgsOfPreviousMeta() throws Exception {
    jobEntry.setArgFromPrevious(true);
    Result prevMetaResult = new Result();
    List<RowMetaAndData> metaAndDataList = new ArrayList<>();
    metaAndDataList.add(constructRowMetaAndData(PATH_TO_FILE, null));
    prevMetaResult.setRows(metaAndDataList);
    jobEntry.execute(prevMetaResult, 0);
    verify(jobEntry, times(metaAndDataList.size())).processFile(anyString(), anyString(), any(Job.class));
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) Job(org.pentaho.di.job.Job) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 48 with Result

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

the class JobEntryDeleteFilesTest method filesWithNoPath_AreNotProcessed_ArgsOfPreviousMeta.

@Test
public void filesWithNoPath_AreNotProcessed_ArgsOfPreviousMeta() throws Exception {
    jobEntry.setArgFromPrevious(true);
    Result prevMetaResult = new Result();
    List<RowMetaAndData> metaAndDataList = new ArrayList<>();
    metaAndDataList.add(constructRowMetaAndData(Const.EMPTY_STRING, null));
    metaAndDataList.add(constructRowMetaAndData(STRING_SPACES_ONLY, null));
    prevMetaResult.setRows(metaAndDataList);
    jobEntry.execute(prevMetaResult, 0);
    verify(jobEntry, never()).processFile(anyString(), anyString(), any(Job.class));
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) Job(org.pentaho.di.job.Job) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 49 with Result

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

the class JobEntryDeleteFilesTest method filesPathVariables_AreProcessed_OnlyIfValueIsNotBlank.

@Test
public void filesPathVariables_AreProcessed_OnlyIfValueIsNotBlank() throws Exception {
    final String pathToFileBlankValue = "pathToFileBlankValue";
    final String pathToFileValidValue = "pathToFileValidValue";
    jobEntry.setVariable(pathToFileBlankValue, Const.EMPTY_STRING);
    jobEntry.setVariable(pathToFileValidValue, PATH_TO_FILE);
    jobEntry.setArguments(new String[] { asVariable(pathToFileBlankValue), asVariable(pathToFileValidValue) });
    jobEntry.setFilemasks(new String[] { null, null });
    jobEntry.setArgFromPrevious(false);
    jobEntry.execute(new Result(), 0);
    verify(jobEntry).processFile(eq(PATH_TO_FILE), anyString(), any(Job.class));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Matchers.anyString(org.mockito.Matchers.anyString) Job(org.pentaho.di.job.Job) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 50 with Result

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

the class JobEntryEvalTableContentTest method testNrErrorsFailureOldBehavior.

@Test
public void testNrErrorsFailureOldBehavior() throws Exception {
    entry.setLimit("1");
    entry.setSuccessCondition(JobEntryEvalTableContent.SUCCESS_CONDITION_ROWS_COUNT_EQUAL);
    entry.setTablename("table");
    entry.setVariable(Const.KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES, "Y");
    Result res = entry.execute(new Result(), 0);
    assertFalse("Eval number of rows should fail", res.getResult());
    assertEquals("An error should be reported in result object accoding to the old behavior", res.getNrErrors(), 1);
}
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