VariableHelpers { static void updateNetworkVariables( Map<String,String> instanceExports, String ipAddress ) { Set<String> keysToUpdate = new HashSet<> (); for( Map.Entry<String,String> entry : instanceExports.entrySet()) { String suffix = parseVariableName( entry.getKey()).getValue(); if( Constants.SPECIFIC_VARIABLE_IP.equalsIgnoreCase( suffix )) keysToUpdate.add( entry.getKey()); } for( String key : keysToUpdate ) instanceExports.put( key, ipAddress ); } private  VariableHelpers(); static Map.Entry<String,String> parseVariableName( String variableName ); static Map.Entry<String,String> parseExportedVariable( String exportedVariable ); static Map<String,ExportedVariable> parseExportedVariables( String line ); static Set<String> findPrefixesForExportedVariables( Instance instance ); static Set<String> findPrefixesForImportedVariables( Instance instance ); static Set<String> findPrefixesForMandatoryImportedVariables( Instance instance ); static Set<String> findPrefixesForExternalImports( AbstractApplication app );  }
@Test public void testUpdateNetworkVariables() { Map<String,String> map = new HashMap<> (); map.put( "comp.ip", "" ); map.put( "ip", "" ); map.put( "not-ip", "" ); final String ip = "127.0.0.1"; VariableHelpers.updateNetworkVariables( map, ip ); Assert.assertEquals( ip, map.get( "comp.ip" )); Assert.assertEquals( ip, map.get( "ip" )); Assert.assertEquals( "", map.get( "not-ip" )); }