Search in sources :

Example 86 with Job

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);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) NamedClusterEmbedManager(org.pentaho.di.trans.steps.named.cluster.NamedClusterEmbedManager) Job(org.pentaho.di.job.Job) Before(org.junit.Before)

Example 87 with Job

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));
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) NamedClusterEmbedManager(org.pentaho.di.trans.steps.named.cluster.NamedClusterEmbedManager) Job(org.pentaho.di.job.Job) Before(org.junit.Before)

Example 88 with Job

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);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Job(org.pentaho.di.job.Job) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) InfobrightDatabaseMeta(org.pentaho.di.core.database.InfobrightDatabaseMeta) BaseDatabaseMeta(org.pentaho.di.core.database.BaseDatabaseMeta) Before(org.junit.Before)

Example 89 with Job

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));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) Job(org.pentaho.di.job.Job) File(java.io.File) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 90 with Job

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));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) Job(org.pentaho.di.job.Job) File(java.io.File) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Aggregations

Job (org.pentaho.di.job.Job)95 JobMeta (org.pentaho.di.job.JobMeta)44 Test (org.junit.Test)35 Result (org.pentaho.di.core.Result)22 KettleException (org.pentaho.di.core.exception.KettleException)20 PrintWriter (java.io.PrintWriter)17 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)17 Trans (org.pentaho.di.trans.Trans)14 IOException (java.io.IOException)11 Before (org.junit.Before)11 Point (org.pentaho.di.core.gui.Point)11 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)11 JobExecutionConfiguration (org.pentaho.di.job.JobExecutionConfiguration)10 Repository (org.pentaho.di.repository.Repository)10 ArrayList (java.util.ArrayList)9 ServletException (javax.servlet.ServletException)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 HttpServletResponse (javax.servlet.http.HttpServletResponse)9 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)9 JobConfiguration (org.pentaho.di.job.JobConfiguration)9