munit генерирует конкретное исключение

Я пытаюсь создать исключение Filter Unaccepted Exception в munit, чтобы проверить свою обработку ошибок, но я получаю эту ошибку

org.mule.api.MessagingException: Failed to invoke throw-an.
at get_data_filter_unaccepted_exception-test.mock:throw-an{doc:name=Throw unaccepted Exception, exception-ref=#[new org.mule.api.routing.filter.FilterUnacceptedException()], whenCalling=.*:.*}(get_data_from_qcfc-test-suite.xml:316)
at appleFlow.munit:test{initialState=started, description=Test, ignore=false, abstract=false, id=MunitTestFlow$$EnhancerByMUNIT$$904837f0{get_data_filter_unaccepted_exception-test}}(get_data_from_qcfc-test-suite.xml:315)
Caused by: org.mule.api.expression.ExpressionRuntimeException: Execution of the expression "new org.mule.api.routing.filter.FilterUnacceptedException()" failed.
    at org.mule.el.mvel.MVELExpressionLanguage.evaluateInternal(MVELExpressionLanguage.java:232)

Это мое исключение

<mock:when messageProcessor=".*:.*" doc:name="Mock API Token Web Service Call">
        <mock:with-attributes>
            <mock:with-attribute name="doc:name" whereValue="#['Get API Token']"/>
        </mock:with-attributes>
        <mock:then-return payload="#[getResource('api_token_success.xml').asString()]" mimeType="application/xml"/>

    </mock:when>

Я думаю, это из-за моего заявления MEL

#[new org.mule.api.routing.filter.FilterUnacceptedException()]

person Dangson    schedule 06.07.2016    source источник


Ответы (2)


Вы можете использовать отличный компонент, чтобы выбросить такое исключение

<scripting:component doc:name="Throw Exception">
        <scripting:script engine="Groovy"><![CDATA[throw new org.mule.api.routing.filter.FilterUnacceptedException(); ]]></scripting:script>
    </scripting:component>

Надеюсь, это поможет.

/T

person Tony K    schedule 07.07.2016

Я не вижу вызова throw-an во вставленном вами фрагменте.

В любом случае, конструктор аргументов для org.mule.api.routing.filter.FilterUnacceptedException не является общедоступным, попробуйте использовать #[new org.mule.api.routing.filter.FilterUnacceptedException('Some message')]

person Manik Magar    schedule 06.07.2016