1 /** 2 *Class:jsystem.framework.scenario.MultipleScenarioOps 3 * @param rootScenario 4 * @param scenarioParentName 5 * @param indexToInsert 6 * where to locate new test 7 * @param testToAdd 8 * the test to add 9 * @param currentTestIndex 10 */ 11 public static ArrayList<JTest> addTestToScenario(Scenario rootScenario, Scenario scenarioToAddTo, 12 ArrayList<Integer> containersPath, JTest testToAdd, int currentTestIndex) throws Exception { 13 14 ArrayList<JTest> testsToReturn = new ArrayList<JTest>(); 15 JTest cloneTest; 16 17 List<Scenario> allScenarios = ScenarioHelpers.getAllScenarios(rootScenario); 18 allScenarios.add(rootScenario); 19 20 for (Scenario scenario: allScenarios) { 21 if (scenario.getName().equals(scenarioToAddTo.getName())) { 22 cloneTest = testToAdd.cloneTest(); 23 cloneTest.setUUID(testToAdd.getUUID()); 24 testsToReturn.add(cloneTest); 25 JTestContainer pointer = scenario; 26 int finalIndexToInsert = containersPath.get(0); 27 28 Iterator<Integer> iter = containersPath.iterator(); 29 while (iter.hasNext()) { 30 finalIndexToInsert = iter.next(); 31 if (iter.hasNext()) { 32 pointer = (JTestContainer)pointer.rootTests.get(finalIndexToInsert); 33 } 34 } 35 pointer.addTest(cloneTest, finalIndexToInsert); 36 } 37 } 38 rootScenario.updateAllTests(); 39 return testsToReturn; 40 }
1 /** 2 * Class:jsystem.framework.scenario.JTestContainer 3 * Scenario model update and querying methods 4 * 5 */ 6 public int getRootIndex(JTest test) { 7 if (test == null) { 8 return -1; 9 } 10 for (int i = 0; i < rootTests.size(); i++) { 11 if (test.equals(rootTests.elementAt(i))) { 12 return i; 13 } 14 } 15 return -1; 16 }
1 /** 2 *Class:jsystem.framework.scenario.Scenario 3 */ 4 @Override 5 public Scenario getMyScenario() { 6 return this; 7 }
1 /**Class:jsystem.framework.scenario.ScenariosManager 2 * @return Returns the currentScenario. 3 */ 4 public synchronized Scenario getCurrentScenario() { 5 if (currentScenario == null) { 6 try { 7 currentScenario = getScenario(null); 8 } catch (Exception e) { 9 log.log(Level.SEVERE, "Unable to init scenario", e); 10 lastException = e; 11 } 12 } 13 return currentScenario; 14 }
1 /** 2 *Class:jsystem.framework.scenario.Scenario 3 */ 4 @Override 5 public Scenario getParentScenario() { 6 if (isRoot()) { 7 return null; 8 } 9 return getParent().getMyScenario(); 10 }
1 /** 2 *Class:jsystem.framework.scenario.MultipleScenarioOps 3 * add test to all of scenario`s instances 4 * TODO: new doc 5 * 6 * @param rootScenario 7 * @param scenarioParentName 8 * @param indexToInsert 9 * where to locate new test 10 * @param testToAdd 11 * the test to add 12 * @param currentTestIndex 13 */ 14 public static ArrayList<JTest> addTestToScenario(Scenario rootScenario, Scenario scenarioToAddTo, 15 ArrayList<Integer> containersPath, JTest testToAdd, int currentTestIndex) throws Exception { 16 17 ArrayList<JTest> testsToReturn = new ArrayList<JTest>(); 18 JTest cloneTest; 19 20 List<Scenario> allScenarios = ScenarioHelpers.getAllScenarios(rootScenario); 21 allScenarios.add(rootScenario); 22 23 for (Scenario scenario: allScenarios) { 24 if (scenario.getName().equals(scenarioToAddTo.getName())) { 25 cloneTest = testToAdd.cloneTest(); 26 cloneTest.setUUID(testToAdd.getUUID()); 27 testsToReturn.add(cloneTest); 28 JTestContainer pointer = scenario; 29 int finalIndexToInsert = containersPath.get(0); 30 31 Iterator<Integer> iter = containersPath.iterator(); 32 while (iter.hasNext()) { 33 finalIndexToInsert = iter.next(); 34 if (iter.hasNext()) { 35 pointer = (JTestContainer)pointer.rootTests.get(finalIndexToInsert); 36 } 37 } 38 pointer.addTest(cloneTest, finalIndexToInsert); 39 } 40 } 41 rootScenario.updateAllTests(); 42 return testsToReturn; 43 }