@Test public void testFindAllScopedInstances() { Instance root = new Instance( "root" ).component( new Component( "Root" ).installerName( Constants.TARGET_INSTALLER )); Instance server = new Instance( "server" ).component( new Component( "Server" ).installerName( Constants.TARGET_INSTALLER )); Instance app1 = new Instance( "app1" ).component( new Component( "Application" ).installerName( "whatever" )); Instance app2 = new Instance( "app2" ).component( new Component( "Application" ).installerName( Constants.TARGET_INSTALLER )); Instance server2 = new Instance( "server2" ).component( new Component( "Server" ).installerName( "whatever" )); InstanceHelpers.insertChild( root, server ); InstanceHelpers.insertChild( root, server2 ); InstanceHelpers.insertChild( server, app1 ); InstanceHelpers.insertChild( server2, app2 ); Application app = new Application( "test", new ApplicationTemplate()); app.getRootInstances().add( root ); List<Instance> instances = InstanceHelpers.findAllScopedInstances( app ); Assert.assertEquals( 3, instances.size()); Assert.assertTrue( instances.contains( root )); Assert.assertTrue( instances.contains( server )); Assert.assertTrue( instances.contains( app2 )); }
public static List<Instance> findAllScopedInstances( AbstractApplication app ) { List<Instance> instanceList = new ArrayList<> (); List<Instance> todo = new ArrayList<> (); todo.addAll( app.getRootInstances()); while( ! todo.isEmpty()) { Instance current = todo.remove( 0 ); todo.addAll( current.getChildren()); if( isTarget( current )) instanceList.add( current ); } return instanceList; }
InstanceHelpers { public static List<Instance> findAllScopedInstances( AbstractApplication app ) { List<Instance> instanceList = new ArrayList<> (); List<Instance> todo = new ArrayList<> (); todo.addAll( app.getRootInstances()); while( ! todo.isEmpty()) { Instance current = todo.remove( 0 ); todo.addAll( current.getChildren()); if( isTarget( current )) instanceList.add( current ); } return instanceList; } }
InstanceHelpers { public static List<Instance> findAllScopedInstances( AbstractApplication app ) { List<Instance> instanceList = new ArrayList<> (); List<Instance> todo = new ArrayList<> (); todo.addAll( app.getRootInstances()); while( ! todo.isEmpty()) { Instance current = todo.remove( 0 ); todo.addAll( current.getChildren()); if( isTarget( current )) instanceList.add( current ); } return instanceList; } private  InstanceHelpers(); }
InstanceHelpers { public static List<Instance> findAllScopedInstances( AbstractApplication app ) { List<Instance> instanceList = new ArrayList<> (); List<Instance> todo = new ArrayList<> (); todo.addAll( app.getRootInstances()); while( ! todo.isEmpty()) { Instance current = todo.remove( 0 ); todo.addAll( current.getChildren()); if( isTarget( current )) instanceList.add( current ); } return instanceList; } private  InstanceHelpers(); static String computeInstancePath( Instance inst ); static boolean haveSamePath( Instance i1, Instance i2 ); static String findInstanceName( String instancePath ); static List<Instance> buildHierarchicalList( Instance inst ); static void insertChild( Instance parent, Instance child ); static Map<String,String> findAllExportedVariables( Instance instance ); static Instance findInstanceByPath( AbstractApplication application, String instancePath ); static Instance findInstanceByPath( Instance rootInstance, String instancePath ); static List<Instance> findInstancesByComponentName( AbstractApplication application, String componentName ); static Instance findRootInstance( Instance instance ); static Instance findScopedInstance( Instance instance ); static List<Instance> findAllScopedInstances( AbstractApplication app ); static List<Instance> getAllInstances( AbstractApplication application ); static boolean tryToInsertChildInstance( AbstractApplication application, Instance parentInstance, Instance childInstance ); static boolean hasChildWithThisName( AbstractApplication application, Instance parentInstance, String nameToSearch ); static File findInstanceDirectoryOnAgent( Instance instance ); static int countInstances( String instancePath ); static Instance replicateInstance( Instance instance ); static boolean isTarget( Instance instance ); static void removeOffScopeInstances( Instance scopedInstance ); static String findRootInstancePath( String scopedInstancePath ); static void fixOverriddenExports( Instance instance ); }
InstanceHelpers { public static List<Instance> findAllScopedInstances( AbstractApplication app ) { List<Instance> instanceList = new ArrayList<> (); List<Instance> todo = new ArrayList<> (); todo.addAll( app.getRootInstances()); while( ! todo.isEmpty()) { Instance current = todo.remove( 0 ); todo.addAll( current.getChildren()); if( isTarget( current )) instanceList.add( current ); } return instanceList; } private  InstanceHelpers(); static String computeInstancePath( Instance inst ); static boolean haveSamePath( Instance i1, Instance i2 ); static String findInstanceName( String instancePath ); static List<Instance> buildHierarchicalList( Instance inst ); static void insertChild( Instance parent, Instance child ); static Map<String,String> findAllExportedVariables( Instance instance ); static Instance findInstanceByPath( AbstractApplication application, String instancePath ); static Instance findInstanceByPath( Instance rootInstance, String instancePath ); static List<Instance> findInstancesByComponentName( AbstractApplication application, String componentName ); static Instance findRootInstance( Instance instance ); static Instance findScopedInstance( Instance instance ); static List<Instance> findAllScopedInstances( AbstractApplication app ); static List<Instance> getAllInstances( AbstractApplication application ); static boolean tryToInsertChildInstance( AbstractApplication application, Instance parentInstance, Instance childInstance ); static boolean hasChildWithThisName( AbstractApplication application, Instance parentInstance, String nameToSearch ); static File findInstanceDirectoryOnAgent( Instance instance ); static int countInstances( String instancePath ); static Instance replicateInstance( Instance instance ); static boolean isTarget( Instance instance ); static void removeOffScopeInstances( Instance scopedInstance ); static String findRootInstancePath( String scopedInstancePath ); static void fixOverriddenExports( Instance instance );  }