Пример #1
0
  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);
  }
Пример #2
0
  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);
  }
Пример #3
0
  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);
  }