Search in sources :

Example 11 with ConstructModel

use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.

the class DeclarationBasedElementModelFactory method create.

public <T> Optional<DslElementModel<T>> create(ElementDeclaration declaration) {
    setupCurrentExtensionContext(declaration.getDeclaringExtension());
    final Function<NamedObject, Boolean> equalsName = (named) -> named.getName().equals(declaration.getName());
    if (declaration instanceof TopLevelParameterDeclaration) {
        return createFromType((TopLevelParameterDeclaration) declaration);
    }
    Reference<DslElementModel> elementModel = new Reference<>();
    new ExtensionWalker() {

        @Override
        protected void onConfiguration(ConfigurationModel model) {
            if (equalsName.apply(model) && declaration instanceof ConfigurationElementDeclaration) {
                elementModel.set(createConfigurationElement(model, (ConfigurationElementDeclaration) declaration));
                stop();
            }
        }

        @Override
        protected void onOperation(HasOperationModels owner, OperationModel model) {
            if (equalsName.apply(model) && declaration instanceof OperationElementDeclaration) {
                elementModel.set(createComponentElement(model, (OperationElementDeclaration) declaration));
                stop();
            }
        }

        @Override
        protected void onConstruct(HasConstructModels owner, ConstructModel model) {
            if (equalsName.apply(model) && declaration instanceof ConstructElementDeclaration) {
                elementModel.set(createComponentElement(model, (ConstructElementDeclaration) declaration));
                stop();
            }
        }

        @Override
        protected void onSource(HasSourceModels owner, SourceModel model) {
            if (equalsName.apply(model) && declaration instanceof SourceElementDeclaration) {
                elementModel.set(createComponentElement(model, (SourceElementDeclaration) declaration));
                stop();
            }
        }
    }.walk(currentExtension);
    if (LOGGER.isDebugEnabled() && elementModel.get() == null) {
        LOGGER.debug(format("No model found with name [%s] of type [%s] for extension [%s]", declaration.getName(), declaration.getClass().getName(), declaration.getDeclaringExtension()));
    }
    return Optional.ofNullable(elementModel.get());
}
Also used : ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) NamedObject(org.mule.runtime.api.meta.NamedObject) LoggerFactory(org.slf4j.LoggerFactory) ParameterizedElementDeclaration(org.mule.runtime.app.declaration.api.ParameterizedElementDeclaration) ComposableModel(org.mule.runtime.api.meta.model.ComposableModel) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ArrayType(org.mule.metadata.api.model.ArrayType) KEY_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.KEY_ATTRIBUTE_NAME) Map(java.util.Map) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) ParameterSimpleValue(org.mule.runtime.app.declaration.api.fluent.ParameterSimpleValue) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) ParameterValueVisitor(org.mule.runtime.app.declaration.api.ParameterValueVisitor) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) DslElementModelFactory(org.mule.runtime.config.api.dsl.model.DslElementModelFactory) ParameterElementDeclaration(org.mule.runtime.app.declaration.api.ParameterElementDeclaration) ExtensionModelUtils.isContent(org.mule.runtime.extension.api.util.ExtensionModelUtils.isContent) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) ObjectType(org.mule.metadata.api.model.ObjectType) ElementDeclarer.newObjectValue(org.mule.runtime.app.declaration.api.fluent.ElementDeclarer.newObjectValue) InternalComponentConfiguration(org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration) String.format(java.lang.String.format) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) NAME_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.NAME_ATTRIBUTE_NAME) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) ConstructElementDeclaration(org.mule.runtime.app.declaration.api.ConstructElementDeclaration) HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) ElementDeclaration(org.mule.runtime.app.declaration.api.ElementDeclaration) LayoutModel(org.mule.runtime.api.meta.model.display.LayoutModel) ConfigurationElementDeclaration(org.mule.runtime.app.declaration.api.ConfigurationElementDeclaration) ExtensionModelUtils.isInfrastructure(org.mule.runtime.extension.api.util.ExtensionModelUtils.isInfrastructure) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) Optional(java.util.Optional) ComponentIdentifier.builder(org.mule.runtime.api.component.ComponentIdentifier.builder) ReferableElementDeclaration(org.mule.runtime.app.declaration.api.ReferableElementDeclaration) ExtensionMetadataTypeUtils.getAlias(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getAlias) ExtensionModelUtils.isRequired(org.mule.runtime.extension.api.util.ExtensionModelUtils.isRequired) Optional.empty(java.util.Optional.empty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SourceElementDeclaration(org.mule.runtime.app.declaration.api.SourceElementDeclaration) CONFIG_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.CONFIG_ATTRIBUTE_NAME) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) HasConstructModels(org.mule.runtime.api.meta.model.construct.HasConstructModels) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) RouteElementDeclaration(org.mule.runtime.app.declaration.api.RouteElementDeclaration) Preconditions.checkArgument(org.mule.runtime.api.util.Preconditions.checkArgument) VALUE_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.VALUE_ATTRIBUTE_NAME) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) Function(java.util.function.Function) ExtensionMetadataTypeUtils.isFlattenedParameterGroup(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isFlattenedParameterGroup) ParameterListValue(org.mule.runtime.app.declaration.api.fluent.ParameterListValue) DslElementSyntaxBuilder(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntaxBuilder) ExtensionModelUtils.getDefaultValue(org.mule.runtime.extension.api.util.ExtensionModelUtils.getDefaultValue) ParameterObjectValue(org.mule.runtime.app.declaration.api.fluent.ParameterObjectValue) Stream.concat(java.util.stream.Stream.concat) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) Logger(org.slf4j.Logger) ParameterValue(org.mule.runtime.app.declaration.api.ParameterValue) Stream.of(java.util.stream.Stream.of) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ConnectionElementDeclaration(org.mule.runtime.app.declaration.api.ConnectionElementDeclaration) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel) Collectors.toList(java.util.stream.Collectors.toList) TopLevelParameterDeclaration(org.mule.runtime.app.declaration.api.TopLevelParameterDeclaration) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) Reference(org.mule.runtime.api.util.Reference) OperationElementDeclaration(org.mule.runtime.app.declaration.api.OperationElementDeclaration) IS_CDATA(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler.IS_CDATA) ComponentElementDeclaration(org.mule.runtime.app.declaration.api.ComponentElementDeclaration) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) ParameterGroupElementDeclaration(org.mule.runtime.app.declaration.api.ParameterGroupElementDeclaration) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) Reference(org.mule.runtime.api.util.Reference) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) NamedObject(org.mule.runtime.api.meta.NamedObject) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ConstructElementDeclaration(org.mule.runtime.app.declaration.api.ConstructElementDeclaration) ConfigurationElementDeclaration(org.mule.runtime.app.declaration.api.ConfigurationElementDeclaration) HasConstructModels(org.mule.runtime.api.meta.model.construct.HasConstructModels) SourceElementDeclaration(org.mule.runtime.app.declaration.api.SourceElementDeclaration) OperationElementDeclaration(org.mule.runtime.app.declaration.api.OperationElementDeclaration) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel) TopLevelParameterDeclaration(org.mule.runtime.app.declaration.api.TopLevelParameterDeclaration) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Example 12 with ConstructModel

use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.

the class DefaultXmlArtifactDeclarationLoader method getComponentDeclaringWalker.

private ExtensionWalker getComponentDeclaringWalker(final Consumer<ComponentElementDeclaration> declarationConsumer, final ConfigLine line, final ElementDeclarer extensionElementsDeclarer) {
    final DslSyntaxResolver dsl = resolvers.get(getNamespace(line));
    return new ExtensionWalker() {

        @Override
        protected void onOperation(HasOperationModels owner, OperationModel model) {
            if (!model.getName().equals(TRANSFORM_IDENTIFIER)) {
                declareComponentModel(line, model, extensionElementsDeclarer::newOperation).ifPresent(declarer -> {
                    declarationConsumer.accept((ComponentElementDeclaration) declarer.getDeclaration());
                    stop();
                });
            } else {
                declareTransform(model);
            }
        }

        @Override
        protected void onSource(HasSourceModels owner, SourceModel model) {
            declareComponentModel(line, model, extensionElementsDeclarer::newSource).ifPresent(declarer -> {
                final DslElementSyntax elementDsl = dsl.resolve(model);
                model.getSuccessCallback().ifPresent(cb -> declareParameterizedComponent(cb, elementDsl, declarer, line.getConfigAttributes(), line.getChildren()));
                model.getErrorCallback().ifPresent(cb -> declareParameterizedComponent(cb, elementDsl, declarer, line.getConfigAttributes(), line.getChildren()));
                declarationConsumer.accept((ComponentElementDeclaration) declarer.getDeclaration());
                stop();
            });
        }

        @Override
        protected void onConstruct(HasConstructModels owner, ConstructModel model) {
            declareComponentModel(line, model, extensionElementsDeclarer::newConstruct).ifPresent(declarer -> {
                declarationConsumer.accept((ComponentElementDeclaration) declarer.getDeclaration());
                stop();
            });
        }

        private void declareTransform(ComponentModel model) {
            final DslElementSyntax elementDsl = dsl.resolve(model);
            if (model.getName().equals(TRANSFORM_IDENTIFIER) && elementDsl.getElementName().equals(line.getIdentifier())) {
                ComponentElementDeclarer transform = extensionElementsDeclarer.newOperation(TRANSFORM_IDENTIFIER);
                line.getChildren().stream().filter(c -> c.getIdentifier().equals("message")).findFirst().ifPresent(messageConfig -> {
                    ParameterGroupElementDeclarer messageGroup = newParameterGroup("Message");
                    messageConfig.getChildren().stream().filter(c -> c.getIdentifier().equals("set-payload")).findFirst().ifPresent(payloadConfig -> {
                        ParameterObjectValue.Builder payload = newObjectValue();
                        populateTransformScriptParameter(payloadConfig, payload);
                        messageGroup.withParameter("setPayload", payload.build());
                    });
                    messageConfig.getChildren().stream().filter(c -> c.getIdentifier().equals("set-attributes")).findFirst().ifPresent(attributesConfig -> {
                        ParameterObjectValue.Builder attributes = newObjectValue();
                        populateTransformScriptParameter(attributesConfig, attributes);
                        messageGroup.withParameter("setAttributes", attributes.build());
                    });
                    transform.withParameterGroup(messageGroup.getDeclaration());
                });
                line.getChildren().stream().filter(c -> c.getIdentifier().equals("variables")).findFirst().ifPresent(variablesConfig -> {
                    ParameterGroupElementDeclarer variablesGroup = newParameterGroup("Set Variables");
                    ParameterListValue.Builder variables = newListValue();
                    variablesConfig.getChildren().forEach(variableConfig -> {
                        ParameterObjectValue.Builder variable = newObjectValue();
                        variable.withParameter(TRANSFORM_VARIABLE_NAME, variableConfig.getConfigAttributes().get(TRANSFORM_VARIABLE_NAME).getValue());
                        populateTransformScriptParameter(variableConfig, variable);
                        variables.withValue(variable.build());
                    });
                    transform.withParameterGroup(variablesGroup.withParameter("setVariables", variables.build()).getDeclaration());
                });
                line.getConfigAttributes().values().forEach(a -> transform.withCustomParameter(a.getName(), a.getValue()));
                declarationConsumer.accept((ComponentElementDeclaration) transform.getDeclaration());
                stop();
            }
        }
    };
}
Also used : HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) ParameterListValue(org.mule.runtime.app.declaration.api.fluent.ParameterListValue) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) ParameterGroupElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ParameterGroupElementDeclarer) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ComponentElementDeclarer(org.mule.runtime.app.declaration.api.fluent.ComponentElementDeclarer) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) HasConstructModels(org.mule.runtime.api.meta.model.construct.HasConstructModels) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) ParameterObjectValue(org.mule.runtime.app.declaration.api.fluent.ParameterObjectValue) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Example 13 with ConstructModel

use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.

the class CoreExtensionModelTestCase method splitAggregate.

@Test
public void splitAggregate() {
    final ConstructModel splitAggregate = coreExtensionModel.getConstructModel("splitAggregate").get();
    NestableElementModel processorsChain = splitAggregate.getNestedComponents().get(0);
    assertThat(processorsChain, instanceOf(NestedChainModel.class));
    assertThat(processorsChain.isRequired(), is(true));
    assertThat(splitAggregate.getAllParameterModels(), hasSize(5));
    assertThat(splitAggregate.getAllParameterModels().get(0).getName(), is("collection"));
    assertThat(splitAggregate.getAllParameterModels().get(0).getExpressionSupport(), is(REQUIRED));
    assertThat(splitAggregate.getAllParameterModels().get(0).getType(), instanceOf(DefaultStringType.class));
    assertThat(splitAggregate.getAllParameterModels().get(0).isRequired(), is(false));
    assertThat(splitAggregate.getAllParameterModels().get(1).getName(), is("timeout"));
    assertThat(splitAggregate.getAllParameterModels().get(1).getExpressionSupport(), is(NOT_SUPPORTED));
    assertThat(splitAggregate.getAllParameterModels().get(1).getType(), instanceOf(DefaultNumberType.class));
    assertThat(splitAggregate.getAllParameterModels().get(1).isRequired(), is(false));
    assertThat(splitAggregate.getAllParameterModels().get(2).getName(), is("maxConcurrency"));
    assertThat(splitAggregate.getAllParameterModels().get(2).getExpressionSupport(), is(NOT_SUPPORTED));
    assertThat(splitAggregate.getAllParameterModels().get(2).getType(), instanceOf(DefaultNumberType.class));
    assertThat(splitAggregate.getAllParameterModels().get(2).isRequired(), is(false));
    assertThat(splitAggregate.getAllParameterModels().get(3).getName(), is(TARGET_PARAMETER_NAME));
    assertThat(splitAggregate.getAllParameterModels().get(3).getExpressionSupport(), is(NOT_SUPPORTED));
    assertThat(splitAggregate.getAllParameterModels().get(3).getType(), instanceOf(DefaultStringType.class));
    assertThat(splitAggregate.getAllParameterModels().get(3).isRequired(), is(false));
    assertThat(splitAggregate.getAllParameterModels().get(4).getName(), is(TARGET_VALUE_PARAMETER_NAME));
    assertThat(splitAggregate.getAllParameterModels().get(4).getExpressionSupport(), is(REQUIRED));
    assertThat(splitAggregate.getAllParameterModels().get(4).getType(), instanceOf(StringType.class));
    assertThat(splitAggregate.getAllParameterModels().get(4).isRequired(), is(false));
}
Also used : ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) DefaultNumberType(org.mule.metadata.api.model.impl.DefaultNumberType) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) StringType(org.mule.metadata.api.model.StringType) DefaultStringType(org.mule.metadata.api.model.impl.DefaultStringType) DefaultStringType(org.mule.metadata.api.model.impl.DefaultStringType) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) Test(org.junit.Test)

Example 14 with ConstructModel

use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.

the class CoreExtensionModelTestCase method flow.

@Test
public void flow() {
    final ConstructModel flow = coreExtensionModel.getConstructModel("flow").get();
    assertThat(flow.getStereotype().getType(), is(FLOW.getType()));
    assertThat(flow.allowsTopLevelDeclaration(), is(true));
    final List<ParameterModel> paramModels = flow.getAllParameterModels();
    assertThat(paramModels, hasSize(2));
    ParameterModel initialState = paramModels.get(0);
    assertThat(initialState.getName(), is("initialState"));
    assertThat(initialState.getDefaultValue(), is("started"));
    ParameterModel maxConcurrency = paramModels.get(1);
    assertThat(maxConcurrency.getName(), is("maxConcurrency"));
    List<? extends NestableElementModel> nestedComponents = flow.getNestedComponents();
    assertThat(nestedComponents, hasSize(3));
    NestableElementModel source = nestedComponents.get(0);
    assertThat(source.getName(), is("source"));
    assertThat(source.isRequired(), is(false));
    assertThat(source, instanceOf(NestedComponentModel.class));
    assertThat(((NestedComponentModel) source).getAllowedStereotypes(), contains(SOURCE));
    NestableElementModel chain = nestedComponents.get(1);
    assertThat(chain.getName(), is("processors"));
    assertThat(chain.isRequired(), is(true));
    assertThat(chain, instanceOf(NestedChainModel.class));
    assertThat(((NestedChainModel) chain).getAllowedStereotypes().stream().anyMatch(s -> s.getType().equals(PROCESSOR.getType())), is(true));
    NestableElementModel errorHandler = nestedComponents.get(2);
    assertThat(errorHandler.getName(), is("errorHandler"));
    assertThat(errorHandler.isRequired(), is(false));
    assertThat(errorHandler, instanceOf(NestedComponentModel.class));
    assertThat(((NestedComponentModel) errorHandler).getAllowedStereotypes(), contains(ERROR_HANDLER));
}
Also used : OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) ErrorModelBuilder.newError(org.mule.runtime.api.meta.model.error.ErrorModelBuilder.newError) DefaultAnyType(org.mule.metadata.api.model.impl.DefaultAnyType) VoidType(org.mule.metadata.api.model.VoidType) Assert.assertThat(org.junit.Assert.assertThat) CPU_LITE(org.mule.runtime.api.meta.model.operation.ExecutionType.CPU_LITE) ErrorModel(org.mule.runtime.api.meta.model.error.ErrorModel) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) IsCollectionContaining.hasItem(org.hamcrest.core.IsCollectionContaining.hasItem) ArrayType(org.mule.metadata.api.model.ArrayType) TARGET_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TARGET_PARAMETER_NAME) ON_ERROR(org.mule.runtime.extension.api.stereotype.MuleStereotypes.ON_ERROR) SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.SUPPORTED) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) TypeIdAnnotation(org.mule.metadata.api.annotation.TypeIdAnnotation) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) ObjectType(org.mule.metadata.api.model.ObjectType) REQUIRED(org.mule.runtime.api.meta.ExpressionSupport.REQUIRED) ClassInformationAnnotation(org.mule.metadata.java.api.annotation.ClassInformationAnnotation) DefaultObjectType(org.mule.metadata.api.model.impl.DefaultObjectType) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) MuleManifest.getVendorName(org.mule.runtime.core.api.config.MuleManifest.getVendorName) EnumAnnotation(org.mule.metadata.api.annotation.EnumAnnotation) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) StringType(org.mule.metadata.api.model.StringType) Matchers.contains(org.hamcrest.Matchers.contains) AbstractMuleContextTestCase(org.mule.tck.junit4.AbstractMuleContextTestCase) DefaultNumberType(org.mule.metadata.api.model.impl.DefaultNumberType) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) FLOW(org.mule.runtime.extension.api.stereotype.MuleStereotypes.FLOW) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) DefaultStringType(org.mule.metadata.api.model.impl.DefaultStringType) MuleManifest.getProductVersion(org.mule.runtime.core.api.config.MuleManifest.getProductVersion) IsEmptyCollection.empty(org.hamcrest.collection.IsEmptyCollection.empty) Matchers.arrayContainingInAnyOrder(org.hamcrest.Matchers.arrayContainingInAnyOrder) TARGET_VALUE_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TARGET_VALUE_PARAMETER_NAME) TRANSFORMATION(org.mule.runtime.core.api.exception.Errors.ComponentIdentifiers.Handleable.TRANSFORMATION) SOURCE(org.mule.runtime.extension.api.stereotype.MuleStereotypes.SOURCE) COMMUNITY(org.mule.runtime.api.meta.Category.COMMUNITY) OBJECT_STORE(org.mule.runtime.extension.api.stereotype.MuleStereotypes.OBJECT_STORE) Iterator(java.util.Iterator) ERROR_HANDLER(org.mule.runtime.extension.api.stereotype.MuleStereotypes.ERROR_HANDLER) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) DefaultBooleanType(org.mule.metadata.api.model.impl.DefaultBooleanType) Test(org.junit.Test) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) MULE_VERSION(org.mule.runtime.core.api.extension.MuleExtensionModelProvider.MULE_VERSION) MuleExtensionModelProvider.getExtensionModel(org.mule.runtime.core.api.extension.MuleExtensionModelProvider.getExtensionModel) PROCESSOR(org.mule.runtime.extension.api.stereotype.MuleStereotypes.PROCESSOR) Scheduler(org.mule.runtime.core.api.source.scheduler.Scheduler) NestedComponentModel(org.mule.runtime.api.meta.model.nested.NestedComponentModel) MULE_NAME(org.mule.runtime.core.api.extension.MuleExtensionModelProvider.MULE_NAME) NOT_SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED) SubTypesModel(org.mule.runtime.api.meta.model.SubTypesModel) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) NestedComponentModel(org.mule.runtime.api.meta.model.nested.NestedComponentModel) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) Test(org.junit.Test)

Example 15 with ConstructModel

use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.

the class CoreExtensionModelTestCase method untilSuccessful.

@Test
public void untilSuccessful() {
    final ConstructModel tryModel = coreExtensionModel.getConstructModel("untilSuccessful").get();
    List<ParameterModel> allParameterModels = tryModel.getAllParameterModels();
    assertThat(allParameterModels, hasSize(2));
    ParameterModel action = allParameterModels.get(0);
    assertThat(action.getName(), is("maxRetries"));
    assertThat(action.getType(), is(instanceOf(DefaultNumberType.class)));
    assertThat(action.getExpressionSupport(), is(NOT_SUPPORTED));
    assertThat(action.getDefaultValue(), is(5));
    assertThat(action.isRequired(), is(false));
    ParameterModel type = allParameterModels.get(1);
    assertThat(type.getName(), is("millisBetweenRetries"));
    assertThat(type.getType(), is(instanceOf(DefaultNumberType.class)));
    assertThat(type.getExpressionSupport(), is(NOT_SUPPORTED));
    assertThat(type.getDefaultValue(), is(60000));
    assertThat(type.isRequired(), is(false));
}
Also used : ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) Test(org.junit.Test)

Aggregations

ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)20 Test (org.junit.Test)12 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)10 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)9 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)8 NestedRouteModel (org.mule.runtime.api.meta.model.nested.NestedRouteModel)7 DslSyntaxResolver (org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver)6 ArrayType (org.mule.metadata.api.model.ArrayType)5 DefaultNumberType (org.mule.metadata.api.model.impl.DefaultNumberType)5 DefaultStringType (org.mule.metadata.api.model.impl.DefaultStringType)5 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)5 NestableElementModel (org.mule.runtime.api.meta.model.nested.NestableElementModel)5 ExtensionWalker (org.mule.runtime.api.meta.model.util.ExtensionWalker)5 List (java.util.List)4 Optional (java.util.Optional)4 ObjectType (org.mule.metadata.api.model.ObjectType)4 ComponentModel (org.mule.runtime.api.meta.model.ComponentModel)4 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)4 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)4 NestedChainModel (org.mule.runtime.api.meta.model.nested.NestedChainModel)4