Search in sources :

Example 1 with ExclusiveParametersDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.ExclusiveParametersDeclaration in project mule by mulesoft.

the class ExclusiveOptionalModelTestCase method exclusiveOptionals.

@Test
public void exclusiveOptionals() {
    OperationDeclaration operation = getOperation(extensionDeclaration, "convinceAnimalKiller");
    assertThat(operation.getParameterGroups(), hasSize(2));
    ParameterGroupDeclaration group = operation.getParameterGroups().get(0);
    assertThat(group.getName(), equalTo("arguments"));
    assertThat(group.getExclusiveParameters(), hasSize(1));
    ExclusiveParametersDeclaration exclusive = group.getExclusiveParameters().get(0);
    assertThat(exclusive.isRequiresOne(), is(false));
    assertThat(exclusive.getParameterNames(), containsInAnyOrder("argument1", "argument2", "argument3"));
}
Also used : ExclusiveParametersDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExclusiveParametersDeclaration) ParameterGroupDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) Test(org.junit.Test)

Example 2 with ExclusiveParametersDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.ExclusiveParametersDeclaration in project mule by mulesoft.

the class ParameterModelsLoaderDelegate method parseExclusiveOptional.

private void parseExclusiveOptional(ExtensionParameter extensionParameter, ParameterGroupDeclarer parameterGroupDeclarer, ParameterDeclarer parameter) {
    ParameterGroupDeclaration groupDeclaration = (ParameterGroupDeclaration) parameterGroupDeclarer.getDeclaration();
    List<ExclusiveParametersDeclaration> exclusiveParameters = groupDeclaration.getExclusiveParameters();
    exclusiveParameters.stream().filter(group -> group.getParameterNames().contains(extensionParameter.getAlias())).findFirst().ifPresent(exclusiveParametersDeclaration -> {
        ExclusiveParametersModel exclusiveParametersModel = new ImmutableExclusiveParametersModel(exclusiveParametersDeclaration.getParameterNames(), exclusiveParametersDeclaration.isRequiresOne());
        parameter.withModelProperty(new ExclusiveOptionalModelProperty(exclusiveParametersModel));
    });
}
Also used : ExclusiveParametersDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExclusiveParametersDeclaration) ExclusiveParametersModel(org.mule.runtime.api.meta.model.parameter.ExclusiveParametersModel) ImmutableExclusiveParametersModel(org.mule.runtime.extension.api.model.parameter.ImmutableExclusiveParametersModel) ParameterGroupDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration) ExclusiveOptionalModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ExclusiveOptionalModelProperty) ImmutableExclusiveParametersModel(org.mule.runtime.extension.api.model.parameter.ImmutableExclusiveParametersModel)

Aggregations

ExclusiveParametersDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExclusiveParametersDeclaration)2 ParameterGroupDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration)2 Test (org.junit.Test)1 OperationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)1 ExclusiveParametersModel (org.mule.runtime.api.meta.model.parameter.ExclusiveParametersModel)1 ImmutableExclusiveParametersModel (org.mule.runtime.extension.api.model.parameter.ImmutableExclusiveParametersModel)1 ExclusiveOptionalModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ExclusiveOptionalModelProperty)1