use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class StepExternalResourceConsumerListener method addExternalResources.
protected void addExternalResources(Collection<IExternalResourceInfo> resources, StepInterface step) {
if (resources != null) {
// Add the resources to the execution profile
IExecutionProfile executionProfile = TransLineageHolderMap.getInstance().getLineageHolder(step.getTrans()).getExecutionProfile();
if (executionProfile != null) {
String stepName = step.getStepname();
Map<String, List<IExternalResourceInfo>> resourceMap = executionProfile.getExecutionData().getExternalResources();
List<IExternalResourceInfo> externalResources = resourceMap.get(stepName);
if (externalResources == null) {
externalResources = new LinkedList<IExternalResourceInfo>();
}
externalResources.addAll(resources);
resourceMap.put(stepName, externalResources);
}
}
}
use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class BaseRuntimeExtensionPointTest method testWriteLineageHolder.
@Test
public void testWriteLineageHolder() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
assertEquals(0, baos.size());
PrintStream stringStream = new PrintStream(baos);
IGraphWriter graphWriter = mock(IGraphWriter.class);
IExecutionProfile executionProfile = new ExecutionProfile();
executionProfile.setName("testName");
IMetaverseBuilder builder = mock(IMetaverseBuilder.class);
LineageHolder holder = new LineageHolder(executionProfile, builder);
LineageWriter lineageWriter = new LineageWriter();
lineageWriter.setProfileOutputStream(stringStream);
lineageWriter.setGraphOutputStream(System.out);
lineageWriter.setOutputStrategy("all");
lineageWriter.setGraphWriter(graphWriter);
extensionPoint.setLineageWriter(lineageWriter);
extensionPoint.writeLineageInfo(holder);
assertNotEquals(0, baos.size());
assertTrue(baos.toString().contains("testName"));
verify(graphWriter, times(1)).outputGraph(any(Graph.class), any(OutputStream.class));
}
use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class JobEntryExternalResourceConsumerListenerTest method testCallJobEntryAddExternalResources.
@Test
public void testCallJobEntryAddExternalResources() {
JobEntryExternalResourceConsumerListener stepExtensionPoint = new JobEntryExternalResourceConsumerListener();
stepExtensionPoint.addExternalResources(null, null);
JobEntryInterface mockJobEntry = mock(JobEntryInterface.class);
Job mockJob = mock(Job.class);
when(mockJobEntry.getParentJob()).thenReturn(mockJob);
IExecutionProfile executionProfile = mock(IExecutionProfile.class);
IExecutionData executionData = mock(IExecutionData.class);
when(executionProfile.getExecutionData()).thenReturn(executionData);
JobLineageHolderMap.getInstance().getLineageHolder(mockJob).setExecutionProfile(executionProfile);
Collection<IExternalResourceInfo> externalResources = new ArrayList<IExternalResourceInfo>();
stepExtensionPoint.addExternalResources(externalResources, mockJobEntry);
IExternalResourceInfo externalResource = mock(IExternalResourceInfo.class);
externalResources.add(externalResource);
stepExtensionPoint.addExternalResources(externalResources, mockJobEntry);
}
use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class JobEntryExternalResourceListenerTest method testBeforeAfterExecution.
@Test
public void testBeforeAfterExecution() throws Exception {
IJobEntryExternalResourceConsumer consumer = mock(IJobEntryExternalResourceConsumer.class);
JobMeta mockJobMeta = mock(JobMeta.class);
Job job = mock(Job.class);
when(job.getJobMeta()).thenReturn(mockJobMeta);
JobEntryInterface jobEntryInterface = mock(JobEntryInterface.class);
when(jobEntryInterface.getParentJob()).thenReturn(job);
when(jobEntryInterface.getResourceDependencies(mockJobMeta)).thenReturn(Collections.singletonList(new ResourceReference(null, Collections.singletonList(new ResourceEntry("myFile", ResourceEntry.ResourceType.FILE)))));
JobEntryCopy jobEntryCopy = mock(JobEntryCopy.class);
IExecutionProfile executionProfile = mock(IExecutionProfile.class);
IExecutionData executionData = mock(IExecutionData.class);
when(executionProfile.getExecutionData()).thenReturn(executionData);
JobLineageHolderMap.getInstance().getLineageHolder(job).setExecutionProfile(executionProfile);
JobEntryExternalResourceListener listener = new JobEntryExternalResourceListener(consumer);
FileObject mockFile = mock(FileObject.class);
FileName mockFilename = mock(FileName.class);
when(mockFilename.getPath()).thenReturn("/path/to/file");
when(mockFile.getName()).thenReturn(mockFilename);
ResultFile resultFile = mock(ResultFile.class);
when(resultFile.getFile()).thenReturn(mockFile);
List<ResultFile> resultFiles = Collections.singletonList(resultFile);
Result result = mock(Result.class);
when(result.getResultFilesList()).thenReturn(resultFiles);
// Call beforeExecution for coverage
listener.beforeExecution(null, null, null);
listener.afterExecution(job, jobEntryCopy, jobEntryInterface, result);
}
use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class StepExternalConsumerRowListenerTest method testStepExternalConsumerRowListener.
@Test
public void testStepExternalConsumerRowListener() throws Exception {
IStepExternalResourceConsumer consumer = mock(IStepExternalResourceConsumer.class);
BaseStep mockStep = mock(BaseStep.class, withSettings().extraInterfaces(StepInterface.class));
StepMeta mockStepMeta = mock(StepMeta.class);
BaseStepMeta bsm = mock(BaseStepMeta.class, withSettings().extraInterfaces(StepMetaInterface.class));
StepMetaInterface stepMetaInterface = (StepMetaInterface) bsm;
when(mockStep.getStepMeta()).thenReturn(mockStepMeta);
when(mockStepMeta.getStepMetaInterface()).thenReturn(stepMetaInterface);
Trans mockTrans = mock(Trans.class);
when(mockStep.getTrans()).thenReturn(mockTrans);
IExecutionProfile executionProfile = mock(IExecutionProfile.class);
IExecutionData executionData = mock(IExecutionData.class);
when(executionProfile.getExecutionData()).thenReturn(executionData);
LineageHolder holder = new LineageHolder();
holder.setExecutionProfile(executionProfile);
TransLineageHolderMap.getInstance().putLineageHolder(mockTrans, holder);
StepExternalConsumerRowListener listener = new StepExternalConsumerRowListener(consumer, mockStep);
RowMetaInterface rmi = mock(RowMetaInterface.class);
Object[] row = new Object[0];
listener.rowReadEvent(rmi, row);
}
Aggregations