Search in sources :

Example 66 with JobMeta

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

the class RepositoryImporterTest method createRepositoryImporter.

private static RepositoryImporter createRepositoryImporter(final JobEntryInterface jobEntryInterface, final StepMetaInterface stepMetaInterface, final boolean needToCheckPathForVariables) {
    Repository repository = mock(Repository.class);
    LogChannelInterface log = mock(LogChannelInterface.class);
    RepositoryImporter importer = new RepositoryImporter(repository, log) {

        @Override
        JobMeta createJobMetaForNode(Node jobnode) throws KettleXMLException {
            JobMeta meta = mock(JobMeta.class);
            JobEntryCopy jec = mock(JobEntryCopy.class);
            when(jec.isTransformation()).thenReturn(true);
            when(jec.getEntry()).thenReturn(jobEntryInterface);
            when(meta.getJobCopies()).thenReturn(Collections.singletonList(jec));
            return meta;
        }

        @Override
        TransMeta createTransMetaForNode(Node transnode) throws KettleMissingPluginsException, KettleXMLException {
            TransMeta meta = mock(TransMeta.class);
            StepMeta stepMeta = mock(StepMeta.class);
            when(stepMeta.isMapping()).thenReturn(true);
            when(stepMeta.getStepMetaInterface()).thenReturn(stepMetaInterface);
            when(meta.getSteps()).thenReturn(Collections.singletonList(stepMeta));
            return meta;
        }

        @Override
        protected void replaceSharedObjects(JobMeta transMeta) throws KettleException {
        }

        @Override
        protected void replaceSharedObjects(TransMeta transMeta) throws KettleException {
        }

        @Override
        boolean needToCheckPathForVariables() {
            return needToCheckPathForVariables;
        }
    };
    return importer;
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Node(org.w3c.dom.Node) TransMeta(org.pentaho.di.trans.TransMeta) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 67 with JobMeta

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

the class KettleFileRepositoryTest method testCurrentDirJob.

@Test
public void testCurrentDirJob() throws Exception {
    final String dirName = "dirName";
    final String jobName = "job";
    JobMeta setupJobMeta = new JobMeta();
    setupJobMeta.setName(jobName);
    RepositoryDirectoryInterface repoDir = repository.createRepositoryDirectory(new RepositoryDirectory(), dirName);
    setupJobMeta.setRepositoryDirectory(repoDir);
    repository.save(setupJobMeta, "");
    JobMeta jobMeta = repository.loadJob(jobName, repoDir, null, "");
    assertEquals(repository, jobMeta.getRepository());
    assertEquals(repoDir.getPath(), jobMeta.getRepositoryDirectory().getPath());
    jobMeta.setInternalKettleVariables();
    String currentDir = jobMeta.getVariable(Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY);
    assertEquals(repoDir.getPath(), currentDir);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) Test(org.junit.Test)

Example 68 with JobMeta

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

the class JobEntryFilesExistTest method setUp.

@Before
public void setUp() throws Exception {
    job = new Job(null, new JobMeta());
    entry = new JobEntryFilesExist();
    job.getJobMeta().addJobEntry(new JobEntryCopy(entry));
    entry.setParentJob(job);
    JobMeta mockJobMeta = mock(JobMeta.class);
    entry.setParentJobMeta(mockJobMeta);
    job.setStopped(false);
    existingFile1 = TestUtils.createRamFile(getClass().getSimpleName() + "/existingFile1.ext", entry);
    existingFile2 = TestUtils.createRamFile(getClass().getSimpleName() + "/existingFile2.ext", entry);
}
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 69 with JobMeta

use of org.pentaho.di.job.JobMeta 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 70 with JobMeta

use of org.pentaho.di.job.JobMeta 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)

Aggregations

JobMeta (org.pentaho.di.job.JobMeta)254 Test (org.junit.Test)88 TransMeta (org.pentaho.di.trans.TransMeta)69 KettleException (org.pentaho.di.core.exception.KettleException)62 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)48 Job (org.pentaho.di.job.Job)45 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)27 Repository (org.pentaho.di.repository.Repository)25 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)25 Point (org.pentaho.di.core.gui.Point)24 ArrayList (java.util.ArrayList)23 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)22 SlaveServer (org.pentaho.di.cluster.SlaveServer)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 FileObject (org.apache.commons.vfs2.FileObject)16 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)16 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)15 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)15 PrintWriter (java.io.PrintWriter)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)12