Search in sources :

Example 11 with ErrorModel

use of org.mule.runtime.api.meta.model.error.ErrorModel in project mule by mulesoft.

the class ErrorsModelFactory method addConnectivityErrors.

private void addConnectivityErrors(Map<String, ErrorModel> errorModelMap) {
    ErrorModel connectivityError = toErrorModel(CONNECTIVITY, errorModelMap);
    String key = connectivityError.toString();
    if (!errorModelMap.containsKey(key)) {
        errorModelMap.put(key, connectivityError);
    }
    ErrorModel retryExhaustedError = toErrorModel(RETRY_EXHAUSTED, errorModelMap);
    String retry = retryExhaustedError.toString();
    if (!errorModelMap.containsKey(retry)) {
        errorModelMap.put(retry, retryExhaustedError);
    }
}
Also used : ErrorModel(org.mule.runtime.api.meta.model.error.ErrorModel)

Example 12 with ErrorModel

use of org.mule.runtime.api.meta.model.error.ErrorModel in project mule by mulesoft.

the class ErrorsDeclarationEnricherTestCase method operationInheritsExtensionErrorThrows.

@Test
public void operationInheritsExtensionErrorThrows() {
    extensionModel = loadExtension(HeisenbergWithExtensionThrows.class);
    OperationModel someOperation = extensionModel.getOperationModel("someOperation").get();
    Optional<ErrorModel> operationError = someOperation.getErrorModels().stream().filter(errorModel -> errorModel.getType().equals(EXTENSION.getType())).findFirst();
    assertThat(operationError.isPresent(), is(true));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Optional.empty(java.util.Optional.empty) HEALTH(org.mule.test.heisenberg.extension.HeisenbergErrors.HEALTH) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Operations(org.mule.runtime.extension.api.annotation.Operations) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Extension(org.mule.runtime.extension.api.annotation.Extension) HeisenbergOperations(org.mule.test.heisenberg.extension.HeisenbergOperations) HeisenbergScopes(org.mule.test.heisenberg.extension.HeisenbergScopes) EXTENSION(org.mule.runtime.module.extension.internal.loader.enricher.LevelErrorTypes.EXTENSION) KillingOperations(org.mule.test.heisenberg.extension.KillingOperations) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) ErrorModel(org.mule.runtime.api.meta.model.error.ErrorModel) AbstractMuleTestCase(org.mule.tck.junit4.AbstractMuleTestCase) Collections.singleton(java.util.Collections.singleton) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) CONNECTIVITY_ERROR_IDENTIFIER(org.mule.runtime.core.api.exception.Errors.Identifiers.CONNECTIVITY_ERROR_IDENTIFIER) ExpectedException.none(org.junit.rules.ExpectedException.none) EnricherTestUtils.getNamedObject(org.mule.runtime.module.extension.internal.loader.enricher.EnricherTestUtils.getNamedObject) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) ExpectedException(org.junit.rules.ExpectedException) ErrorTypes(org.mule.runtime.extension.api.annotation.error.ErrorTypes) MuleExtensionUtils.loadExtension(org.mule.runtime.module.extension.api.util.MuleExtensionUtils.loadExtension) Set(java.util.Set) Throws(org.mule.runtime.extension.api.annotation.error.Throws) Test(org.junit.Test) OPERATION(org.mule.runtime.module.extension.internal.loader.enricher.LevelErrorTypes.OPERATION) ANY(org.mule.runtime.extension.api.error.MuleErrors.ANY) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ErrorTypeDefinition(org.mule.runtime.extension.api.error.ErrorTypeDefinition) MoneyLaunderingOperation(org.mule.test.heisenberg.extension.MoneyLaunderingOperation) Rule(org.junit.Rule) HeisenbergErrors(org.mule.test.heisenberg.extension.HeisenbergErrors) ErrorTypeProvider(org.mule.runtime.extension.api.annotation.error.ErrorTypeProvider) Optional(java.util.Optional) HeisenbergRouters(org.mule.test.heisenberg.extension.HeisenbergRouters) IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) ErrorModel(org.mule.runtime.api.meta.model.error.ErrorModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Test(org.junit.Test)

Aggregations

ErrorModel (org.mule.runtime.api.meta.model.error.ErrorModel)12 Test (org.junit.Test)7 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)5 Collections.singleton (java.util.Collections.singleton)3 Optional (java.util.Optional)3 Optional.empty (java.util.Optional.empty)3 Set (java.util.Set)3 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)3 CoreMatchers.hasItem (org.hamcrest.CoreMatchers.hasItem)3 CoreMatchers.is (org.hamcrest.CoreMatchers.is)3 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)3 Matchers.hasProperty (org.hamcrest.Matchers.hasProperty)3 Rule (org.junit.Rule)3 ExpectedException (org.junit.rules.ExpectedException)3 ExpectedException.none (org.junit.rules.ExpectedException.none)3 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)3 CONNECTIVITY_ERROR_IDENTIFIER (org.mule.runtime.core.api.exception.Errors.Identifiers.CONNECTIVITY_ERROR_IDENTIFIER)3 Extension (org.mule.runtime.extension.api.annotation.Extension)3 Operations (org.mule.runtime.extension.api.annotation.Operations)3 ErrorTypeProvider (org.mule.runtime.extension.api.annotation.error.ErrorTypeProvider)3