use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobEntryCopyFilesTest method setUp.
@Before
public void setUp() {
entry = new JobEntryCopyFiles();
Job parentJob = new Job();
entry.setParentJob(parentJob);
JobMeta mockJobMeta = mock(JobMeta.class);
mockNamedClusterEmbedManager = mock(NamedClusterEmbedManager.class);
when(mockJobMeta.getNamedClusterEmbedManager()).thenReturn(mockNamedClusterEmbedManager);
entry.setParentJobMeta(mockJobMeta);
entry = spy(entry);
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobEntryDeleteFilesTest method setUp.
@Before
public void setUp() throws Exception {
jobEntry = new JobEntryDeleteFiles();
Job parentJob = mock(Job.class);
doReturn(false).when(parentJob).isStopped();
jobEntry.setParentJob(parentJob);
JobMeta mockJobMeta = mock(JobMeta.class);
mockNamedClusterEmbedManager = mock(NamedClusterEmbedManager.class);
when(mockJobMeta.getNamedClusterEmbedManager()).thenReturn(mockNamedClusterEmbedManager);
jobEntry.setParentJobMeta(mockJobMeta);
jobEntry = spy(jobEntry);
doReturn(true).when(jobEntry).processFile(anyString(), anyString(), eq(parentJob));
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobEntryEvalTableContentTest method setUp.
@Before
public void setUp() throws Exception {
MockDriver.registerInstance();
Job job = new Job(null, new JobMeta());
entry = new JobEntryEvalTableContent();
job.getJobMeta().addJobEntry(new JobEntryCopy(entry));
entry.setParentJob(job);
job.setStopped(false);
DatabaseMeta dbMeta = new DatabaseMeta();
dbMeta.setDatabaseType("mock-db");
entry.setDatabase(dbMeta);
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobEntryHTTP_PDI208_Test method testHTTPResultDefaultRows.
@Test
public void testHTTPResultDefaultRows() throws IOException {
File localFileForUpload = getInputFile("existingFile1", ".tmp");
File tempFileForDownload = File.createTempFile("downloadedFile1", ".tmp");
localFileForUpload.deleteOnExit();
tempFileForDownload.deleteOnExit();
Object[] r = new Object[] { HTTP_SERVER_BASEURL + "/uploadFile", localFileForUpload.getCanonicalPath(), tempFileForDownload.getCanonicalPath() };
RowMeta rowMetaDefault = new RowMeta();
rowMetaDefault.addValueMeta(new ValueMetaString("URL"));
rowMetaDefault.addValueMeta(new ValueMetaString("UPLOAD"));
rowMetaDefault.addValueMeta(new ValueMetaString("DESTINATION"));
List<RowMetaAndData> rows = new ArrayList<RowMetaAndData>();
rows.add(new RowMetaAndData(rowMetaDefault, r));
Result previousResult = new Result();
previousResult.setRows(rows);
JobEntryHTTP http = new JobEntryHTTP();
http.setParentJob(new Job());
http.setRunForEveryRow(true);
http.setAddFilenameToResult(false);
http.execute(previousResult, 0);
assertTrue(FileUtils.contentEquals(localFileForUpload, tempFileForDownload));
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobEntryHTTP_PDI208_Test method testHTTPResultCustomRows.
@Test
public void testHTTPResultCustomRows() throws IOException {
File localFileForUpload = getInputFile("existingFile2", ".tmp");
File tempFileForDownload = File.createTempFile("downloadedFile2", ".tmp");
localFileForUpload.deleteOnExit();
tempFileForDownload.deleteOnExit();
Object[] r = new Object[] { HTTP_SERVER_BASEURL + "/uploadFile", localFileForUpload.getCanonicalPath(), tempFileForDownload.getCanonicalPath() };
RowMeta rowMetaDefault = new RowMeta();
rowMetaDefault.addValueMeta(new ValueMetaString("MyURL"));
rowMetaDefault.addValueMeta(new ValueMetaString("MyUpload"));
rowMetaDefault.addValueMeta(new ValueMetaString("MyDestination"));
List<RowMetaAndData> rows = new ArrayList<RowMetaAndData>();
rows.add(new RowMetaAndData(rowMetaDefault, r));
Result previousResult = new Result();
previousResult.setRows(rows);
JobEntryHTTP http = new JobEntryHTTP();
http.setParentJob(new Job());
http.setRunForEveryRow(true);
http.setAddFilenameToResult(false);
http.setUrlFieldname("MyURL");
http.setUploadFieldname("MyUpload");
http.setDestinationFieldname("MyDestination");
http.execute(previousResult, 0);
assertTrue(FileUtils.contentEquals(localFileForUpload, tempFileForDownload));
}
Aggregations