VariableHelpers { public static Set<String> findPrefixesForMandatoryImportedVariables( Instance instance ) { Set<String> result = new HashSet<> (); for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( instance.getComponent()).values()) { if( ! var.isOptional()) result.add( VariableHelpers.parseVariableName( var.getName()).getKey()); } return result; } 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 testFindPrefixesForMandatoryImportedVariables() { Component component = new Component( "comp" ); component.addImportedVariable( new ImportedVariable( "comp.ip", false, false )); component.addImportedVariable( new ImportedVariable( "comp.split.property", false, false )); component.addImportedVariable( new ImportedVariable( "comp.port", false, false )); component.addImportedVariable( new ImportedVariable( "facet.desc", true, false )); component.addImportedVariable( new ImportedVariable( "facet-n.prop1", true, false )); component.addImportedVariable( new ImportedVariable( "facet-n.prop2", false, false )); Instance instance = new Instance( "inst" ).component( component ); Set<String> prefixes = VariableHelpers.findPrefixesForMandatoryImportedVariables( instance ); Assert.assertEquals( 2, prefixes.size()); Assert.assertTrue( prefixes.contains( "comp" )); Assert.assertTrue( prefixes.contains( "facet-n" )); component.importedVariables.clear(); prefixes = VariableHelpers.findPrefixesForMandatoryImportedVariables( instance ); Assert.assertEquals( 0, prefixes.size()); }