ImportHelpers { public static void updateImports( Instance instance, Map<String,Collection<Import>> variablePrefixToImports ) { instance.getImports().clear(); if( variablePrefixToImports != null ) instance.getImports().putAll( variablePrefixToImports ); } 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 testUpdateImports() { Map<String,Collection<Import>> prefixToImports = new HashMap<String,Collection<Import>> (); prefixToImports.put( "comp", Arrays.asList( new Import( "/root1", "comp1" ), new Import( "/root2", "comp1" ))); Instance inst = new Instance( "inst" ); Assert.assertEquals( 0, inst.getImports().size()); ImportHelpers.updateImports( inst, prefixToImports ); Assert.assertEquals( 1, inst.getImports().size()); Iterator<Import> iterator = inst.getImports().get( "comp" ).iterator(); Assert.assertEquals( "/root1", iterator.next().getInstancePath()); Assert.assertEquals( "/root2", iterator.next().getInstancePath()); Assert.assertFalse( iterator.hasNext()); prefixToImports.put( "comp", Arrays.asList( new Import( "/root1", "comp1" ))); ImportHelpers.updateImports( inst, prefixToImports ); Assert.assertEquals( 1, inst.getImports().size()); iterator = inst.getImports().get( "comp" ).iterator(); Assert.assertEquals( "/root1", iterator.next().getInstancePath()); Assert.assertFalse( iterator.hasNext()); ImportHelpers.updateImports( inst, null ); Assert.assertEquals( 0, inst.getImports().size()); }