コード例 #1
0
  /** Tests the case of a null operation (that it doesn't throw an NPE). */
  public void test_OperationCallExp_checkArgumentCount_nullOperation_231515() {
    OperationCallExp o = factory.createOperationCallExp();

    o.setReferredOperation(null); // be explicit on the purpose of the test

    OCLExpression arg = factory.createUnspecifiedValueExp();
    o.getArgument().add(arg);
    CollectionType ctype = factory.createOrderedSetType();
    ctype.setElementType(color);
    arg.setType(ctype);

    assertOK(o, ExpressionsValidator.OPERATION_CALL_EXP__ARGUMENT_COUNT);

    o.getArgument().add(factory.createCollectionLiteralExp());

    assertOK(o, ExpressionsValidator.OPERATION_CALL_EXP__ARGUMENT_COUNT);

    o.getArgument().clear();

    assertOK(o, ExpressionsValidator.OPERATION_CALL_EXP__ARGUMENT_COUNT);
  }
コード例 #2
0
  public void test_OperationCallExp_checkArgumentCount() {
    OperationCallExp o = factory.createOperationCallExp();

    EClass fruitUtil = (EClass) fruitPackage.getEClassifier("FruitUtil");
    EOperation oper = fruitUtil.getEOperations().get(0);
    o.setReferredOperation(oper);

    OCLExpression arg = factory.createUnspecifiedValueExp();
    o.getArgument().add(arg);
    CollectionType ctype = factory.createOrderedSetType();
    ctype.setElementType(color);
    arg.setType(ctype);

    assertOK(o, ExpressionsValidator.OPERATION_CALL_EXP__ARGUMENT_COUNT);

    o.getArgument().add(factory.createCollectionLiteralExp());

    assertProblem(o, ExpressionsValidator.OPERATION_CALL_EXP__ARGUMENT_COUNT);

    o.getArgument().clear();

    assertProblem(o, ExpressionsValidator.OPERATION_CALL_EXP__ARGUMENT_COUNT);
  }