use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method firstSuccessful.
@Test
public void firstSuccessful() {
final ConstructModel tryModel = coreExtensionModel.getConstructModel("firstSuccessful").get();
List<ParameterModel> allParameterModels = tryModel.getAllParameterModels();
assertThat(allParameterModels, hasSize(0));
}
use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method scatterGather.
@Test
public void scatterGather() {
final ConstructModel scatterGatherModel = coreExtensionModel.getConstructModel("scatterGather").get();
assertThat(scatterGatherModel.getAllParameterModels(), hasSize(4));
assertThat(scatterGatherModel.getAllParameterModels().get(0).getName(), is("timeout"));
assertThat(scatterGatherModel.getAllParameterModels().get(0).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(scatterGatherModel.getAllParameterModels().get(0).getType(), instanceOf(DefaultNumberType.class));
assertThat(scatterGatherModel.getAllParameterModels().get(0).isRequired(), is(false));
assertThat(scatterGatherModel.getAllParameterModels().get(1).getName(), is("maxConcurrency"));
assertThat(scatterGatherModel.getAllParameterModels().get(1).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(scatterGatherModel.getAllParameterModels().get(1).getType(), instanceOf(DefaultNumberType.class));
assertThat(scatterGatherModel.getAllParameterModels().get(1).isRequired(), is(false));
assertThat(scatterGatherModel.getAllParameterModels().get(2).getName(), is(TARGET_PARAMETER_NAME));
assertThat(scatterGatherModel.getAllParameterModels().get(2).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(scatterGatherModel.getAllParameterModels().get(2).getType(), instanceOf(DefaultStringType.class));
assertThat(scatterGatherModel.getAllParameterModels().get(2).isRequired(), is(false));
assertThat(scatterGatherModel.getAllParameterModels().get(3).getName(), is(TARGET_VALUE_PARAMETER_NAME));
assertThat(scatterGatherModel.getAllParameterModels().get(3).getExpressionSupport(), is(REQUIRED));
assertThat(scatterGatherModel.getAllParameterModels().get(3).getType(), instanceOf(StringType.class));
assertThat(scatterGatherModel.getAllParameterModels().get(3).isRequired(), is(false));
assertThat(scatterGatherModel.getNestedComponents(), hasSize(1));
final NestedRouteModel routeModel = (NestedRouteModel) scatterGatherModel.getNestedComponents().get(0);
assertThat(routeModel.getName(), is("route"));
assertThat(routeModel.getMinOccurs(), is(2));
assertThat(routeModel.getMaxOccurs(), is(Optional.empty()));
assertThat(routeModel.getAllParameterModels(), empty());
}
use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.
the class DefaultExtensionBuildingDefinitionProvider method registerExtensionParsers.
private void registerExtensionParsers(ExtensionModel extensionModel) {
XmlDslModel xmlDslModel = extensionModel.getXmlDslModel();
final ExtensionParsingContext parsingContext = createParsingContext(extensionModel);
final Builder definitionBuilder = new Builder().withNamespace(xmlDslModel.getPrefix());
final DslSyntaxResolver dslSyntaxResolver = DslSyntaxResolver.getDefault(extensionModel, DslResolvingContext.getDefault(extensions));
if (extensionModel.getModelProperty(CustomBuildingDefinitionProviderModelProperty.class).isPresent()) {
return;
}
if (extensionModel.getModelProperty(XmlExtensionModelProperty.class).isPresent()) {
registerXmlExtensionParsers(definitionBuilder, extensionModel, dslSyntaxResolver);
} else {
final ClassLoader extensionClassLoader = getClassLoader(extensionModel);
withContextClassLoader(extensionClassLoader, () -> {
ReflectionCache reflectionCache = new ReflectionCache();
new IdempotentExtensionWalker() {
@Override
public void onConfiguration(ConfigurationModel model) {
parseWith(new ConfigurationDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
}
@Override
protected void onConstruct(ConstructModel model) {
parseWith(new ConstructDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
}
@Override
public void onOperation(OperationModel model) {
parseWith(new OperationDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
}
@Override
public void onConnectionProvider(ConnectionProviderModel model) {
parseWith(new ConnectionProviderDefinitionParser(definitionBuilder, model, extensionModel, dslSyntaxResolver, parsingContext));
}
@Override
public void onSource(SourceModel model) {
parseWith(new SourceDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
}
@Override
protected void onParameter(ParameterGroupModel groupModel, ParameterModel model) {
registerTopLevelParameter(model.getType(), definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
}
}.walk(extensionModel);
registerExportedTypesTopLevelParsers(extensionModel, definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
registerSubTypes(definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
});
}
}
use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.
the class NameClashModelValidatorTestCase method constructNameClashesWithAnotherConstructName.
@Test
public void constructNameClashesWithAnotherConstructName() {
exception.expect(IllegalModelDefinitionException.class);
ConstructModel anotherConstructModel = mock(ConstructModel.class);
when(anotherConstructModel.getName()).thenReturn(CONSTRUCT_NAME);
when(extensionModel.getConstructModels()).thenReturn(asList(constructModel, anotherConstructModel));
validate();
}
use of org.mule.runtime.api.meta.model.construct.ConstructModel in project mule by mulesoft.
the class ConfigurationBasedElementModelFactory method createIdentifiedElement.
private DslElementModel createIdentifiedElement(ComponentConfiguration configuration) {
final ComponentIdentifier identifier = configuration.getIdentifier();
Optional<Map.Entry<ExtensionModel, DslSyntaxResolver>> entry = resolvers.entrySet().stream().filter(e -> e.getKey().getXmlDslModel().getPrefix().equals(identifier.getNamespace())).findFirst();
if (!entry.isPresent()) {
return null;
}
currentExtension = entry.get().getKey();
dsl = entry.get().getValue();
Reference<DslElementModel> elementModel = new Reference<>();
new ExtensionWalker() {
@Override
protected void onConfiguration(ConfigurationModel model) {
final DslElementSyntax elementDsl = dsl.resolve(model);
getIdentifier(elementDsl).ifPresent(elementId -> {
if (elementId.equals(identifier)) {
DslElementModel.Builder<ConfigurationModel> element = createElementModel(model, elementDsl, configuration);
addConnectionProvider(model, dsl, element, configuration);
elementModel.set(element.build());
stop();
}
});
}
@Override
protected void onConstruct(HasConstructModels owner, ConstructModel model) {
final DslElementSyntax elementDsl = dsl.resolve(model);
getIdentifier(elementDsl).ifPresent(elementId -> {
if (elementId.equals(identifier)) {
elementModel.set(createElementModel(model, elementDsl, configuration).build());
stop();
}
});
}
@Override
protected void onOperation(HasOperationModels owner, OperationModel model) {
final DslElementSyntax elementDsl = dsl.resolve(model);
getIdentifier(elementDsl).ifPresent(elementId -> {
if (elementId.equals(identifier)) {
elementModel.set(createElementModel(model, elementDsl, configuration).build());
stop();
}
});
}
@Override
protected void onSource(HasSourceModels owner, SourceModel model) {
final DslElementSyntax elementDsl = dsl.resolve(model);
getIdentifier(elementDsl).ifPresent(elementId -> {
if (elementId.equals(identifier)) {
elementModel.set(createElementModel(model, elementDsl, configuration).build());
stop();
}
});
}
}.walk(currentExtension);
if (elementModel.get() == null) {
resolveBasedOnTypes(configuration).ifPresent(elementModel::set);
}
return elementModel.get();
}
Aggregations