Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 187242
Collapse All | Expand All

(-)src/org/eclipse/tptp/test/report/birt/internal/ResolveTestExecutions.java (-12 / +86 lines)
Lines 13-30 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.HashMap;
14
import java.util.HashMap;
15
import java.util.Iterator;
15
import java.util.Iterator;
16
import java.util.LinkedList;
17
import java.util.List;
16
import java.util.List;
18
import java.util.Map;
17
import java.util.Map;
19
18
20
import org.eclipse.emf.common.util.BasicEList;
19
import org.eclipse.emf.common.util.BasicEList;
21
import org.eclipse.emf.common.util.EList;
20
import org.eclipse.emf.common.util.EList;
21
import org.eclipse.hyades.models.common.fragments.BVRCombinedFragment;
22
import org.eclipse.hyades.models.common.fragments.BVRInteractionOperand;
23
import org.eclipse.hyades.models.common.interactions.BVRExecutionOccurrence;
24
import org.eclipse.hyades.models.common.interactions.BVRInteractionFragment;
22
import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent;
25
import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent;
23
import org.eclipse.hyades.models.common.testprofile.TPFExecutionHistory;
26
import org.eclipse.hyades.models.common.testprofile.TPFExecutionHistory;
24
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
27
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
28
import org.eclipse.hyades.models.common.testprofile.TPFTest;
25
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
29
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
26
import org.eclipse.hyades.models.common.util.ExecutionUtil;
30
import org.eclipse.hyades.models.common.util.ExecutionUtil;
27
31
32
/**
33
 * Test execution resolver.
34
 * <p>
35
 * 
36
 * 
37
 * @author  Sheldon Lee-Loy
38
 * @author  Paul E. Slauenwhite
39
 * @version August 27, 2007
40
 * @since   August 28, 2007
41
 */
28
public class ResolveTestExecutions {
42
public class ResolveTestExecutions {
29
	
43
	
30
	public static List[] getExecutionResults(EList allTestSuites, TestContextObject context){
44
	public static List[] getExecutionResults(EList allTestSuites, TestContextObject context){
Lines 77-99 Link Here
77
     * Recursively resolves all referenced test suites from the parameter root
91
     * Recursively resolves all referenced test suites from the parameter root
78
     * test suite.
92
     * test suite.
79
     * <p>
93
     * <p>
94
     * Only test suite invocations are considered referenced test suites.
95
     * <p>
80
     * 
96
     * 
81
     * @param testSuite
97
     * @param testSuite
82
     *            The root test suite.
98
     *            The root test suite.
83
     * @return The list of all recursively referenced test suites, including the
99
     * @return The list ({@link TPFTestSuite}) of all recursively referenced test suites, including the
84
     *         root grandparent test suite.
100
     *         parameter root test suite.
85
     */
101
     */
86
    protected static List findAllReferencedTestSuites(TPFTestSuite testSuite) {
102
    protected static List findAllReferencedTestSuites(TPFTestSuite testSuite) {
87
        List referencedTestSuites = new LinkedList();
103
88
        //Step 1. Add the parameter test suite:
104
    	List referencedTestSuites = new ArrayList();
89
        referencedTestSuites.add(testSuite);
105
90
        //Step 2. Add all the referenced test suite(s):
106
    	//Step 1. Add the parameter test suite:
91
        Iterator referencedSuitesIterator = testSuite.getReferencedSuites().iterator();
107
    	referencedTestSuites.add(testSuite);
92
        while (referencedSuitesIterator.hasNext()) {
108
93
            referencedTestSuites.addAll(findAllReferencedTestSuites(((TPFTestSuite) (referencedSuitesIterator.next()))));
109
    	//Step 2. Add all the referenced test suite(s):        
94
        }
110
    	Iterator interactionFragmentsIterator = testSuite.getBehavior().getInteraction().getInteractionFragments().iterator();
95
        return referencedTestSuites;
111
112
    	while(interactionFragmentsIterator.hasNext()){
113
114
    		Iterator testInvocationIterator = findAllTestInvocations(((BVRInteractionFragment)(interactionFragmentsIterator.next()))).iterator();
115
116
    		while(testInvocationIterator.hasNext()){
117
118
    			TPFTest testInvocation = ((TPFTest)(testInvocationIterator.next()));
119
120
    			//Only test suite invocations are considered referenced test suites:
121
    			if (testInvocation instanceof TPFTestSuite) {
122
123
    				TPFTestSuite testSuiteInvocation = ((TPFTestSuite)(testInvocation));
124
125
    				if(!testSuiteInvocation.getId().equals(testSuite.getId())){
126
    					referencedTestSuites.addAll(findAllReferencedTestSuites(testSuiteInvocation));
127
    				}
128
    			}
129
    		}
130
    	}
131
132
    	return referencedTestSuites;
96
    }	
133
    }	
134
135
    /**
136
     * Recursively resolves all test invocations from the parameter root
137
     * interaction fragment.
138
     * <p>
139
     * Test suite and test case invocations are considered test invocations.
140
     * <p>
141
     * 
142
     * @param interactionFragment
143
     *            The root interaction fragment.
144
     * @return The list ({@link TPFTest}) of all recursively referenced test invocations by the
145
     *         parameter root interaction fragment.
146
     */
147
    protected static List findAllTestInvocations(BVRInteractionFragment interactionFragment) {
148
149
    	List testInvocations = new ArrayList();
150
151
    	if (interactionFragment instanceof BVRExecutionOccurrence){
152
    		testInvocations.add(((BVRExecutionOccurrence) (interactionFragment)).getOtherBehavior().getTest());
153
    	}
154
    	else if (interactionFragment instanceof BVRCombinedFragment) {
155
156
    		Iterator interactionOperandsIterator = ((BVRCombinedFragment) (interactionFragment)).getInteractionOperands().iterator();
157
158
    		while (interactionOperandsIterator.hasNext()) {
159
160
    			Iterator interactionFragmentsIterator = ((BVRInteractionOperand) (interactionOperandsIterator.next())).getInteractionFragments().iterator();
161
162
    			while (interactionFragmentsIterator.hasNext()) {
163
    				testInvocations.addAll(findAllTestInvocations(((BVRInteractionFragment) (interactionFragmentsIterator.next()))));
164
    			}
165
    		}
166
    	}
167
168
    	return testInvocations;
169
    }
170
97
    
171
    
98
	/**
172
	/**
99
	 * This method filters the map of TestSuites to ExecutionResults by 
173
	 * This method filters the map of TestSuites to ExecutionResults by 

Return to bug 187242