use of org.mule.runtime.api.meta.model.nested.NestableElementModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method async.
@Test
public void async() {
final ConstructModel asyncModel = coreExtensionModel.getConstructModel("async").get();
assertThat(asyncModel.getNestedComponents(), hasSize(1));
NestableElementModel processors = asyncModel.getNestedComponents().get(0);
assertThat(processors, instanceOf(NestedChainModel.class));
assertThat(processors.isRequired(), is(true));
assertThat(asyncModel.getAllParameterModels(), hasSize(2));
assertThat(asyncModel.getAllParameterModels().get(0).getName(), is("name"));
assertThat(asyncModel.getAllParameterModels().get(0).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(asyncModel.getAllParameterModels().get(0).getType(), instanceOf(DefaultStringType.class));
assertThat(asyncModel.getAllParameterModels().get(0).isRequired(), is(false));
assertThat(asyncModel.getAllParameterModels().get(1).getName(), is("maxConcurrency"));
assertThat(asyncModel.getAllParameterModels().get(1).getType(), instanceOf(DefaultNumberType.class));
assertThat(asyncModel.getAllParameterModels().get(1).isRequired(), is(false));
}
use of org.mule.runtime.api.meta.model.nested.NestableElementModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method foreach.
@Test
public void foreach() {
final ConstructModel foreach = coreExtensionModel.getConstructModel("foreach").get();
assertThat(foreach.getNestedComponents().size(), is(1));
NestableElementModel processorsChain = foreach.getNestedComponents().get(0);
assertThat(processorsChain, instanceOf(NestedChainModel.class));
assertThat(processorsChain.isRequired(), is(true));
assertThat(foreach.getAllParameterModels(), hasSize(4));
ParameterModel collection = foreach.getAllParameterModels().get(0);
assertThat(collection.getName(), is("collection"));
assertThat(collection.getExpressionSupport(), is(REQUIRED));
assertThat(collection.getType(), instanceOf(ArrayType.class));
assertThat(collection.getType().getAnnotation(ClassInformationAnnotation.class).map(ClassInformationAnnotation::getClassname).orElse(""), is(Iterable.class.getName()));
assertThat(collection.isRequired(), is(false));
ParameterModel batchSize = foreach.getAllParameterModels().get(1);
assertThat(batchSize.getName(), is("batchSize"));
assertThat(batchSize.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(batchSize.getType(), instanceOf(DefaultNumberType.class));
assertThat(batchSize.isRequired(), is(false));
ParameterModel rootMessageName = foreach.getAllParameterModels().get(2);
assertThat(rootMessageName.getName(), is("rootMessageVariableName"));
assertThat(rootMessageName.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(rootMessageName.getType(), instanceOf(DefaultStringType.class));
assertThat(rootMessageName.isRequired(), is(false));
ParameterModel counter = foreach.getAllParameterModels().get(3);
assertThat(counter.getName(), is("counterVariableName"));
assertThat(counter.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(counter.getType(), instanceOf(DefaultStringType.class));
assertThat(counter.isRequired(), is(false));
}
use of org.mule.runtime.api.meta.model.nested.NestableElementModel 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));
}
use of org.mule.runtime.api.meta.model.nested.NestableElementModel 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));
}
use of org.mule.runtime.api.meta.model.nested.NestableElementModel in project mule by mulesoft.
the class AbstractComponentDefinitionParser method doParse.
@Override
protected Builder doParse(Builder definitionBuilder) throws ConfigurationException {
Builder finalBuilder = definitionBuilder.withIdentifier(operationDsl.getElementName()).withTypeDefinition(fromType(getMessageProcessorType())).withObjectFactoryType(getMessageProcessorFactoryType()).withConstructorParameterDefinition(fromFixedValue(extensionModel).build()).withConstructorParameterDefinition(fromFixedValue(componentModel).build()).withConstructorParameterDefinition(fromReferenceObject(MuleContext.class).build()).withConstructorParameterDefinition(fromReferenceObject(Registry.class).build()).withConstructorParameterDefinition(fromReferenceObject(PolicyManager.class).build()).withSetterParameterDefinition(TARGET_PARAMETER_NAME, fromSimpleParameter(TARGET_PARAMETER_NAME).build()).withSetterParameterDefinition(TARGET_VALUE_PARAMETER_NAME, fromSimpleParameter(TARGET_VALUE_PARAMETER_NAME).build()).withSetterParameterDefinition(CONFIG_PROVIDER_ATTRIBUTE_NAME, fromSimpleReferenceParameter(CONFIG_ATTRIBUTE_NAME).build()).withSetterParameterDefinition(CURSOR_PROVIDER_FACTORY_FIELD_NAME, fromChildConfiguration(CursorProviderFactory.class).build()).withSetterParameterDefinition("retryPolicyTemplate", fromChildConfiguration(RetryPolicyTemplate.class).build());
Optional<? extends NestableElementModel> nestedChain = componentModel.getNestedComponents().stream().filter(c -> c instanceof NestedChainModel).findFirst();
if (nestedChain.isPresent()) {
// TODO MULE-13483: improve parsers to support things like [source, chainOfProcessors, errorHandler]
// or [chainOfProcessors, errorHandler]
finalBuilder = finalBuilder.withSetterParameterDefinition("nestedProcessors", fromChildCollectionConfiguration(Processor.class).build());
parseParameters(componentModel.getAllParameterModels());
} else {
List<ParameterGroupModel> inlineGroups = getInlineGroups(componentModel);
parseParameters(getFlatParameters(inlineGroups, componentModel.getAllParameterModels()));
for (ParameterGroupModel group : inlineGroups) {
parseInlineParameterGroup(group);
}
// TODO MULE-13483
parseNestedComponents(componentModel.getNestedComponents());
}
return finalBuilder;
}
Aggregations