Search in sources :

Example 61 with Result

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

the class JobEntrySetVariablesTest method testASCIIText.

@Test
public void testASCIIText() throws Exception {
    // properties file with native2ascii
    entry.setFilename("src/test/resources/org/pentaho/di/job/entries/setvariables/ASCIIText.properties");
    // For absence of null check in execute method
    entry.setVariableName(new String[] {});
    entry.setReplaceVars(true);
    Result result = entry.execute(new Result(), 0);
    assertTrue("Result should be true", result.getResult());
    assertEquals("日本語", entry.getVariable("Japanese"));
    assertEquals("English", entry.getVariable("English"));
    assertEquals("中文", entry.getVariable("Chinese"));
}
Also used : Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 62 with Result

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

the class JobEntrySetVariablesTest method testVariableTypeCurrentJob.

@Test
public void testVariableTypeCurrentJob() throws Exception {
    entry.setFilename("src/test/resources/org/pentaho/di/job/entries/setvariables/UTF8Text.properties");
    entry.setVariableName(new String[] {});
    entry.setReplaceVars(true);
    entry.setFileVariableType(JobEntrySetVariables.VARIABLE_TYPE_CURRENT_JOB);
    Result result = entry.execute(new Result(), 0);
    for (JobEntryListener jobEntryListener : job.getJobEntryListeners()) {
        jobEntryListener.beforeExecution(job, null, entry);
    }
    Assert.assertTrue(result.getResult());
    Assert.assertNull(entry.getVariable("Japanese"));
    Assert.assertNull(entry.getVariable("English"));
    Assert.assertNull(entry.getVariable("Chinese"));
}
Also used : JobEntryListener(org.pentaho.di.job.JobEntryListener) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 63 with Result

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

the class JobEntrySetVariablesTest method testUTF8Text.

@Test
public void testUTF8Text() throws Exception {
    // properties files without native2ascii
    entry.setFilename("src/test/resources/org/pentaho/di/job/entries/setvariables/UTF8Text.properties");
    // For absence of null check in execute method
    entry.setVariableName(new String[] {});
    entry.setReplaceVars(true);
    Result result = entry.execute(new Result(), 0);
    assertTrue("Result should be true", result.getResult());
    assertEquals("日本語", entry.getVariable("Japanese"));
    assertEquals("English", entry.getVariable("English"));
    assertEquals("中文", entry.getVariable("Chinese"));
}
Also used : Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 64 with Result

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

the class JobEntryColumnsExistTest method jobFail_columnNotExist.

@Test
public void jobFail_columnNotExist() throws KettleException {
    doReturn(db).when(jobEntry).getNewDatabaseFromMeta();
    doNothing().when(db).connect(anyString(), anyString());
    doReturn(true).when(db).checkTableExists(anyString());
    doReturn(false).when(db).checkColumnExists(anyString(), anyString());
    final Result result = jobEntry.execute(new Result(), 0);
    assertEquals("Should be some errors", 1, result.getNrErrors());
    assertFalse("Result should be false", result.getResult());
    verify(db, atLeastOnce()).disconnect();
}
Also used : Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 65 with Result

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

the class JobEntryColumnsExistTest method jobSuccess.

@Test
public void jobSuccess() throws KettleException {
    doReturn(db).when(jobEntry).getNewDatabaseFromMeta();
    doNothing().when(db).connect(anyString(), anyString());
    doReturn(true).when(db).checkColumnExists(anyString(), anyString());
    doReturn(true).when(db).checkTableExistsByDbMeta(anyString(), anyString());
    final Result result = jobEntry.execute(new Result(), 0);
    assertEquals("Should be no error", 0, result.getNrErrors());
    assertTrue("Result should be true", result.getResult());
    assertEquals("Lines written", COLUMNS.length, result.getNrLinesWritten());
    verify(db, atLeastOnce()).disconnect();
}
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