Exemplo n.º 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);
  }
Exemplo n.º 2
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);
  }