use of org.pentaho.metaverse.analyzer.kettle.extensionpoints.trans.TransLineageHolderMap in project pentaho-metaverse by pentaho.
the class JobLineageHolderMapTest method testRemoveLineageHolderWithParentTrans.
@Test
public void testRemoveLineageHolderWithParentTrans() throws Exception {
initMetas();
// initialize the lineage holder for this transformation
jobLineageHolderMap.getLineageHolder(job);
// test with parent transformation being set
when(job.getParentTrans()).thenReturn(parentTrans);
Field lineageHolderMapField = jobLineageHolderMap.getClass().getDeclaredField("lineageHolderMap");
lineageHolderMapField.setAccessible(true);
jobLineageHolderMap.removeLineageHolder(job);
// make sure the trans map entry was NOT removed and its resources were NOT removed from the
// KettleAnalyzerUtil.resourceMap, since trans has a parent
Map<Trans, LineageHolder> lineageHolderMap = (Map) lineageHolderMapField.get(jobLineageHolderMap);
assertNotNull(lineageHolderMap.get(job));
// lineageHolderMap will only have one member, the parent trans will be in the TransLineageHolderMap
assertEquals(1, lineageHolderMap.size());
// make sure that removing the parent trans removes it and its sub-transformations from the map and also removed
// sub-transformation resources from KettleAnalyzerUtil.resourceMap
TransLineageHolderMap.getInstance().removeLineageHolder(parentTrans);
lineageHolderMap = (Map) lineageHolderMapField.get(jobLineageHolderMap);
assertNull(lineageHolderMap.get(parentTrans));
assertNull(lineageHolderMap.get(job));
assertEquals(0, lineageHolderMap.size());
}
Aggregations