Search in sources :

Example 16 with Component

use of org.mule.runtime.api.component.Component in project mule by mulesoft.

the class DefaultsConfigurationBuilder method doConfigure.

@Override
protected void doConfigure(MuleContext muleContext) throws Exception {
    MuleRegistry registry = ((MuleContextWithRegistries) muleContext).getRegistry();
    new SimpleRegistryBootstrap(APP, muleContext).initialise();
    configureQueueManager(muleContext);
    registry.registerObject(OBJECT_MULE_CONTEXT, muleContext);
    registerObject(OBJECT_SECURITY_MANAGER, new DefaultMuleSecurityManager(), muleContext);
    registerObject(BASE_IN_MEMORY_OBJECT_STORE_KEY, createDefaultInMemoryObjectStore(), muleContext);
    registerObject(BASE_PERSISTENT_OBJECT_STORE_KEY, createDefaultPersistentObjectStore(), muleContext);
    registerLocalObjectStoreManager(muleContext, registry);
    registerObject(OBJECT_SCHEDULER_POOLS_CONFIG, SchedulerContainerPoolsConfig.getInstance(), muleContext);
    registerObject(OBJECT_SCHEDULER_BASE_CONFIG, config().withPrefix(muleContext.getConfiguration().getId()).withShutdownTimeout(() -> muleContext.getConfiguration().getShutdownTimeout(), MILLISECONDS), muleContext);
    registerObject(OBJECT_STORE_MANAGER, new MuleObjectStoreManager(), muleContext);
    registerObject(OBJECT_DEFAULT_MESSAGE_PROCESSING_MANAGER, new MuleMessageProcessingManager(), muleContext);
    registerObject(OBJECT_MULE_STREAM_CLOSER_SERVICE, new DefaultStreamCloserService(), muleContext);
    registerObject(OBJECT_LOCK_PROVIDER, new SingleServerLockProvider(), muleContext);
    registerObject(OBJECT_LOCK_FACTORY, new MuleLockFactory(), muleContext);
    registerObject(OBJECT_PROCESSING_TIME_WATCHER, new DefaultProcessingTimeWatcher(), muleContext);
    registerObject(OBJECT_DEFAULT_RETRY_POLICY_TEMPLATE, new NoRetryPolicyTemplate(), muleContext);
    registerObject(OBJECT_CONVERTER_RESOLVER, new DynamicDataTypeConversionResolver(muleContext), muleContext);
    registerObject(DEFAULT_OBJECT_SERIALIZER_NAME, new JavaObjectSerializer(), muleContext);
    registerObject(OBJECT_EXPRESSION_LANGUAGE, new MVELExpressionLanguage(muleContext), muleContext);
    StreamingManager streamingManager = new DefaultStreamingManager();
    registerObject(OBJECT_STREAMING_MANAGER, streamingManager, muleContext);
    registerObject(OBJECT_EXPRESSION_MANAGER, new DefaultExpressionManager(), muleContext);
    registerObject(OBJECT_TIME_SUPPLIER, new LocalTimeSupplier(), muleContext);
    registerObject(OBJECT_CONNECTION_MANAGER, new DefaultConnectionManager(muleContext), muleContext);
    registerObject(METADATA_SERVICE_KEY, new MuleMetadataService(), muleContext);
    registerObject(VALUE_PROVIDER_SERVICE_KEY, new MuleValueProviderService(), muleContext);
    registerObject(PROCESSOR_INTERCEPTOR_MANAGER_REGISTRY_KEY, new DefaultProcessorInterceptorManager(), muleContext);
    registerObject(OBJECT_NOTIFICATION_DISPATCHER, new DefaultNotificationDispatcher(), muleContext);
    registerObject(NotificationListenerRegistry.REGISTRY_KEY, new DefaultNotificationListenerRegistry(), muleContext);
    registerObject(EventContextService.REGISTRY_KEY, new DefaultEventContextService(), muleContext);
    registerObject(OBJECT_TRANSACTION_FACTORY_LOCATOR, new TransactionFactoryLocator(), muleContext);
    registerObject(ComponentInitialStateManager.SERVICE_ID, new ComponentInitialStateManager() {

        @Override
        public boolean mustStartMessageSource(Component component) {
            return true;
        }
    }, muleContext);
}
Also used : TransactionFactoryLocator(org.mule.runtime.core.internal.transaction.TransactionFactoryLocator) DefaultEventContextService(org.mule.runtime.core.internal.event.DefaultEventContextService) DefaultConnectionManager(org.mule.runtime.core.internal.connection.DefaultConnectionManager) MuleMessageProcessingManager(org.mule.runtime.core.internal.execution.MuleMessageProcessingManager) DefaultNotificationDispatcher(org.mule.runtime.core.internal.context.notification.DefaultNotificationDispatcher) DefaultNotificationListenerRegistry(org.mule.runtime.core.internal.context.notification.DefaultNotificationListenerRegistry) NoRetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate) LocalTimeSupplier(org.mule.runtime.core.internal.time.LocalTimeSupplier) MuleMetadataService(org.mule.runtime.core.internal.metadata.MuleMetadataService) Component(org.mule.runtime.api.component.Component) DynamicDataTypeConversionResolver(org.mule.runtime.core.internal.transformer.DynamicDataTypeConversionResolver) MuleValueProviderService(org.mule.runtime.core.internal.value.MuleValueProviderService) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) MuleObjectStoreManager(org.mule.runtime.core.internal.util.store.MuleObjectStoreManager) SingleServerLockProvider(org.mule.runtime.core.internal.lock.SingleServerLockProvider) DefaultProcessingTimeWatcher(org.mule.runtime.core.internal.management.stats.DefaultProcessingTimeWatcher) MVELExpressionLanguage(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguage) JavaObjectSerializer(org.mule.runtime.core.internal.serialization.JavaObjectSerializer) MuleLockFactory(org.mule.runtime.core.internal.lock.MuleLockFactory) ComponentInitialStateManager(org.mule.runtime.api.deployment.management.ComponentInitialStateManager) DefaultMuleSecurityManager(org.mule.runtime.core.internal.security.DefaultMuleSecurityManager) DefaultExpressionManager(org.mule.runtime.core.internal.el.DefaultExpressionManager) DefaultProcessorInterceptorManager(org.mule.runtime.core.internal.processor.interceptor.DefaultProcessorInterceptorManager) DefaultStreamCloserService(org.mule.runtime.core.internal.util.DefaultStreamCloserService) StreamingManager(org.mule.runtime.core.api.streaming.StreamingManager) DefaultStreamingManager(org.mule.runtime.core.api.streaming.DefaultStreamingManager) MuleRegistry(org.mule.runtime.core.internal.registry.MuleRegistry) DefaultStreamingManager(org.mule.runtime.core.api.streaming.DefaultStreamingManager) SimpleRegistryBootstrap(org.mule.runtime.core.internal.config.bootstrap.SimpleRegistryBootstrap)

Example 17 with Component

use of org.mule.runtime.api.component.Component in project mule by mulesoft.

the class ApplicationModel method resolveComponentTypes.

/**
 * Resolves the types of each component model when possible.
 */
public void resolveComponentTypes() {
    // TODO MULE-13894 enable this once changes are completed and no componentBuildingDefinition is needed
    // checkState(componentBuildingDefinitionRegistry.isPresent(),
    // "ApplicationModel was created without a " + ComponentBuildingDefinitionProvider.class.getName());
    componentBuildingDefinitionRegistry.ifPresent(buildingDefinitionRegistry -> {
        executeOnEveryComponentTree(componentModel -> {
            Optional<ComponentBuildingDefinition<?>> buildingDefinition = buildingDefinitionRegistry.getBuildingDefinition(componentModel.getIdentifier());
            buildingDefinition.map(definition -> {
                ObjectTypeVisitor typeDefinitionVisitor = new ObjectTypeVisitor(componentModel);
                definition.getTypeDefinition().visit(typeDefinitionVisitor);
                componentModel.setType(typeDefinitionVisitor.getType());
                return definition;
            }).orElseGet(() -> {
                String classParameter = componentModel.getParameters().get(CLASS_ATTRIBUTE);
                if (classParameter != null) {
                    try {
                        componentModel.setType(ClassUtils.getClass(classParameter));
                    } catch (ClassNotFoundException e) {
                        throw new RuntimeConfigurationException(I18nMessageFactory.createStaticMessage(String.format("Could not resolve class '%s' for component '%s'", classParameter, componentModel.getComponentLocation())));
                    }
                }
                return null;
            });
        });
    });
}
Also used : ResourceProvider(org.mule.runtime.config.api.dsl.model.ResourceProvider) MacroExpansionModulesModel(org.mule.runtime.config.internal.dsl.model.extension.xml.MacroExpansionModulesModel) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) MULE_ROOT_ELEMENT(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_ROOT_ELEMENT) Optional.of(java.util.Optional.of) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) ConfigurationProperty(org.mule.runtime.config.api.dsl.model.properties.ConfigurationProperty) Collections.singletonList(java.util.Collections.singletonList) ClassUtils(org.apache.commons.lang3.ClassUtils) DefaultConfigurationParameters(org.mule.runtime.config.internal.dsl.model.DefaultConfigurationParameters) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) MULE_EE_DOMAIN_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_EE_DOMAIN_IDENTIFIER) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) DslElementModelFactory(org.mule.runtime.config.api.dsl.model.DslElementModelFactory) ERROR_HANDLER_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.ERROR_HANDLER_IDENTIFIER) ComponentModelReader(org.mule.runtime.config.internal.dsl.model.ComponentModelReader) CompositeConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.CompositeConfigurationPropertiesProvider) PropertiesResolverConfigurationProperties(org.mule.runtime.config.internal.dsl.model.config.PropertiesResolverConfigurationProperties) EnvironmentPropertiesConfigurationProvider(org.mule.runtime.config.internal.dsl.model.config.EnvironmentPropertiesConfigurationProvider) MULE_DOMAIN_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_DOMAIN_IDENTIFIER) DEFAULT_EXPRESSION_PREFIX(org.mule.runtime.core.api.el.ExpressionManager.DEFAULT_EXPRESSION_PREFIX) ImmutableSet(com.google.common.collect.ImmutableSet) ComponentModelHelper.resolveComponentType(org.mule.runtime.config.internal.dsl.spring.ComponentModelHelper.resolveComponentType) MapConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.MapConfigurationPropertiesProvider) TypedComponentIdentifier(org.mule.runtime.api.component.TypedComponentIdentifier) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) UNKNOWN(org.mule.runtime.api.component.TypedComponentIdentifier.ComponentType.UNKNOWN) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ServiceLoader(java.util.ServiceLoader) SOURCE_TYPE(org.mule.runtime.config.internal.dsl.spring.BeanDefinitionFactory.SOURCE_TYPE) NameValidationUtil.verifyStringDoesNotContainsReservedCharacters(org.mule.runtime.internal.util.NameValidationUtil.verifyStringDoesNotContainsReservedCharacters) String.format(java.lang.String.format) FileConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.FileConfigurationPropertiesProvider) ERROR_HANDLER(org.mule.runtime.config.api.dsl.CoreDslConstants.ERROR_HANDLER) I18nMessageFactory(org.mule.runtime.api.i18n.I18nMessageFactory) XmlCustomAttributeHandler(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) List(java.util.List) ElementDeclaration(org.mule.runtime.app.declaration.api.ElementDeclaration) GlobalPropertyConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.GlobalPropertyConfigurationPropertiesProvider) Optional(java.util.Optional) QName(javax.xml.namespace.QName) MuleExtensionModelProvider(org.mule.runtime.core.api.extension.MuleExtensionModelProvider) ComponentIdentifier.builder(org.mule.runtime.api.component.ComponentIdentifier.builder) Optional.empty(java.util.Optional.empty) ComponentBuildingDefinitionRegistry(org.mule.runtime.config.api.dsl.model.ComponentBuildingDefinitionRegistry) DefaultComponentLocation(org.mule.runtime.dsl.api.component.config.DefaultComponentLocation) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) ConfigurationProperties(org.mule.runtime.api.component.ConfigurationProperties) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) ComponentLocationVisitor(org.mule.runtime.config.internal.dsl.model.ComponentLocationVisitor) NameUtils.pluralize(org.mule.runtime.extension.api.util.NameUtils.pluralize) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) MULE_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_IDENTIFIER) ConfigurationPropertiesProvider(org.mule.runtime.config.api.dsl.model.properties.ConfigurationPropertiesProvider) ArtifactDeclaration(org.mule.runtime.app.declaration.api.ArtifactDeclaration) Component(org.mule.runtime.api.component.Component) Node(org.w3c.dom.Node) BiConsumer(java.util.function.BiConsumer) FLOW_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.FLOW_IDENTIFIER) RuntimeConfigurationException(org.mule.runtime.config.internal.dsl.model.config.RuntimeConfigurationException) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) ConfigFile(org.mule.runtime.config.api.dsl.processor.ConfigFile) DefaultConfigurationProperty(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationProperty) LinkedList(java.util.LinkedList) Collections.emptyMap(java.util.Collections.emptyMap) Collections.emptySet(java.util.Collections.emptySet) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) Optional.ofNullable(java.util.Optional.ofNullable) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) NameUtils.hyphenize(org.mule.runtime.extension.api.util.NameUtils.hyphenize) ConfigurationParameters(org.mule.runtime.config.api.dsl.model.ConfigurationParameters) ExtensionModelHelper(org.mule.runtime.config.internal.dsl.model.ExtensionModelHelper) ArtifactConfig(org.mule.runtime.config.api.dsl.processor.ArtifactConfig) DefaultConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver) Joiner.on(com.google.common.base.Joiner.on) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor) AbstractComponent(org.mule.runtime.api.component.AbstractComponent) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.ConfigurationPropertiesResolver) FLOW_REF_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.FLOW_REF_IDENTIFIER) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) ConfigurationPropertiesProviderFactory(org.mule.runtime.config.api.dsl.model.properties.ConfigurationPropertiesProviderFactory) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) CollectionUtils.disjunction(org.apache.commons.collections.CollectionUtils.disjunction) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) ANY_IDENTIFIER(org.mule.runtime.core.api.exception.Errors.Identifiers.ANY_IDENTIFIER) RuntimeConfigurationException(org.mule.runtime.config.internal.dsl.model.config.RuntimeConfigurationException) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor)

Example 18 with Component

use of org.mule.runtime.api.component.Component in project mule by mulesoft.

the class FlowRefFactoryBean method getReferencedFlow.

protected Processor getReferencedFlow(String name, FlowRefMessageProcessor flowRefMessageProcessor) throws MuleException {
    if (name == null) {
        throw new RoutePathNotFoundException(createStaticMessage("flow-ref name expression returned 'null'"), flowRefMessageProcessor);
    }
    Component referencedFlow = getReferencedProcessor(name);
    if (referencedFlow == null) {
        throw new RoutePathNotFoundException(createStaticMessage("No flow/sub-flow with name '%s' found", name), flowRefMessageProcessor);
    }
    // for subflows, we create a new one so it must be initialised manually
    if (!(referencedFlow instanceof Flow)) {
        if (referencedFlow instanceof SubflowMessageProcessorChainBuilder) {
            MessageProcessorChainBuilder chainBuilder = (MessageProcessorChainBuilder) referencedFlow;
            locator.find(flowRefMessageProcessor.getRootContainerLocation()).filter(c -> c instanceof Flow).map(c -> (Flow) c).ifPresent(f -> chainBuilder.setProcessingStrategy(f.getProcessingStrategy()));
            referencedFlow = chainBuilder.build();
        }
        initialiseIfNeeded(referencedFlow, muleContext);
        Map<QName, Object> annotations = new HashMap<>(referencedFlow.getAnnotations());
        annotations.put(ROOT_CONTAINER_NAME_KEY, getRootContainerLocation().toString());
        referencedFlow.setAnnotations(annotations);
        startIfNeeded(referencedFlow);
    }
    return (Processor) referencedFlow;
}
Also used : Flux.just(reactor.core.publisher.Flux.just) LoadingCache(com.google.common.cache.LoadingCache) Map(java.util.Map) LifecycleUtils.stopIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) Operators.outputToTarget(org.mule.runtime.core.internal.util.rx.Operators.outputToTarget) Flow(org.mule.runtime.core.api.construct.Flow) CacheLoader(com.google.common.cache.CacheLoader) MessageProcessors.processWithChildContext(org.mule.runtime.core.privileged.processor.MessageProcessors.processWithChildContext) MessageProcessors(org.mule.runtime.core.privileged.processor.MessageProcessors) MessageProcessorChainBuilder(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChainBuilder) CacheBuilder(com.google.common.cache.CacheBuilder) QName(javax.xml.namespace.QName) ExtendedExpressionManager(org.mule.runtime.core.api.el.ExtendedExpressionManager) ApplicationContextAware(org.springframework.context.ApplicationContextAware) Flux.from(reactor.core.publisher.Flux.from) HashMap(java.util.HashMap) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) Processor(org.mule.runtime.core.api.processor.Processor) Inject(javax.inject.Inject) ConfigurationComponentLocator(org.mule.runtime.api.component.location.ConfigurationComponentLocator) MuleContext(org.mule.runtime.core.api.MuleContext) MuleException(org.mule.runtime.api.exception.MuleException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) Component(org.mule.runtime.api.component.Component) Flux.error(reactor.core.publisher.Flux.error) Disposable(org.mule.runtime.api.lifecycle.Disposable) AnnotatedProcessor(org.mule.runtime.core.privileged.processor.AnnotatedProcessor) AbstractComponentFactory(org.mule.runtime.dsl.api.component.AbstractComponentFactory) Logger(org.slf4j.Logger) MessageProcessors.processToApply(org.mule.runtime.core.privileged.processor.MessageProcessors.processToApply) SubflowMessageProcessorChainBuilder(org.mule.runtime.core.internal.processor.chain.SubflowMessageProcessorChainBuilder) Optional.ofNullable(java.util.Optional.ofNullable) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Publisher(org.reactivestreams.Publisher) RoutePathNotFoundException(org.mule.runtime.core.privileged.routing.RoutePathNotFoundException) LifecycleUtils.startIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.startIfNeeded) BeansException(org.springframework.beans.BeansException) Mono(reactor.core.publisher.Mono) ApplicationContext(org.springframework.context.ApplicationContext) AbstractComponent(org.mule.runtime.api.component.AbstractComponent) LifecycleUtils.disposeIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.disposeIfNeeded) Flux(reactor.core.publisher.Flux) Stoppable(org.mule.runtime.api.lifecycle.Stoppable) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ComponentLocation(org.mule.runtime.api.component.location.ComponentLocation) MuleArtifactContext(org.mule.runtime.config.internal.MuleArtifactContext) RoutePathNotFoundException(org.mule.runtime.core.privileged.routing.RoutePathNotFoundException) Processor(org.mule.runtime.core.api.processor.Processor) AnnotatedProcessor(org.mule.runtime.core.privileged.processor.AnnotatedProcessor) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) MessageProcessorChainBuilder(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChainBuilder) SubflowMessageProcessorChainBuilder(org.mule.runtime.core.internal.processor.chain.SubflowMessageProcessorChainBuilder) Component(org.mule.runtime.api.component.Component) AbstractComponent(org.mule.runtime.api.component.AbstractComponent) SubflowMessageProcessorChainBuilder(org.mule.runtime.core.internal.processor.chain.SubflowMessageProcessorChainBuilder) Flow(org.mule.runtime.core.api.construct.Flow)

Example 19 with Component

use of org.mule.runtime.api.component.Component in project mule by mulesoft.

the class LocatedMuleExceptionTestCase method annotatedComponent.

@Test
public void annotatedComponent() {
    Component annotated = mock(Component.class);
    when(annotated.getAnnotation(eq(docNameAttrName))).thenReturn("Mock Component");
    when(annotated.toString()).thenReturn("Mock@1");
    configureProcessorLocation(annotated);
    LocatedMuleException lme = new LocatedMuleException(annotated);
    assertThat(lme.getInfo().get(INFO_LOCATION_KEY).toString(), is("Mock@1 @ app:muleApp.xml:10 (Mock Component)"));
}
Also used : Component(org.mule.runtime.api.component.Component) LocatedMuleException(org.mule.runtime.api.exception.LocatedMuleException) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 20 with Component

use of org.mule.runtime.api.component.Component in project mule by mulesoft.

the class MVELExpressionLanguageTestCase method setupMVEL.

@Before
public void setupMVEL() throws InitialisationException {
    mvel = new MVELExpressionLanguage(muleContext);
    mvel.initialise();
    flowConstruct = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class));
    when(flowConstruct.getName()).thenReturn("myFlow");
    final DefaultComponentLocation location = fromSingleComponent("myFlow");
    when(((Component) flowConstruct).getAnnotation(LOCATION_KEY)).thenReturn(location);
    when(((Component) flowConstruct).getLocation()).thenReturn(location);
}
Also used : FlowConstruct(org.mule.runtime.core.api.construct.FlowConstruct) DefaultComponentLocation.fromSingleComponent(org.mule.runtime.dsl.api.component.config.DefaultComponentLocation.fromSingleComponent) Component(org.mule.runtime.api.component.Component) DefaultComponentLocation(org.mule.runtime.dsl.api.component.config.DefaultComponentLocation) Before(org.junit.Before)

Aggregations

Component (org.mule.runtime.api.component.Component)39 Test (org.junit.Test)15 Map (java.util.Map)12 AbstractComponent (org.mule.runtime.api.component.AbstractComponent)12 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)12 SmallTest (org.mule.tck.size.SmallTest)11 Optional (java.util.Optional)9 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)9 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)9 List (java.util.List)8 ComponentIdentifier (org.mule.runtime.api.component.ComponentIdentifier)8 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)7 HashMap (java.util.HashMap)6 String.format (java.lang.String.format)5 Optional.empty (java.util.Optional.empty)5 Optional.of (java.util.Optional.of)5 Set (java.util.Set)5 Inject (javax.inject.Inject)5 Arrays.asList (java.util.Arrays.asList)4 Collection (java.util.Collection)4