use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration in project mule by mulesoft.
the class ObjectStoreParameterDeclarationEnricher method enrich.
@Override
public void enrich(ExtensionLoadingContext extensionLoadingContext) {
final ExtensionDeclaration extension = extensionLoadingContext.getExtensionDeclarer().getDeclaration();
final Reference<Boolean> hasObjectStoreParams = new Reference<>(false);
new IdempotentDeclarationWalker() {
@Override
protected void onParameter(ParameterGroupDeclaration parameterGroup, ParameterDeclaration parameter) {
if (isObjectStore(parameter.getType())) {
List<StereotypeModel> stereotypes = parameter.getAllowedStereotypeModels();
if (!stereotypes.contains(OBJECT_STORE)) {
stereotypes.add(OBJECT_STORE);
}
hasObjectStoreParams.set(true);
}
}
}.walk(extension);
if (hasObjectStoreParams.get() && !isObjectStoreAlreadyImported(extension)) {
ClassTypeLoader typeLoader = ExtensionsTypeLoaderFactory.getDefault().createTypeLoader();
extension.getImportedTypes().add(new ImportedTypeModel((ObjectType) typeLoader.load(ObjectStore.class)));
}
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration 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"));
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration in project mule by mulesoft.
the class LayoutModelTestCase method assertParameterPlacement.
private void assertParameterPlacement(Pair<ParameterGroupDeclaration, ParameterDeclaration> pair, String groupName, Integer order) {
ParameterGroupDeclaration group = pair.getFirst();
assertThat(group.getName(), equalTo(groupName));
assertParameterPlacement(pair.getSecond(), order);
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration 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));
});
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration 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;
}
Aggregations