public void test_MessageExp_checkHasOperationOrSignal() { MessageExp m = factory.createMessageExp(); CallOperationAction coa = factory.createCallOperationAction(); coa.setOperation(fruit_ripen); SendSignalAction ssa = factory.createSendSignalAction(); ssa.setSignal(stem); m.setCalledOperation(coa); assertOK(m, ExpressionsValidator.MESSAGE_EXP__HAS_OPERATION_OR_SIGNAL); m.setSentSignal(ssa); assertProblem(m, ExpressionsValidator.MESSAGE_EXP__HAS_OPERATION_OR_SIGNAL); m.setCalledOperation(null); assertOK(m, ExpressionsValidator.MESSAGE_EXP__HAS_OPERATION_OR_SIGNAL); m.setSentSignal(null); assertProblem(m, ExpressionsValidator.MESSAGE_EXP__HAS_OPERATION_OR_SIGNAL); }
public void test_MessageExp_checkOperationArguments() { MessageExp m = factory.createMessageExp(); CallOperationAction action = factory.createCallOperationAction(); m.setCalledOperation(action); action.setOperation(fruit_ripen); UnspecifiedValueExp arg = factory.createUnspecifiedValueExp(); arg.setType(getOCLStandardLibrary().getBoolean()); m.getArgument().add(arg); assertProblem(m, ExpressionsValidator.MESSAGE_EXP__OPERATION_ARGUMENTS); arg.setType(color); assertOK(m, ExpressionsValidator.MESSAGE_EXP__OPERATION_ARGUMENTS); // no-arg operation action.setOperation(fruit_newFruit); // wrong number of message args assertProblem(m, ExpressionsValidator.MESSAGE_EXP__OPERATION_ARGUMENTS); m.getArgument().clear(); assertOK(m, ExpressionsValidator.MESSAGE_EXP__OPERATION_ARGUMENTS); }
public void test_MessageExp_checkTargetNotCollection() { MessageExp m = factory.createMessageExp(); CallOperationAction action = factory.createCallOperationAction(); m.setCalledOperation(action); action.setOperation(fruit_ripen); UnspecifiedValueExp arg = factory.createUnspecifiedValueExp(); arg.setType(color); m.getArgument().add(arg); OCLExpression target = factory.createBooleanLiteralExp(); m.setTarget(target); target.setType(factory.createSequenceType()); assertProblem(m, ExpressionsValidator.MESSAGE_EXP__TARGET_NOT_COLLECTION); target.setType(fruit); assertOK(m, ExpressionsValidator.MESSAGE_EXP__TARGET_NOT_COLLECTION); }
public void test_MessageExp_checkSignalArguments() { expectModified = true; MessagingFruitEnvironmentFactory envFactory = new MessagesTest.MessagingFruitEnvironmentFactory(this); ocl.dispose(); ocl = OCL.newInstance(envFactory); helper = ocl.createOCLHelper(); ((InitEnvironment) ocl.getEnvironment()).init(); MessageExp m = factory.createMessageExp(); SendSignalAction action = factory.createSendSignalAction(); m.setSentSignal(action); EClass drop = (EClass) fruitPackage.getEClassifier("Drop"); assertNotNull(drop); action.setSignal(drop); UnspecifiedValueExp arg = factory.createUnspecifiedValueExp(); arg.setType(getOCLStandardLibrary().getInteger()); m.getArgument().add(arg); arg = factory.createUnspecifiedValueExp(); arg.setType(getOCLStandardLibrary().getBoolean()); m.getArgument().add(arg); assertProblem(m, ExpressionsValidator.MESSAGE_EXP__SIGNAL_ARGUMENTS); arg.setType(stem); assertOK(m, ExpressionsValidator.MESSAGE_EXP__SIGNAL_ARGUMENTS); // wrong number of arguments m.getArgument().remove(arg); assertProblem(m, ExpressionsValidator.MESSAGE_EXP__SIGNAL_ARGUMENTS); }