use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration in project mule by mulesoft.
the class ClusterSupportEnricherTestCase method assertEnrichment.
private void assertEnrichment(boolean runsOnPrimaryNodeOnly, boolean parameterAdded, boolean defaultParameterValue) {
enricher.enrich(extensionLoadingContext);
verify(sourceDeclaration).setRunsOnPrimaryNodeOnly(runsOnPrimaryNodeOnly);
if (parameterAdded) {
ArgumentCaptor<ParameterDeclaration> captor = ArgumentCaptor.forClass(ParameterDeclaration.class);
verify(parameterGroup).addParameter(captor.capture());
ParameterDeclaration parameter = captor.getValue();
assertThat(parameter.getName(), equalTo(PRIMARY_NODE_ONLY_PARAMETER_NAME));
assertThat(parameter.getDefaultValue(), is(defaultParameterValue));
} else {
verify(parameterGroup, never()).addParameter(any());
}
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration in project mule by mulesoft.
the class ExtensionsTestUtils method mockParameters.
public static ParameterGroupDeclaration mockParameters(ParameterizedDeclaration declaration, String groupName, ParameterDeclaration... parameters) {
ParameterGroupDeclaration group = mock(ParameterGroupDeclaration.class);
when(group.getName()).thenReturn(groupName);
when(declaration.getParameterGroups()).thenReturn(asList(group));
when(declaration.getParameterGroup(groupName)).thenReturn(group);
List<ParameterDeclaration> params = new ArrayList<>(asList(parameters));
when(group.getParameters()).thenReturn(params);
when(declaration.getAllParameters()).thenReturn(params);
return group;
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration in project mule by mulesoft.
the class BackPressureDeclarationEnricher method addBackPressureParameter.
private void addBackPressureParameter(ExtensionDeclaration extensionDeclaration, SourceDeclaration sourceDeclaration, BackPressureStrategyModelProperty property) {
ParameterDeclaration parameter = new ParameterDeclaration(BACK_PRESSURE_STRATEGY_PARAMETER_NAME);
parameter.setDescription(BACK_PRESSURE_STRATEGY_PARAMETER_DESCRIPTION);
parameter.setRequired(false);
parameter.setDefaultValue(property.getDefaultMode());
parameter.setExpressionSupport(NOT_SUPPORTED);
parameter.setLayoutModel(LayoutModel.builder().tabName(ADVANCED_TAB).build());
MetadataType type = BaseTypeBuilder.create(JAVA).stringType().id(format("%s-%s-backPressureStrategy", extensionDeclaration.getName(), sourceDeclaration.getName())).with(new EnumAnnotation<>(property.getSupportedModes().stream().map(BackPressureMode::name).toArray(String[]::new))).build();
parameter.setType(type, false);
sourceDeclaration.getParameterGroup(DEFAULT_GROUP_NAME).addParameter(parameter);
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration in project mule by mulesoft.
the class BooleanParameterDeclarationEnricher method enrich.
@Override
public void enrich(ExtensionLoadingContext extensionLoadingContext) {
ExtensionDeclaration extensionDeclaration = extensionLoadingContext.getExtensionDeclarer().getDeclaration();
new DeclarationWalker() {
@Override
protected void onParameter(ParameterizedDeclaration owner, ParameterGroupDeclaration parameterGroup, ParameterDeclaration declaration) {
declaration.getType().accept(new MetadataTypeVisitor() {
@Override
public void visitBoolean(BooleanType booleanType) {
declaration.setRequired(false);
if (declaration.getDefaultValue() == null && !declaration.isConfigOverride()) {
declaration.setDefaultValue(valueOf(FALSE));
}
}
});
}
}.walk(extensionDeclaration);
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration in project mule by mulesoft.
the class JavaDeclarationDelegateTestCase method assertParameter.
private void assertParameter(List<ParameterDeclaration> parameters, String name, String description, MetadataType metadataType, boolean required, ExpressionSupport expressionSupport, Object defaultValue) {
ParameterDeclaration param = findParameter(parameters, name);
assertThat(param, is(notNullValue()));
assertThat(param.getName(), equalTo(name));
assertThat(param.getDescription(), equalTo(description));
assertParameterType(metadataType, param);
assertThat(param.isRequired(), is(required));
assertThat(param.getExpressionSupport(), is(expressionSupport));
assertThat(param.getDefaultValue(), equalTo(defaultValue));
}
Aggregations