use of org.pentaho.metaverse.analyzer.kettle.jobentry.JobEntryExternalResourceConsumerProvider in project pentaho-metaverse by pentaho.
the class JobEntryExternalResourceConsumerListenerTest method testCallJobEntryExtensionPoint.
@Test
public void testCallJobEntryExtensionPoint() throws Exception {
JobEntryExternalResourceConsumerListener jobEntryExtensionPoint = new JobEntryExternalResourceConsumerListener();
jobEntryExtensionPoint.setJobEntryExternalResourceConsumerProvider(MetaverseTestUtils.getJobEntryExternalResourceConsumerProvider());
JobExecutionExtension jobExec = mock(JobExecutionExtension.class);
JobEntryBase jobEntryBase = mock(JobEntryBase.class, withSettings().extraInterfaces(JobEntryInterface.class));
JobEntryInterface jobEntryInterface = (JobEntryInterface) jobEntryBase;
JobEntryCopy jobEntryCopy = mock(JobEntryCopy.class);
when(jobEntryCopy.getEntry()).thenReturn(jobEntryInterface);
jobExec.jobEntryCopy = jobEntryCopy;
jobEntryExtensionPoint.callExtensionPoint(null, jobExec);
// Adda consumer
Map<Class<? extends JobEntryBase>, Set<IJobEntryExternalResourceConsumer>> jobEntryConsumerMap = new JobEntryExternalResourceConsumerProvider().getJobEntryConsumerMap();
Set<IJobEntryExternalResourceConsumer> consumers = new HashSet<IJobEntryExternalResourceConsumer>();
jobEntryConsumerMap.put(jobEntryBase.getClass(), consumers);
jobEntryExtensionPoint.callExtensionPoint(null, jobExec);
IJobEntryExternalResourceConsumer consumer = mock(IJobEntryExternalResourceConsumer.class);
when(consumer.getResourcesFromMeta(Mockito.any())).thenReturn(Collections.emptyList());
consumers.add(consumer);
Job mockJob = mock(Job.class);
when(jobEntryInterface.getParentJob()).thenReturn(mockJob);
jobExec.job = mockJob;
jobEntryExtensionPoint.callExtensionPoint(null, jobExec);
when(consumer.isDataDriven(Mockito.any())).thenReturn(Boolean.TRUE);
jobEntryExtensionPoint.callExtensionPoint(null, jobExec);
}
Aggregations