@Test public void testFormatExportedVars_singleInstance() { Component c = new Component( "c" ); c.exportedVariables.put( "forced-ip", new ExportedVariable( "forced-ip", "127.0.0.1" )); c.exportedVariables.put( "port", new ExportedVariable( "port", "49535" )); Instance i = new Instance( "i" ).component( c ); i.overriddenExports.put( "something", "else" ); Map<String,String> exportedVariables = ScriptUtils.formatExportedVars( i ); Assert.assertEquals( 3, exportedVariables.size()); Assert.assertEquals( "127.0.0.1", exportedVariables.get( "forced_ip" )); Assert.assertEquals( "49535", exportedVariables.get( "port" )); Assert.assertEquals( "else", exportedVariables.get( "something" )); }
public static Map<String,String> formatExportedVars( Instance instance ) { Map<String, String> exportedVars = new HashMap<> (); for( Instance inst = instance; inst != null; inst = inst.getParent()) { String prefix = ""; if( inst != instance ) prefix = "ANCESTOR_" + inst.getComponent().getName() + "_"; Map<String,String> exports = InstanceHelpers.findAllExportedVariables( inst ); for(Entry<String, String> entry : exports.entrySet()) { String vname = prefix + VariableHelpers.parseVariableName( entry.getKey()).getValue(); vname = vname.replaceAll( "(-|%s)+", "_" ); exportedVars.put( vname, entry.getValue()); } } return exportedVars; }
ScriptUtils { public static Map<String,String> formatExportedVars( Instance instance ) { Map<String, String> exportedVars = new HashMap<> (); for( Instance inst = instance; inst != null; inst = inst.getParent()) { String prefix = ""; if( inst != instance ) prefix = "ANCESTOR_" + inst.getComponent().getName() + "_"; Map<String,String> exports = InstanceHelpers.findAllExportedVariables( inst ); for(Entry<String, String> entry : exports.entrySet()) { String vname = prefix + VariableHelpers.parseVariableName( entry.getKey()).getValue(); vname = vname.replaceAll( "(-|%s)+", "_" ); exportedVars.put( vname, entry.getValue()); } } return exportedVars; } }
ScriptUtils { public static Map<String,String> formatExportedVars( Instance instance ) { Map<String, String> exportedVars = new HashMap<> (); for( Instance inst = instance; inst != null; inst = inst.getParent()) { String prefix = ""; if( inst != instance ) prefix = "ANCESTOR_" + inst.getComponent().getName() + "_"; Map<String,String> exports = InstanceHelpers.findAllExportedVariables( inst ); for(Entry<String, String> entry : exports.entrySet()) { String vname = prefix + VariableHelpers.parseVariableName( entry.getKey()).getValue(); vname = vname.replaceAll( "(-|%s)+", "_" ); exportedVars.put( vname, entry.getValue()); } } return exportedVars; } private  ScriptUtils(); }
ScriptUtils { public static Map<String,String> formatExportedVars( Instance instance ) { Map<String, String> exportedVars = new HashMap<> (); for( Instance inst = instance; inst != null; inst = inst.getParent()) { String prefix = ""; if( inst != instance ) prefix = "ANCESTOR_" + inst.getComponent().getName() + "_"; Map<String,String> exports = InstanceHelpers.findAllExportedVariables( inst ); for(Entry<String, String> entry : exports.entrySet()) { String vname = prefix + VariableHelpers.parseVariableName( entry.getKey()).getValue(); vname = vname.replaceAll( "(-|%s)+", "_" ); exportedVars.put( vname, entry.getValue()); } } return exportedVars; } private  ScriptUtils(); static Map<String,String> formatExportedVars( Instance instance ); static Map<String,String> formatImportedVars( Instance instance ); static void setScriptsExecutable( File fileOrDir ); }
ScriptUtils { public static Map<String,String> formatExportedVars( Instance instance ) { Map<String, String> exportedVars = new HashMap<> (); for( Instance inst = instance; inst != null; inst = inst.getParent()) { String prefix = ""; if( inst != instance ) prefix = "ANCESTOR_" + inst.getComponent().getName() + "_"; Map<String,String> exports = InstanceHelpers.findAllExportedVariables( inst ); for(Entry<String, String> entry : exports.entrySet()) { String vname = prefix + VariableHelpers.parseVariableName( entry.getKey()).getValue(); vname = vname.replaceAll( "(-|%s)+", "_" ); exportedVars.put( vname, entry.getValue()); } } return exportedVars; } private  ScriptUtils(); static Map<String,String> formatExportedVars( Instance instance ); static Map<String,String> formatImportedVars( Instance instance ); static void setScriptsExecutable( File fileOrDir );  }