コード例 #1
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);
  }
コード例 #2
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);
  }
コード例 #3
0
  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);
  }