Skip to content

Commit 2696368

Browse files
committed
Issue FUML15-16 - Cleared feature values when object is destroyed.
1 parent 28a0b44 commit 2696368

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

org.modeldriven.fuml/src/main/java/fuml/semantics/actions/DestroyObjectActionActivation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class DestroyObjectActionActivation extends
3030

3131
public void doAction() {
3232
// Get the value on the target input pin.
33-
// If the value is not a reference, the action has no effect.
33+
// If the value is not a reference, then the action has no effect.
3434
// Otherwise, do the following.
3535
// If isDestroyLinks is true, destroy all links in which the referent
3636
// participates.
@@ -115,8 +115,8 @@ public Value getCompositeValue(
115115
while (compositeValue == null & i <= linkFeatureValues.size()) {
116116
FeatureValue featureValue = linkFeatureValues.getValue(i - 1);
117117
Value value = featureValue.values.getValue(0);
118-
if (!value.equals(reference)
119-
& ((Property) featureValue.feature).aggregation == AggregationKind.composite) {
118+
if (!value.equals(reference) &
119+
((Property) featureValue.feature).aggregation == AggregationKind.composite) {
120120
compositeValue = value;
121121
}
122122
i = i + 1;

org.modeldriven.fuml/src/main/java/fuml/semantics/structuredclassifiers/Object_.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void send(
6464
} // send
6565

6666
public void destroy() {
67-
// Stop the object activation (if any), clear all types and destroy the
68-
// object as an extensional value.
67+
// Stop the object activation (if any), clear all types and feature values,
68+
// and destroy the object as an extensional value.
6969

7070
Debug.println("[destroy] object = " + this.identifier);
7171

@@ -75,6 +75,7 @@ public void destroy() {
7575
}
7676

7777
this.types.clear();
78+
this.featureValues.clear();
7879
super.destroy();
7980
} // destroy
8081

org.modeldriven.fuml/src/test/java/org/modeldriven/fuml/test/model/ExecutionTestCase.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import fuml.semantics.commonbehavior.ParameterValueList;
1717
import fuml.semantics.simpleclassifiers.BooleanValue;
1818
import fuml.semantics.simpleclassifiers.FeatureValueList;
19+
import fuml.semantics.simpleclassifiers.StructuredValue;
1920
import fuml.semantics.structuredclassifiers.ExtensionalValueList;
2021
import fuml.semantics.structuredclassifiers.Reference;
2122
import fuml.semantics.values.Value;
@@ -152,7 +153,9 @@ public void testTestClassObjectDestroyer() throws Exception {
152153

153154
assertTrue("One output value", output.size() == 1 && output.get(0).values.size() == 1);
154155
Value value = output.get(0).values.get(0);
156+
assertTrue("value instanceof StructureValue", value instanceof StructuredValue);
155157
assertTrue("value.getTypes().isEmpty()", value.getTypes().isEmpty());
158+
assertTrue("value.getFeatureValues().isEmpty()", ((StructuredValue)value).getFeatureValues().isEmpty());
156159
}
157160

158161
public void testTestCompositeObjectDestroyer() throws Exception {
@@ -163,15 +166,24 @@ public void testTestCompositeObjectDestroyer() throws Exception {
163166

164167
ValueList compositeOut = output.get(0).values;
165168
assertEquals("compositeOut.size()", 1, compositeOut.size());
166-
assertTrue("compositeOut.getTypes().isEmpty()", compositeOut.get(0).getTypes().isEmpty());
167-
169+
Value value = compositeOut.get(0);
170+
assertTrue("compositeOut instanceof StructuredValue", value instanceof StructuredValue);
171+
assertTrue("compositeOut.getTypes().isEmpty()", value.getTypes().isEmpty());
172+
assertTrue("compositeOut.getFeatureValues().isEmpty()", ((StructuredValue)value).getFeatureValues().isEmpty());
173+
168174
ValueList object1Out = output.get(1).values;
169175
assertEquals("object1Out.size()", 1, object1Out.size());
170-
assertTrue("object1Out.getTypes().isEmpty()", object1Out.get(0).getTypes().isEmpty());
176+
value = object1Out.get(0);
177+
assertTrue("object1Out instanceof StructuredValue", value instanceof StructuredValue);
178+
assertTrue("object1Out.getTypes().isEmpty()", value.getTypes().isEmpty());
179+
assertTrue("object1Out.getFeatureValues().isEmpty()", ((StructuredValue)value).getFeatureValues().isEmpty());
171180

172181
ValueList object2Out = output.get(2).values;
173182
assertEquals("object2Out.size()", 1, object2Out.size());
174-
assertTrue("object2Out.getTypes().isEmpty()", object2Out.get(0).getTypes().isEmpty());
183+
value = object2Out.get(0);
184+
assertTrue("object2Out instanceof StructuredValue", value instanceof StructuredValue);
185+
assertTrue("object2Out.getTypes().isEmpty()", value.getTypes().isEmpty());
186+
assertTrue("object2Out.getFeatureValues().isEmpty()", ((StructuredValue)value).getFeatureValues().isEmpty());
175187

176188
ValueList assocOut = output.get(3).values;
177189
assertEquals("assocOut.size()", 0, assocOut.size());

0 commit comments

Comments
 (0)