Search in sources :

Example 11 with Job

use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.

the class JobEntryFolderIsEmptyTest method setUp.

@Before
public void setUp() throws Exception {
    job = new Job(null, new JobMeta());
    entry = new JobEntryFolderIsEmpty();
    job.getJobMeta().addJobEntry(new JobEntryCopy(entry));
    entry.setParentJob(job);
    JobMeta mockJobMeta = mock(JobMeta.class);
    entry.setParentJobMeta(mockJobMeta);
    job.setStopped(false);
    File dir = Files.createTempDirectory("dir", new FileAttribute<?>[0]).toFile();
    dir.deleteOnExit();
    emptyDir = dir.getPath();
    dir = Files.createTempDirectory("dir", new FileAttribute<?>[0]).toFile();
    dir.deleteOnExit();
    nonEmptyDir = dir.getPath();
    File file = File.createTempFile("existingFile", "ext", dir);
    file.deleteOnExit();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Job(org.pentaho.di.job.Job) File(java.io.File) FileAttribute(java.nio.file.attribute.FileAttribute) Before(org.junit.Before)

Example 12 with Job

use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.

the class JobEntryFTPTest method setUp.

@Before
public void setUp() throws Exception {
    job = new Job(null, new JobMeta());
    entry = new MockedJobEntryFTP();
    job.getJobMeta().addJobEntry(new JobEntryCopy(entry));
    entry.setParentJob(job);
    job.setStopped(false);
    entry.setServerName("some.server");
    entry.setUserName("anonymous");
    entry.setFtpDirectory(".");
    entry.setWildcard("robots.txt");
    entry.setBinaryMode(false);
    entry.setSuccessCondition("success_if_no_errors");
    existingDir = TestUtils.createTempDir();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Job(org.pentaho.di.job.Job) Before(org.junit.Before)

Example 13 with Job

use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.

the class KitchenTest method testConfigureParameters.

@Test
public void testConfigureParameters() throws Exception {
    JobMeta jobMeta = new JobMeta();
    jobMeta.addParameterDefinition(TEST_PARAM_NAME, DEFAULT_PARAM_VALUE, "This tests a default parameter");
    assertEquals("Default parameter was not set correctly on JobMeta", DEFAULT_PARAM_VALUE, jobMeta.getParameterDefault(TEST_PARAM_NAME));
    assertEquals("Parameter value should be blank in JobMeta", "", jobMeta.getParameterValue(TEST_PARAM_NAME));
    Job job = new Job(null, jobMeta);
    job.copyParametersFrom(jobMeta);
    assertEquals("Default parameter was not set correctly on Job", DEFAULT_PARAM_VALUE, job.getParameterDefault(TEST_PARAM_NAME));
    assertEquals("Parameter value should be blank in Job", "", job.getParameterValue(TEST_PARAM_NAME));
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) Job(org.pentaho.di.job.Job) Test(org.junit.Test)

Example 14 with Job

use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.

the class JobEntryColumnsExistTest method setUp.

@Before
public void setUp() {
    Job parentJob = new Job(null, new JobMeta());
    jobEntry = spy(new JobEntryColumnsExist(""));
    parentJob.getJobMeta().addJobEntry(new JobEntryCopy(jobEntry));
    parentJob.setStopped(false);
    jobEntry.setParentJob(parentJob);
    parentJob.setLogLevel(LogLevel.NOTHING);
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    jobEntry.setDatabase(dbMeta);
    db = spy(new Database(jobEntry, dbMeta));
    jobEntry.setParentJob(parentJob);
    jobEntry.setTablename(TABLENAME);
    jobEntry.setArguments(COLUMNS);
    jobEntry.setSchemaname(SCHEMANAME);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Database(org.pentaho.di.core.database.Database) Job(org.pentaho.di.job.Job) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Before(org.junit.Before)

Example 15 with Job

use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.

the class RemoveJobServletIT method testRemoveJobServletEscapesHtmlWhenTransFound.

@Test
public void testRemoveJobServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
    KettleLogStore.init();
    HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
    HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
    Job mockJob = mock(Job.class);
    JobMeta mockJobMeta = mock(JobMeta.class);
    LogChannelInterface mockLogChannelInterface = mock(LogChannelInterface.class);
    mockJob.setName(ServletTestUtils.BAD_STRING);
    StringWriter out = new StringWriter();
    PrintWriter printWriter = new PrintWriter(out);
    when(mockHttpServletRequest.getContextPath()).thenReturn(RemoveJobServlet.CONTEXT_PATH);
    when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING);
    when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
    when(mockJobMap.getJob(any(CarteObjectEntry.class))).thenReturn(mockJob);
    when(mockJob.getLogChannelId()).thenReturn(ServletTestUtils.BAD_STRING);
    when(mockJob.getLogChannel()).thenReturn(mockLogChannelInterface);
    when(mockJob.getJobMeta()).thenReturn(mockJobMeta);
    when(mockJobMeta.getMaximum()).thenReturn(new Point(10, 10));
    removeJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
    assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H3", out.toString())));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) JobMeta(org.pentaho.di.job.JobMeta) StringWriter(java.io.StringWriter) HttpServletResponse(javax.servlet.http.HttpServletResponse) Point(org.pentaho.di.core.gui.Point) Job(org.pentaho.di.job.Job) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) PrintWriter(java.io.PrintWriter) 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