Search in sources :

Example 1 with TransLineageHolderMap

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());
}
Also used : Field(java.lang.reflect.Field) Trans(org.pentaho.di.trans.Trans) TransLineageHolderMap(org.pentaho.metaverse.analyzer.kettle.extensionpoints.trans.TransLineageHolderMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) LineageHolder(org.pentaho.metaverse.api.model.LineageHolder) Test(org.junit.Test)

Aggregations

Field (java.lang.reflect.Field)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Test (org.junit.Test)1 Trans (org.pentaho.di.trans.Trans)1 TransLineageHolderMap (org.pentaho.metaverse.analyzer.kettle.extensionpoints.trans.TransLineageHolderMap)1 LineageHolder (org.pentaho.metaverse.api.model.LineageHolder)1