ImportHelpers { public static void addImport( Instance instance, String componentOrFacetName, Import imp ) { Collection<Import> imports = instance.getImports().get( componentOrFacetName ); if(imports == null) { imports = new LinkedHashSet<Import> (); instance.getImports().put( componentOrFacetName, imports ); } if( ! imports.contains( imp )) imports.add( imp ); } private  ImportHelpers(); static boolean hasAllRequiredImports( Instance instance, Logger logger ); static Import buildTailoredImport(
			Instance instanceThatUseTheImport,
			String exportingInstancePath,
			String exportingInstanceComponent,
			Map<String,String> exportedVariables ); static void addImport( Instance instance, String componentOrFacetName, Import imp ); static void updateImports( Instance instance, Map<String,Collection<Import>> variablePrefixToImports ); static Import findImportByExportingInstance( Collection<Import> imports, String exportingInstancePath );  }
@Test public void testAddImport() { Map<String,Collection<Import>> prefixToImports = new HashMap<String,Collection<Import>> (); prefixToImports.put( "comp", new ArrayList<Import>( Arrays.asList( new Import( "/root1", "comp1" ), new Import( "/root2", "comp1" )))); Instance inst = new Instance( "inst" ); inst.getImports().putAll( prefixToImports ); Assert.assertEquals( 1, inst.getImports().keySet().size()); Assert.assertTrue( inst.getImports().keySet().contains( "comp" )); ImportHelpers.addImport( inst, "wow", new Import( "/root", "comp1" )); Assert.assertEquals( 2, inst.getImports().keySet().size()); Assert.assertTrue( inst.getImports().keySet().contains( "comp" )); Assert.assertTrue( inst.getImports().keySet().contains( "wow" )); Assert.assertEquals( 2, inst.getImports().get( "comp" ).size()); ImportHelpers.addImport( inst, "comp", new Import( "/root3", "comp1" )); Assert.assertEquals( 3, inst.getImports().get( "comp" ).size()); Assert.assertEquals( 2, inst.getImports().keySet().size()); ImportHelpers.addImport( inst, "comp", new Import( "/root3", "comp1" )); Assert.assertEquals( 3, inst.getImports().get( "comp" ).size()); Assert.assertEquals( 2, inst.getImports().keySet().size()); }