Search in sources :

Example 11 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans in project pentaho-kettle by pentaho.

the class JobFileListenerTest method testProcessLinkedTransWithFilename.

@Test
public void testProcessLinkedTransWithFilename() {
    JobEntryTrans jobTransExecutor = spy(new JobEntryTrans());
    jobTransExecutor.setFileName("/path/to/Transformation2.ktr");
    jobTransExecutor.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
    JobEntryCopy jobEntry = mock(JobEntryCopy.class);
    when(jobEntry.getEntry()).thenReturn(jobTransExecutor);
    JobMeta parent = mock(JobMeta.class);
    when(parent.nrJobEntries()).thenReturn(1);
    when(parent.getJobEntry(0)).thenReturn(jobEntry);
    JobMeta result = jobFileListener.processLinkedTrans(parent);
    JobEntryCopy meta = result.getJobEntry(0);
    assertNotNull(meta);
    JobEntryTrans resultExecMeta = (JobEntryTrans) meta.getEntry();
    assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod());
    assertEquals("/path/to", resultExecMeta.getDirectory());
    assertEquals("Transformation2", resultExecMeta.getTransname());
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobMeta(org.pentaho.di.job.JobMeta) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) Test(org.junit.Test)

Example 12 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans in project pentaho-kettle by pentaho.

the class JobFileListenerTest method testProcessLinkedTransWithNoFilename.

@Test
public void testProcessLinkedTransWithNoFilename() {
    JobEntryTrans jobTransExecutor = spy(new JobEntryTrans());
    jobTransExecutor.setFileName(null);
    jobTransExecutor.setDirectory("/path/to");
    jobTransExecutor.setTransname("Transformation2");
    jobTransExecutor.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
    JobEntryCopy jobEntry = mock(JobEntryCopy.class);
    when(jobEntry.getEntry()).thenReturn(jobTransExecutor);
    JobMeta parent = mock(JobMeta.class);
    when(parent.nrJobEntries()).thenReturn(1);
    when(parent.getJobEntry(0)).thenReturn(jobEntry);
    JobMeta result = jobFileListener.processLinkedTrans(parent);
    JobEntryCopy meta = result.getJobEntry(0);
    assertNotNull(meta);
    JobEntryTrans resultExecMeta = (JobEntryTrans) meta.getEntry();
    assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod());
    assertEquals("/path/to", resultExecMeta.getDirectory());
    assertEquals("Transformation2", resultExecMeta.getTransname());
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobMeta(org.pentaho.di.job.JobMeta) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) Test(org.junit.Test)

Example 13 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans in project pentaho-kettle by pentaho.

the class RunConfigurationDelegateTest method testUpdateLoadedJobs_Exception.

@Test
public void testUpdateLoadedJobs_Exception() throws Exception {
    JobEntryTrans trans = new JobEntryTrans();
    trans.setRunConfiguration("key");
    JobMeta meta = new JobMeta();
    meta.addJobEntry(new JobEntryCopy(trans));
    JobMeta[] jobs = new JobMeta[] { meta };
    doReturn(jobs).when(spoon).getLoadedJobs();
    DefaultRunConfiguration config = new DefaultRunConfiguration();
    config.setName("Test");
    config.setServer("localhost");
    LogChannelInterface log = mock(LogChannelInterface.class);
    doReturn(log).when(spoon).getLog();
    PowerMockito.mockStatic(ExtensionPointHandler.class);
    PowerMockito.when(ExtensionPointHandler.class, "callExtensionPoint", any(), any(), any()).thenThrow(KettleException.class);
    delegate.updateLoadedJobs("key", config);
    verify(log, times(1)).logBasic(any());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) ExtensionPointHandler(org.pentaho.di.core.extension.ExtensionPointHandler) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans in project pentaho-kettle by pentaho.

the class RunConfigurationInjectExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    if (!(object instanceof JobExecutionExtension)) {
        return;
    }
    JobExecutionExtension extension = (JobExecutionExtension) object;
    Job job = extension.job;
    JobMeta jobMeta = job.getJobMeta();
    final EmbeddedMetaStore embeddedMetaStore = jobMeta.getEmbeddedMetaStore();
    RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
    // will load and save to meta all run configurations
    for (JobEntryTrans trans : job.getActiveJobEntryTransformations().values()) {
        RunConfiguration loadedRunConfiguration = runConfigurationManager.load(jobMeta.environmentSubstitute(trans.getRunConfiguration()));
        embeddedRunConfigurationManager.save(loadedRunConfiguration);
    }
    for (JobEntryJob subJob : job.getActiveJobEntryJobs().values()) {
        RunConfiguration loadedRunConfiguration = runConfigurationManager.load(jobMeta.environmentSubstitute(subJob.getRunConfiguration()));
        embeddedRunConfigurationManager.save(loadedRunConfiguration);
    }
}
Also used : JobExecutionExtension(org.pentaho.di.job.JobExecutionExtension) JobMeta(org.pentaho.di.job.JobMeta) RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) RunConfigurationManager(org.pentaho.di.engine.configuration.impl.RunConfigurationManager) EmbeddedRunConfigurationManager(org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) Job(org.pentaho.di.job.Job) EmbeddedMetaStore(org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob)

Example 15 with JobEntryTrans

use of org.pentaho.di.job.entries.trans.JobEntryTrans in project pentaho-kettle by pentaho.

the class JobExecutionConfigurationTest method testGetUsedArguments.

@Test
public void testGetUsedArguments() throws KettleException {
    JobExecutionConfiguration executionConfiguration = new JobExecutionConfiguration();
    JobMeta jobMeta = new JobMeta();
    jobMeta.jobcopies = new ArrayList<>();
    String[] commandLineArguments = new String[0];
    IMetaStore metaStore = mock(IMetaStore.class);
    JobEntryCopy jobEntryCopy0 = new JobEntryCopy();
    TransMeta transMeta0 = mock(TransMeta.class);
    Map<String, String> map0 = new HashMap<>();
    map0.put("arg0", "argument0");
    when(transMeta0.getUsedArguments(commandLineArguments)).thenReturn(map0);
    JobEntryInterface jobEntryInterface0 = mock(JobEntryInterface.class);
    when(jobEntryInterface0.isTransformation()).thenReturn(false);
    jobEntryCopy0.setEntry(jobEntryInterface0);
    jobMeta.jobcopies.add(jobEntryCopy0);
    JobEntryCopy jobEntryCopy1 = new JobEntryCopy();
    TransMeta transMeta1 = mock(TransMeta.class);
    Map<String, String> map1 = new HashMap<>();
    map1.put("arg1", "argument1");
    when(transMeta1.getUsedArguments(commandLineArguments)).thenReturn(map1);
    JobEntryTrans jobEntryTrans1 = mock(JobEntryTrans.class);
    when(jobEntryTrans1.isTransformation()).thenReturn(true);
    when(jobEntryTrans1.getTransMeta(executionConfiguration.getRepository(), metaStore, jobMeta)).thenReturn(transMeta1);
    jobEntryCopy1.setEntry(jobEntryTrans1);
    jobMeta.jobcopies.add(jobEntryCopy1);
    JobEntryCopy jobEntryCopy2 = new JobEntryCopy();
    TransMeta transMeta2 = mock(TransMeta.class);
    Map<String, String> map2 = new HashMap<>();
    map2.put("arg1", "argument1");
    map2.put("arg2", "argument2");
    when(transMeta2.getUsedArguments(commandLineArguments)).thenReturn(map2);
    JobEntryTrans jobEntryTrans2 = mock(JobEntryTrans.class);
    when(jobEntryTrans2.isTransformation()).thenReturn(true);
    when(jobEntryTrans2.getTransMeta(executionConfiguration.getRepository(), metaStore, jobMeta)).thenReturn(transMeta2);
    jobEntryCopy2.setEntry(jobEntryTrans2);
    jobMeta.jobcopies.add(jobEntryCopy2);
    executionConfiguration.getUsedArguments(jobMeta, commandLineArguments, metaStore);
    assertEquals(2, executionConfiguration.getArguments().size());
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) HashMap(java.util.HashMap) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) TransMeta(org.pentaho.di.trans.TransMeta) Matchers.anyString(org.mockito.Matchers.anyString) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Aggregations

JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)17 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)14 JobMeta (org.pentaho.di.job.JobMeta)10 Test (org.junit.Test)7 KettleException (org.pentaho.di.core.exception.KettleException)7 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)5 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)5 DefaultRunConfiguration (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration)4 TransMeta (org.pentaho.di.trans.TransMeta)4 ArrayList (java.util.ArrayList)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 FileObject (org.apache.commons.vfs2.FileObject)2 ObjectLocationSpecificationMethod (org.pentaho.di.core.ObjectLocationSpecificationMethod)2 EmbeddedMetaStore (org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)2 Utils (org.pentaho.di.core.util.Utils)2 JobEntryJob (org.pentaho.di.job.entries.job.JobEntryJob)2 IOException (java.io.IOException)1