|
Lines 95-119
Link Here
|
| 95 |
BVRInteractionImpl interaction = (BVRInteractionImpl) notification.getNotifier(); |
95 |
BVRInteractionImpl interaction = (BVRInteractionImpl) notification.getNotifier(); |
| 96 |
BVRInteractionFragmentImpl fragment = null; |
96 |
BVRInteractionFragmentImpl fragment = null; |
| 97 |
List fragments = null; |
97 |
List fragments = null; |
| 98 |
// TPFBehaviorImpl implementor = null; |
|
|
| 99 |
// BVRLifelineImpl selfLifeline = null; |
| 100 |
BVRLifelineImpl lifeline = null; |
98 |
BVRLifelineImpl lifeline = null; |
| 101 |
Iterator iter = null; |
99 |
Iterator iter = null; |
| 102 |
List lifelines = null; |
100 |
List lifelines = null; |
| 103 |
Iterator itLifelines = null; |
101 |
Iterator itLifelines = null; |
| 104 |
// TPFTestSuiteImpl testSuite = null; |
|
|
| 105 |
|
102 |
|
| 106 |
switch(eventType) { |
103 |
switch(eventType) { |
| 107 |
case Notification.ADD: |
104 |
case Notification.ADD: |
| 108 |
fragment = (BVRInteractionFragmentImpl)notification.getNewValue(); |
105 |
fragment = (BVRInteractionFragmentImpl)notification.getNewValue(); |
| 109 |
HyadesUtil.INSTANCE.createSUTInstances(interaction, fragment); |
106 |
HyadesUtil.INSTANCE.createSUTInstances(interaction, fragment); |
| 110 |
|
|
|
| 111 |
// (Add the self lifeline to the the InteractionFragment's lifeline collection. |
| 112 |
// (Convention -- for MessageEnd, caller lifeline is first, then invoked lifeline.) |
| 113 |
// implementor = (TPFBehaviorImpl)interaction.getBehavior(); |
| 114 |
// selfLifeline = implementor.getSelfLifeline(); |
| 115 |
// Add it to the front of the collection |
| 116 |
// fragment.getLifelines().add(0,selfLifeline); |
| 117 |
|
107 |
|
| 118 |
if(fragment instanceof ITestInvocation) |
108 |
if(fragment instanceof ITestInvocation) |
| 119 |
{ |
109 |
{ |
|
Lines 130-189
Link Here
|
| 130 |
} |
120 |
} |
| 131 |
|
121 |
|
| 132 |
break; |
122 |
break; |
| 133 |
case Notification.ADD_MANY: |
|
|
| 134 |
fragments = (List)notification.getNewValue(); |
| 135 |
iter = fragments.iterator(); |
| 136 |
while (iter.hasNext()) { |
| 137 |
fragment = (BVRInteractionFragmentImpl)iter.next(); |
| 138 |
|
| 139 |
// (Add the self lifeline to the the InteractionFragment's lifeline collection. |
| 140 |
// (Convention -- for MessageEnd, caller lifeline is first, then invoked lifeline.) |
| 141 |
// implementor = (TPFBehaviorImpl)interaction.getBehavior(); |
| 142 |
// selfLifeline = implementor.getSelfLifeline(); |
| 143 |
// Add it to the front of the collection |
| 144 |
// fragment.getLifelines().add(0,selfLifeline); |
| 145 |
|
| 146 |
HyadesUtil.INSTANCE.createSUTInstances(interaction, fragment); |
| 147 |
if(fragment instanceof ITestInvocation) |
| 148 |
{ |
| 149 |
ITestSuite test = HyadesUtil.INSTANCE.getTestSuite(((ITestInvocation)fragment).getInvokedTest()); |
| 150 |
ITestSuite owner = (ITestSuite) EcoreUtil.getRootContainer(interaction); |
| 151 |
|
| 152 |
if(owner != null && test != null && !owner.getId().equals(test.getId())) |
| 153 |
{ |
| 154 |
if(!HyadesUtil.INSTANCE.containsSuite(owner.getIReferencedSuites(), test)) |
| 155 |
{ |
| 156 |
owner.getIReferencedSuites().add(test); |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
} |
| 161 |
break; |
| 162 |
case Notification.REMOVE: |
123 |
case Notification.REMOVE: |
| 163 |
fragment = (BVRInteractionFragmentImpl)notification.getOldValue(); |
124 |
fragment = (BVRInteractionFragmentImpl)notification.getOldValue(); |
| 164 |
if(fragment instanceof ITestInvocation) |
|
|
| 165 |
{ |
| 166 |
ITestSuite test = null; |
| 167 |
BVRExecutionOccurrenceImpl executionOccurrenceImpl = (BVRExecutionOccurrenceImpl)fragment; |
| 168 |
if((executionOccurrenceImpl.getOtherBehavior() != null) && (executionOccurrenceImpl.getOtherBehavior().eIsProxy())) |
| 169 |
{ |
| 170 |
TPFBehavior behavior = (TPFBehavior)EcoreUtil.resolve(((BVRExecutionOccurrenceImpl)fragment).getOtherBehavior(), interaction.eResource().getResourceSet()); |
| 171 |
if(behavior != null) |
| 172 |
{ |
| 173 |
test = HyadesUtil.INSTANCE.getTestSuite((ITest)behavior.getTest()); |
| 174 |
} |
| 175 |
} |
| 176 |
else |
| 177 |
{ |
| 178 |
test = HyadesUtil.INSTANCE.getTestSuite(((ITestInvocation)fragment).getInvokedTest()); |
| 179 |
} |
| 180 |
ITestSuite owner = HyadesUtil.INSTANCE.getTestSuite(((TPFBehaviorImpl)interaction.getBehavior()).getOwner()); |
| 181 |
|
| 182 |
if(owner != null && test != null && !hasSuite(interaction.getInteractionFragments(), test, interaction)) |
| 183 |
{ |
| 184 |
owner.getIReferencedSuites().remove(test); |
| 185 |
} |
| 186 |
} |
| 187 |
|
125 |
|
| 188 |
// Iterate over all lifelines in the interaction, and remove |
126 |
// Iterate over all lifelines in the interaction, and remove |
| 189 |
// any references to this interaction fragment from each of them. |
127 |
// any references to this interaction fragment from each of them. |
|
Lines 195-273
Link Here
|
| 195 |
lifeline.getInteractionFragments().remove(fragment); |
133 |
lifeline.getInteractionFragments().remove(fragment); |
| 196 |
} |
134 |
} |
| 197 |
break; |
135 |
break; |
| 198 |
case Notification.REMOVE_MANY: |
|
|
| 199 |
fragments = (List)notification.getOldValue(); |
| 200 |
iter = fragments.iterator(); |
| 201 |
while (iter.hasNext()) { |
| 202 |
fragment = (BVRInteractionFragmentImpl)iter.next(); |
| 203 |
if(fragment instanceof ITestInvocation) |
| 204 |
{ |
| 205 |
ITestSuite test = null; |
| 206 |
if(((BVRExecutionOccurrenceImpl)fragment).getOtherBehavior().eIsProxy()) |
| 207 |
{ |
| 208 |
TPFBehavior behavior = (TPFBehavior)EcoreUtil.resolve(((BVRExecutionOccurrenceImpl)fragment).getOtherBehavior(), interaction.eResource().getResourceSet()); |
| 209 |
if(behavior != null) |
| 210 |
{ |
| 211 |
test = HyadesUtil.INSTANCE.getTestSuite((ITest)behavior.getTest()); |
| 212 |
} |
| 213 |
} |
| 214 |
else |
| 215 |
{ |
| 216 |
test = HyadesUtil.INSTANCE.getTestSuite(((ITestInvocation)fragment).getInvokedTest()); |
| 217 |
} |
| 218 |
ITestSuite owner = HyadesUtil.INSTANCE.getTestSuite(((TPFBehaviorImpl)interaction.getBehavior()).getOwner()); |
| 219 |
|
| 220 |
if(owner != null && test != null && !hasSuite(interaction.getInteractionFragments(), test, interaction)) |
| 221 |
{ |
| 222 |
owner.getIReferencedSuites().remove(test); |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 226 |
// Iterate over all lifelines in the interaction, and remove |
| 227 |
// any references to this interaction fragment from each of them. |
| 228 |
lifelines = interaction.getLifelines(); |
| 229 |
itLifelines = lifelines.iterator(); |
| 230 |
while ( itLifelines.hasNext() ) |
| 231 |
{ |
| 232 |
lifeline = (BVRLifelineImpl)itLifelines.next(); |
| 233 |
lifeline.getInteractionFragments().remove(fragment); |
| 234 |
} |
| 235 |
} |
| 236 |
break; |
| 237 |
} |
136 |
} |
| 238 |
break; |
137 |
break; |
| 239 |
} |
138 |
} |
| 240 |
} |
139 |
} |
| 241 |
} |
140 |
} |
| 242 |
|
141 |
|
| 243 |
private boolean hasSuite(List otherInteractionFragments, ITestSuite suite, BVRInteraction interaction) |
|
|
| 244 |
{ |
| 245 |
Iterator iter = otherInteractionFragments.iterator(); |
| 246 |
while(iter.hasNext()) |
| 247 |
{ |
| 248 |
BVRInteractionFragmentImpl fragment = (BVRInteractionFragmentImpl)iter.next(); |
| 249 |
if(fragment instanceof BVRExecutionOccurrenceImpl) |
| 250 |
{ |
| 251 |
ITestSuite test = null; |
| 252 |
if(((BVRExecutionOccurrenceImpl)fragment).getOtherBehavior().eIsProxy()) |
| 253 |
{ |
| 254 |
TPFBehavior behavior = (TPFBehavior)EcoreUtil.resolve(((BVRExecutionOccurrenceImpl)fragment).getOtherBehavior(), interaction.eResource().getResourceSet()); |
| 255 |
if(behavior != null) |
| 256 |
{ |
| 257 |
test = HyadesUtil.INSTANCE.getTestSuite((ITest)behavior.getTest()); |
| 258 |
} |
| 259 |
} |
| 260 |
else |
| 261 |
{ |
| 262 |
test = HyadesUtil.INSTANCE.getTestSuite(((ITestInvocation)fragment).getInvokedTest()); |
| 263 |
} |
| 264 |
|
| 265 |
if(test.getId().equals(suite.getId())) |
| 266 |
{ |
| 267 |
return true; |
| 268 |
} |
| 269 |
} |
| 270 |
} |
| 271 |
return false; |
| 272 |
} |
| 273 |
} |
142 |
} |