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());
}
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());
}
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());
}
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);
}
}
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());
}
Aggregations