public static TransMeta loadMappingMeta( StepWithMappingMeta mappingMeta, Repository rep,
                                           IMetaStore metaStore, VariableSpace space ) throws KettleException {
    return loadMappingMeta( mappingMeta, rep, metaStore, space, true );
  }
@Test
  public void loadMappingMetaTest() throws Exception {

    String childParam = "childParam";
    String childValue = "childValue";
    String paramOverwrite = "paramOverwrite";
    String parentParam = "parentParam";
    String parentValue = "parentValue";

    String variablePath = "Internal.Entry.Current.Directory";
    String virtualDir = "/testFolder/CDA-91";
    String fileName = "testTrans.ktr";

    VariableSpace variables = new Variables();
    variables.setVariable( parentParam, parentValue );
    variables.setVariable( paramOverwrite, parentValue );

    StepMeta stepMeta = new StepMeta();
    TransMeta parentTransMeta = new TransMeta();
    stepMeta.setParentTransMeta( parentTransMeta );

    RepositoryDirectoryInterface repositoryDirectory = Mockito.mock( RepositoryDirectoryInterface.class );
    when( repositoryDirectory.toString() ).thenReturn( virtualDir );
    stepMeta.getParentTransMeta().setRepositoryDirectory( repositoryDirectory );

    StepWithMappingMeta mappingMetaMock = mock( StepWithMappingMeta.class );
    when( mappingMetaMock.getSpecificationMethod() ).thenReturn( ObjectLocationSpecificationMethod.FILENAME );
    when( mappingMetaMock.getFileName() ).thenReturn( "${" + variablePath + "}/" + fileName );
    when( mappingMetaMock.getParentStepMeta() ).thenReturn( stepMeta );


    Repository rep = mock( Repository.class );
    Mockito.doReturn( Mockito.mock( RepositoryDirectoryInterface.class ) ).when( rep ).findDirectory( anyString() );

    TransMeta child = new TransMeta();
    child.setVariable( childParam, childValue );
    child.setVariable( paramOverwrite, childValue );
    Mockito.doReturn( child ).when( rep ).loadTransformation( anyString(), any(), any(), anyBoolean(), any() );

    TransMeta transMeta = StepWithMappingMeta.loadMappingMeta( mappingMetaMock, rep, null, variables, true );

    Assert.assertNotNull( transMeta );

    //When the child parameter does exist in the parent parameters, overwrite the child parameter by the parent parameter.
    Assert.assertEquals( parentValue, transMeta.getVariable( paramOverwrite ) );

    //When the child parameter does not exist in the parent parameters, keep it.
    Assert.assertEquals( childValue, transMeta.getVariable( childParam ) );

    //All other parent parameters need to get copied into the child parameters  (when the 'Inherit all
    //variables from the transformation?' option is checked).
    Assert.assertEquals( parentValue, transMeta.getVariable( parentParam ) );
  }