ComponentHelpers { public static Collection<Component> findAllChildren( Component component ) { return findAncestorsOrChildren( component, true ); } 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 );  }
@Test public void testFindAllChildren_testApp() { TestApplicationTemplate app = new TestApplicationTemplate(); Collection<Component> children = ComponentHelpers.findAllChildren( app.getTomcat().getComponent()); Assert.assertEquals( 1, children.size()); Assert.assertTrue( children.contains( app.getWar().getComponent())); children = ComponentHelpers.findAllChildren( app.getTomcatVm().getComponent()); Assert.assertEquals( 2, children.size()); Assert.assertTrue( children.contains( app.getTomcat().getComponent())); Assert.assertTrue( children.contains( app.getMySql().getComponent())); children = ComponentHelpers.findAllChildren( app.getMySqlVm().getComponent()); Assert.assertEquals( 2, children.size()); Assert.assertTrue( children.contains( app.getTomcat().getComponent())); Assert.assertTrue( children.contains( app.getMySql().getComponent())); Assert.assertEquals( 0, ComponentHelpers.findAllChildren( app.getMySql().getComponent()).size()); Assert.assertEquals( 0, ComponentHelpers.findAllChildren( app.getWar().getComponent()).size()); }