use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.
the class ParametersResolver method getParametersAsResolverSet.
/**
* Constructs a {@link ResolverSet} from the parameters groups, using {@link #toValueResolver(Object, Set)} to process the values.
*
* @return a {@link ResolverSet}
*/
public ResolverSet getParametersAsResolverSet(MuleContext muleContext, ParameterizedModel model, List<ParameterGroupModel> groups) throws ConfigurationException {
List<ParameterGroupModel> inlineGroups = getInlineGroups(groups);
List<ParameterModel> allParameters = groups.stream().flatMap(g -> g.getParameterModels().stream()).collect(toList());
ResolverSet resolverSet = getParametersAsResolverSet(model, getFlatParameters(inlineGroups, allParameters), muleContext);
for (ParameterGroupModel group : inlineGroups) {
getInlineGroupResolver(group, resolverSet, muleContext);
}
return resolverSet;
}
use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.
the class DeclarationElementModelFactoryTestCase method before.
@Before
public void before() {
initMocks(this);
initializeExtensionMock(extension);
when(configuration.getName()).thenReturn(CONFIGURATION_NAME);
when(configuration.getParameterGroupModels()).thenReturn(asList(parameterGroupModel));
when(configuration.getOperationModels()).thenReturn(asList(operation));
when(configuration.getSourceModels()).thenReturn(asList(source));
when(configuration.getConnectionProviders()).thenReturn(asList(connectionProvider));
when(behaviourParameter.getName()).thenReturn(BEHAVIOUR_NAME);
when(behaviourParameter.getExpressionSupport()).thenReturn(ExpressionSupport.NOT_SUPPORTED);
when(behaviourParameter.getModelProperty(any())).thenReturn(empty());
when(behaviourParameter.getDslConfiguration()).thenReturn(ParameterDslConfiguration.getDefaultInstance());
when(behaviourParameter.getLayoutModel()).thenReturn(empty());
when(behaviourParameter.getRole()).thenReturn(BEHAVIOUR);
when(behaviourParameter.getType()).thenReturn(TYPE_LOADER.load(String.class));
when(listParameter.getName()).thenReturn(LIST_NAME);
when(listParameter.getExpressionSupport()).thenReturn(ExpressionSupport.NOT_SUPPORTED);
when(listParameter.getModelProperty(any())).thenReturn(empty());
when(listParameter.getDslConfiguration()).thenReturn(ParameterDslConfiguration.getDefaultInstance());
when(listParameter.getLayoutModel()).thenReturn(empty());
when(listParameter.getRole()).thenReturn(BEHAVIOUR);
when(listParameter.getType()).thenReturn(TYPE_BUILDER.arrayType().of(TYPE_LOADER.load(String.class)).build());
when(contentParameter.getName()).thenReturn(CONTENT_NAME);
when(contentParameter.getExpressionSupport()).thenReturn(ExpressionSupport.SUPPORTED);
when(contentParameter.getModelProperty(any())).thenReturn(empty());
when(contentParameter.getDslConfiguration()).thenReturn(ParameterDslConfiguration.getDefaultInstance());
when(contentParameter.getLayoutModel()).thenReturn(empty());
when(contentParameter.getRole()).thenReturn(CONTENT);
ObjectTypeBuilder type = TYPE_BUILDER.objectType();
type.addField().key("field").value(TYPE_LOADER.load(String.class)).build();
when(contentParameter.getType()).thenReturn(type.build());
List<ParameterModel> parameterModels = asList(contentParameter, behaviourParameter, listParameter);
when(parameterGroupModel.getName()).thenReturn(DEFAULT_GROUP_NAME);
when(parameterGroupModel.isShowInDsl()).thenReturn(false);
when(parameterGroupModel.getParameterModels()).thenReturn(parameterModels);
when(parameterGroupModel.getParameter(anyString())).thenReturn(empty());
when(source.getName()).thenReturn(SOURCE_NAME);
when(source.getParameterGroupModels()).thenReturn(asList(parameterGroupModel));
when(source.getSuccessCallback()).thenReturn(empty());
when(source.getErrorCallback()).thenReturn(empty());
when(operation.getName()).thenReturn(OPERATION_NAME);
when(operation.getParameterGroupModels()).thenReturn(asList(parameterGroupModel));
visitableMock(operation, source);
when(connectionProvider.getName()).thenReturn(CONNECTION_PROVIDER_NAME);
when(connectionProvider.getParameterGroupModels()).thenReturn(asList(parameterGroupModel));
when(typeCatalog.getSubTypes(any())).thenReturn(emptySet());
when(typeCatalog.getSuperTypes(any())).thenReturn(emptySet());
when(typeCatalog.getAllBaseTypes()).thenReturn(emptySet());
when(typeCatalog.getAllSubTypes()).thenReturn(emptySet());
when(typeCatalog.getTypes()).thenReturn(emptySet());
complexType = (ObjectType) TYPE_LOADER.load(ComplexTypePojo.class);
when(typeCatalog.getType(any())).thenReturn(Optional.of(complexType));
when(typeCatalog.containsBaseType(any())).thenReturn(false);
when(dslContext.getExtension(any())).thenReturn(Optional.of(extension));
when(dslContext.getExtensions()).thenReturn(singleton(extension));
when(dslContext.getTypeCatalog()).thenReturn(typeCatalog);
Stream.of(configuration, operation, connectionProvider, source).forEach(model -> when(model.getAllParameterModels()).thenReturn(parameterModels));
}
use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.
the class ExtensionsTestUtils method getParameter.
private static ParameterModel getParameter() {
ParameterModel parameterModel = mock(ParameterModel.class);
when(parameterModel.getModelProperty(any())).thenReturn(Optional.empty());
when(parameterModel.getDslConfiguration()).thenReturn(ParameterDslConfiguration.getDefaultInstance());
when(parameterModel.getRole()).thenReturn(BEHAVIOUR);
return parameterModel;
}
use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.
the class MetadataInputDelegate method getInputMetadataDescriptors.
/**
* For each of the Component's {@link ParameterModel} creates the corresponding {@link TypeMetadataDescriptor} using only its
* static {@link MetadataType} and ignoring if any parameter has a dynamic type.
*
* @return A {@link List} containing a {@link MetadataResult} of {@link TypeMetadataDescriptor} for each input parameter using
* only its static {@link MetadataType} and ignoring if any parameter has a dynamic type.
*/
MetadataResult<InputMetadataDescriptor> getInputMetadataDescriptors(MetadataContext context, Object key) {
InputMetadataDescriptor.InputMetadataDescriptorBuilder input = InputMetadataDescriptor.builder();
List<MetadataResult<ParameterMetadataDescriptor>> results = new LinkedList<>();
for (ParameterModel parameter : component.getAllParameterModels()) {
MetadataResult<ParameterMetadataDescriptor> result = getParameterMetadataDescriptor(parameter, context, key);
input.withParameter(parameter.getName(), result.get());
results.add(result);
}
List<MetadataFailure> failures = results.stream().flatMap(e -> e.getFailures().stream()).collect(toList());
return failures.isEmpty() ? success(input.build()) : failure(input.build(), failures);
}
use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.
the class MetadataMediator method resolveParameterGroupModelType.
private List<ParameterGroupModel> resolveParameterGroupModelType(List<ParameterGroupModel> untypedParameterGroups, Map<String, ParameterMetadataDescriptor> inputTypeDescriptors) {
List<ParameterGroupModel> parameterGroups = new LinkedList<>();
untypedParameterGroups.forEach(parameterGroup -> {
List<ParameterModel> parameters = new LinkedList<>();
parameterGroup.getParameterModels().forEach(parameterModel -> {
ParameterMetadataDescriptor parameterMetadataDescriptor = inputTypeDescriptors.get(parameterModel.getName());
ParameterModel typedParameterModel = new ImmutableParameterModel(parameterModel.getName(), parameterModel.getDescription(), parameterMetadataDescriptor.getType(), parameterMetadataDescriptor.isDynamic(), parameterModel.isRequired(), parameterModel.isOverrideFromConfig(), parameterModel.getExpressionSupport(), parameterModel.getDefaultValue(), parameterModel.getRole(), parameterModel.getDslConfiguration(), parameterModel.getDisplayModel().orElse(null), parameterModel.getLayoutModel().orElse(null), parameterModel.getValueProviderModel().orElse(null), parameterModel.getAllowedStereotypes(), parameterModel.getModelProperties());
parameters.add(typedParameterModel);
});
parameterGroups.add(new ImmutableParameterGroupModel(parameterGroup.getName(), parameterGroup.getDescription(), parameters, parameterGroup.getExclusiveParametersModels(), parameterGroup.isShowInDsl(), parameterGroup.getDisplayModel().orElse(null), parameterGroup.getLayoutModel().orElse(null), parameterGroup.getModelProperties()));
});
return parameterGroups;
}
Aggregations