@Test public void testFindAllFacets() { ApplicationTemplate app = ComplexApplicationFactory1.newApplication(); Component root1 = ComponentHelpers.findComponent( app.getGraphs(), ComplexApplicationFactory1.ROOT_1 ); Assert.assertNotNull( root1 ); Collection<Facet> facets = ComponentHelpers.findAllFacets( root1 ); Assert.assertEquals( 1, facets.size()); Assert.assertTrue( facets.contains( new Facet( ComplexApplicationFactory1.FACET_VM ))); Component mongoDb = ComponentHelpers.findComponent( app.getGraphs(), ComplexApplicationFactory1.MONGO_DB ); Assert.assertNotNull( mongoDb ); facets = ComponentHelpers.findAllFacets( mongoDb ); Assert.assertEquals( 0, facets.size()); Component glassfish = ComponentHelpers.findComponent( app.getGraphs(), ComplexApplicationFactory1.GLASSFISH ); Assert.assertNotNull( glassfish ); facets = ComponentHelpers.findAllFacets( glassfish ); Assert.assertEquals( 3, facets.size()); Assert.assertTrue( facets.contains( new Facet( ComplexApplicationFactory1.FACET_JEE ))); Assert.assertTrue( facets.contains( new Facet( ComplexApplicationFactory1.FACET_WEB ))); Assert.assertTrue( facets.contains( new Facet( ComplexApplicationFactory1.FACET_DEPLOYABLE ))); Component tomcat = ComponentHelpers.findComponent( app.getGraphs(), ComplexApplicationFactory1.TOMCAT ); Assert.assertNotNull( tomcat ); facets = ComponentHelpers.findAllFacets( tomcat ); Assert.assertEquals( 2, facets.size()); Assert.assertTrue( facets.contains( new Facet( ComplexApplicationFactory1.FACET_WEB ))); Assert.assertTrue( facets.contains( new Facet( ComplexApplicationFactory1.FACET_DEPLOYABLE ))); Component tomcat8 = ComponentHelpers.findComponent( app.getGraphs(), ComplexApplicationFactory1.TOMCAT_8 ); Assert.assertNotNull( tomcat8 ); facets = ComponentHelpers.findAllFacets( tomcat8 ); Assert.assertEquals( 2, facets.size()); Assert.assertTrue( facets.contains( new Facet( ComplexApplicationFactory1.FACET_WEB ))); Assert.assertTrue( facets.contains( new Facet( ComplexApplicationFactory1.FACET_DEPLOYABLE ))); }
public static Collection<Facet> findAllFacets( Component component ) { Set<Facet> result = new HashSet<> (); List<Facet> toProcess = new ArrayList<> (); for( Component c : findAllExtendedComponents( component )) toProcess.addAll( c.getFacets()); while( ! toProcess.isEmpty()) { Facet f = toProcess.remove( 0 ); result.add( f ); toProcess.addAll( f.getExtendedFacets()); toProcess.removeAll( result ); } return result; }
ComponentHelpers { public static Collection<Facet> findAllFacets( Component component ) { Set<Facet> result = new HashSet<> (); List<Facet> toProcess = new ArrayList<> (); for( Component c : findAllExtendedComponents( component )) toProcess.addAll( c.getFacets()); while( ! toProcess.isEmpty()) { Facet f = toProcess.remove( 0 ); result.add( f ); toProcess.addAll( f.getExtendedFacets()); toProcess.removeAll( result ); } return result; } }
ComponentHelpers { public static Collection<Facet> findAllFacets( Component component ) { Set<Facet> result = new HashSet<> (); List<Facet> toProcess = new ArrayList<> (); for( Component c : findAllExtendedComponents( component )) toProcess.addAll( c.getFacets()); while( ! toProcess.isEmpty()) { Facet f = toProcess.remove( 0 ); result.add( f ); toProcess.addAll( f.getExtendedFacets()); toProcess.removeAll( result ); } return result; } private  ComponentHelpers(); }
ComponentHelpers { public static Collection<Facet> findAllFacets( Component component ) { Set<Facet> result = new HashSet<> (); List<Facet> toProcess = new ArrayList<> (); for( Component c : findAllExtendedComponents( component )) toProcess.addAll( c.getFacets()); while( ! toProcess.isEmpty()) { Facet f = toProcess.remove( 0 ); result.add( f ); toProcess.addAll( f.getExtendedFacets()); toProcess.removeAll( result ); } return result; } private  ComponentHelpers(); static Component findComponent( Graphs graphs, String name ); static Component findComponent( AbstractApplication app, String name ); static Component findComponentFrom( Component component, String componentName ); static List<String> extractNames( Collection<? extends AbstractType> types ); static boolean isTarget( Component component ); static Collection<Component> findAllChildren( Component component ); static Collection<Component> findAllAncestors( Component component ); static String findComponentInstaller( Component component ); static Map<String,String> findAllExportedVariables( Component component ); static Map<String,String> findAllExportedVariables( AbstractType type ); static Map<String,String> findAllExportedVariables( Graphs graphs ); static Map<String,String> findAllExportedVariables( Facet facet ); static Map<String,ImportedVariable> findAllImportedVariables( Component component ); static Collection<Facet> findAllFacets( Component component ); static List<Component> findAllExtendedComponents( Component component ); static Collection<Facet> findAllExtendedFacets( Facet facet ); static Collection<Facet> findAllExtendingFacets( Facet facet ); static Collection<Component> findAllExtendingComponents( Component component ); static List<Component> findAllComponents( Graphs graphs ); static List<Component> findAllComponents( AbstractApplication app ); static String searchForLoop( Component component ); static String searchForInheritanceCycle( Facet facet ); static String searchForInheritanceCycle( Component component ); static Map<String,Boolean> findComponentDependenciesFor( Component component ); static Map<Component,Boolean> findComponentDependenciesFor( Component component, ApplicationTemplate app ); static Map<Component,Boolean> findComponentsThatDependOn( Component component, ApplicationTemplate app ); }
ComponentHelpers { public static Collection<Facet> findAllFacets( Component component ) { Set<Facet> result = new HashSet<> (); List<Facet> toProcess = new ArrayList<> (); for( Component c : findAllExtendedComponents( component )) toProcess.addAll( c.getFacets()); while( ! toProcess.isEmpty()) { Facet f = toProcess.remove( 0 ); result.add( f ); toProcess.addAll( f.getExtendedFacets()); toProcess.removeAll( result ); } return result; } private  ComponentHelpers(); static Component findComponent( Graphs graphs, String name ); static Component findComponent( AbstractApplication app, String name ); static Component findComponentFrom( Component component, String componentName ); static List<String> extractNames( Collection<? extends AbstractType> types ); static boolean isTarget( Component component ); static Collection<Component> findAllChildren( Component component ); static Collection<Component> findAllAncestors( Component component ); static String findComponentInstaller( Component component ); static Map<String,String> findAllExportedVariables( Component component ); static Map<String,String> findAllExportedVariables( AbstractType type ); static Map<String,String> findAllExportedVariables( Graphs graphs ); static Map<String,String> findAllExportedVariables( Facet facet ); static Map<String,ImportedVariable> findAllImportedVariables( Component component ); static Collection<Facet> findAllFacets( Component component ); static List<Component> findAllExtendedComponents( Component component ); static Collection<Facet> findAllExtendedFacets( Facet facet ); static Collection<Facet> findAllExtendingFacets( Facet facet ); static Collection<Component> findAllExtendingComponents( Component component ); static List<Component> findAllComponents( Graphs graphs ); static List<Component> findAllComponents( AbstractApplication app ); static String searchForLoop( Component component ); static String searchForInheritanceCycle( Facet facet ); static String searchForInheritanceCycle( Component component ); static Map<String,Boolean> findComponentDependenciesFor( Component component ); static Map<Component,Boolean> findComponentDependenciesFor( Component component, ApplicationTemplate app ); static Map<Component,Boolean> findComponentsThatDependOn( Component component, ApplicationTemplate app );  }