01: package org.andromda.metafacades.uml;
02:
03: import junit.framework.TestCase;
04: import org.andromda.translation.ocl.ExpressionKinds;
05:
06: /**
07: * @author Chad Brandon
08: */
09: public class UMLMetafacadeUtilsTest extends TestCase {
10: public void testIsConstraintKind() {
11: final String emptyExpression = "";
12: assertFalse(UMLMetafacadeUtils.isConstraintKind(
13: emptyExpression, ExpressionKinds.BODY));
14: final String bodyExpressionWithName = "context DecisionItem::findRoot():Collection(DecisionItem) body findByRootBody : allInstances() -> select (decisionItem | decisionItem.rootItem = true)";
15: assertTrue(UMLMetafacadeUtils.isConstraintKind(
16: bodyExpressionWithName, ExpressionKinds.BODY));
17: final String bodyExpressionNoName = "context DecisionItem::findRoot():Collection(DecisionItem) body : allInstances() -> select (decisionItem | decisionItem.rootItem = true)";
18: assertTrue(UMLMetafacadeUtils.isConstraintKind(
19: bodyExpressionNoName, ExpressionKinds.BODY));
20: final String bodyExpressionNoColon = "context DecisionItem::findRoot():Collection(DecisionItem) body allInstances() -> select (decisionItem | decisionItem.rootItem = true)";
21: assertFalse(UMLMetafacadeUtils.isConstraintKind(
22: bodyExpressionNoColon, ExpressionKinds.BODY));
23: final String invExpressionNoName = "context CustomerCard\r\n"
24: + "inv: validFrom.isBefore(goodThru)";
25: assertTrue(UMLMetafacadeUtils.isConstraintKind(
26: invExpressionNoName, ExpressionKinds.INV));
27: }
28: }
|