Search in sources :

Example 1 with CONNECTIVITY_ERROR_IDENTIFIER

use of org.mule.runtime.core.api.exception.Errors.Identifiers.CONNECTIVITY_ERROR_IDENTIFIER in project mule by mulesoft.

the class ErrorsDeclarationEnricherTestCase method extensionErrorsInheritFromMuleErrors.

@Test
public void extensionErrorsInheritFromMuleErrors() {
    extensionModel = loadExtension(HeisenbergExtension.class);
    OperationModel cureCancer = getNamedObject(extensionModel.getOperationModels(), "cureCancer");
    assertThat(cureCancer.getErrorModels(), hasItem(hasProperty(TYPE, is(HEALTH.getType()))));
    Optional<ErrorModel> healthError = extensionModel.getErrorModels().stream().filter(errorModel -> errorModel.getType().equals(HEALTH.getType())).findFirst();
    assertThat(healthError.isPresent(), is(true));
    Optional<ErrorModel> optConnectivityError = healthError.get().getParent();
    assertThat(optConnectivityError.isPresent(), is(true));
    ErrorModel connectivityError = optConnectivityError.get();
    assertThat(connectivityError.getType(), is(CONNECTIVITY_ERROR_IDENTIFIER));
    assertThat(connectivityError.getNamespace(), is(HEISENBERG));
    Optional<ErrorModel> optMuleConnectivityError = connectivityError.getParent();
    assertThat(optMuleConnectivityError.isPresent(), is(true));
    ErrorModel muleConnectivityError = optMuleConnectivityError.get();
    assertThat(muleConnectivityError.getType(), is(CONNECTIVITY_ERROR_IDENTIFIER));
    assertThat(muleConnectivityError.getNamespace(), is(MULE_NAMESPACE));
}
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) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Test(org.junit.Test)

Aggregations

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