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