### Question:
Variables implements IVariables { @Override public void initializeVariablesFrom( IVariables parent ) { this.parent = parent; Set<String> systemPropertiesNames = System.getProperties().stringPropertyNames(); for ( String key : systemPropertiesNames ) { getProperties().put( key, System.getProperties().getProperty( key ) ); } List<DescribedVariable> describedVariables = HopConfig.getInstance().getDescribedVariables(); for ( DescribedVariable describedVariable : describedVariables ) { getProperties().put( describedVariable.getName(), describedVariable.getValue()); } if ( parent != null ) { copyVariablesFrom( parent ); } if ( injection != null ) { getProperties().putAll( injection ); injection = null; } initialized = true; } Variables(); @Override void copyVariablesFrom( IVariables variables ); @Override IVariables getParentVariableSpace(); @Override void setParentVariableSpace( IVariables parent ); @Override String getVariable( String variableName, String defaultValue ); @Override String getVariable( String variableName ); @Override boolean getBooleanValueOfVariable( String variableName, boolean defaultValue ); @Override void initializeVariablesFrom( IVariables parent ); @Override String[] listVariables(); @Override synchronized void setVariable( String variableName, String variableValue ); @Override synchronized String environmentSubstitute( String aString ); @Override String fieldSubstitute( String aString, IRowMeta rowMeta, Object[] rowData ); @Override String[] environmentSubstitute( String[] string ); @Override void shareVariablesWith( IVariables variables ); @Override void injectVariables( Map<String, String> prop ); static synchronized IVariables getADefaultVariableSpace();  }### Answer:
@Test public void testinItializeVariablesFrom() { final Variables variablesMock = mock( Variables.class ); doCallRealMethod().when( variablesMock ).initializeVariablesFrom( any( IVariables.class ) ); @SuppressWarnings( "unchecked" ) final Map<String, String> propertiesMock = mock( Map.class ); when( variablesMock.getProperties() ).thenReturn( propertiesMock ); doAnswer( new Answer<Map<String, String>>() { final String keyStub = "key"; @Override public Map<String, String> answer( InvocationOnMock invocation ) throws Throwable { if ( System.getProperty( keyStub ) == null ) { modifySystemproperties(); } if ( invocation.getArguments()[ 1 ] != null ) { propertiesMock.put( (String) invocation.getArguments()[ 0 ], System.getProperties().getProperty( (String) invocation.getArguments()[ 1 ] ) ); } return propertiesMock; } } ).when( propertiesMock ).put( anyString(), anyString() ); variablesMock.initializeVariablesFrom( null ); }