Search in sources :

Example 6 with ParameterGroupModel

use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel in project mule by mulesoft.

the class NameClashModelValidatorTestCase method mockParameterGroup.

private void mockParameterGroup(ParameterizedModel model, List<ParameterModel> parameters) {
    ParameterGroupModel group = mock(ParameterGroupModel.class);
    when(group.getName()).thenReturn(DEFAULT_GROUP_NAME);
    when(group.getModelProperty(ParameterGroupModelProperty.class)).thenReturn(empty());
    when(group.getParameterModels()).thenReturn(parameters);
    when(group.isShowInDsl()).thenReturn(true);
    when(model.getParameterGroupModels()).thenReturn(asList(group));
}
Also used : ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)

Example 7 with ParameterGroupModel

use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel in project mule by mulesoft.

the class NameClashModelValidatorTestCase method mockParameterGroups.

private void mockParameterGroups(ParameterizedModel model, boolean showInDsl) {
    ParameterGroupModel group = mock(ParameterGroupModel.class);
    ParameterModel parameterModel = getParameter(SIMPLE_PARAM_NAME, Object.class);
    when(group.getName()).thenReturn(DEFAULT_GROUP_NAME);
    when(group.getModelProperty(ParameterGroupModelProperty.class)).thenReturn(empty());
    when(group.getParameterModels()).thenReturn(asList(parameterModel));
    ParameterGroupModel anotherGroup = mock(ParameterGroupModel.class);
    when(anotherGroup.getName()).thenReturn("My Group");
    when(anotherGroup.isShowInDsl()).thenReturn(showInDsl);
    when(anotherGroup.getParameterModels()).thenReturn(asList(parameterModel));
    when(model.getParameterGroupModels()).thenReturn(asList(group, anotherGroup));
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)

Example 8 with ParameterGroupModel

use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel in project mule by mulesoft.

the class NameClashModelValidatorTestCase method sourceWithRepeatedParameterNameAmongCallbackAndSource.

@Test
public void sourceWithRepeatedParameterNameAmongCallbackAndSource() {
    exception.expect(IllegalModelDefinitionException.class);
    ParameterModel offending = getParameter(SIMPLE_PARAM_NAME, String.class);
    SourceCallbackModel sourceCallbackModel = mock(SourceCallbackModel.class);
    mockParameters(sourceCallbackModel, simpleConfigParam);
    ParameterGroupModel group = mock(ParameterGroupModel.class);
    when(group.getName()).thenReturn(DEFAULT_GROUP_NAME);
    when(group.getModelProperty(ParameterGroupModelProperty.class)).thenReturn(empty());
    when(group.isShowInDsl()).thenReturn(false);
    when(group.getParameterModels()).thenReturn(asList(offending));
    SourceModel sourceModel = new ImmutableSourceModel(SOURCE_NAME, "", false, false, asList(group), emptyList(), null, null, of(sourceCallbackModel), empty(), empty(), false, false, false, null, SOURCE, emptySet(), emptySet(), emptySet());
    when(extensionModel.getSourceModels()).thenReturn(asList(sourceModel));
    validate();
}
Also used : SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ImmutableSourceModel(org.mule.runtime.extension.api.model.source.ImmutableSourceModel) ImmutableSourceModel(org.mule.runtime.extension.api.model.source.ImmutableSourceModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) SourceCallbackModel(org.mule.runtime.api.meta.model.source.SourceCallbackModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 9 with ParameterGroupModel

use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel in project mule by mulesoft.

the class NameClashModelValidatorTestCase method contentParameterClashWithAttributeParameterWithinSameGroup.

@Test
public void contentParameterClashWithAttributeParameterWithinSameGroup() {
    exception.expect(IllegalModelDefinitionException.class);
    ParameterGroupModel group = mock(ParameterGroupModel.class);
    ParameterModel contentParam = getParameter(CHILD_SINGULAR_PARAM_NAME, Object.class);
    when(contentParam.getRole()).thenReturn(PRIMARY_CONTENT);
    ParameterModel notContentParam = getParameter(CHILD_SINGULAR_PARAM_NAME, String.class);
    when(notContentParam.getRole()).thenReturn(BEHAVIOUR);
    when(group.getName()).thenReturn(DEFAULT_GROUP_NAME);
    when(group.getModelProperty(ParameterGroupModelProperty.class)).thenReturn(empty());
    when(group.getParameterModels()).thenReturn(asList(contentParam));
    ParameterGroupModel anotherGroup = mock(ParameterGroupModel.class);
    when(anotherGroup.getName()).thenReturn("My Group");
    when(anotherGroup.isShowInDsl()).thenReturn(false);
    when(anotherGroup.getParameterModels()).thenReturn(asList(notContentParam));
    when(operationModel.getParameterGroupModels()).thenReturn(asList(group, anotherGroup));
    validate();
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 10 with ParameterGroupModel

use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel in project mule by mulesoft.

the class ParameterGroupLayoutOrderTestCase method assertParameterOrder.

private void assertParameterOrder(ParameterizedModel parameterizedModel, String parameterName, int expectedOrder) {
    ParameterGroupModel paramOne = getNamedObject(parameterizedModel.getParameterGroupModels(), parameterName);
    Optional<LayoutModel> layoutModel = paramOne.getLayoutModel();
    assertLayoutModel(parameterName, expectedOrder, layoutModel);
}
Also used : ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) LayoutModel(org.mule.runtime.api.meta.model.display.LayoutModel) EnricherTestUtils.assertLayoutModel(org.mule.runtime.module.extension.internal.loader.enricher.EnricherTestUtils.assertLayoutModel)

Aggregations

ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)24 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)11 ParameterizedModel (org.mule.runtime.api.meta.model.parameter.ParameterizedModel)6 ExtensionWalker (org.mule.runtime.api.meta.model.util.ExtensionWalker)5 List (java.util.List)4 Optional (java.util.Optional)4 MetadataType (org.mule.metadata.api.model.MetadataType)4 ObjectType (org.mule.metadata.api.model.ObjectType)4 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)4 String.format (java.lang.String.format)3 Field (java.lang.reflect.Field)3 Set (java.util.Set)3 Test (org.junit.Test)3 MetadataTypeUtils.getLocalPart (org.mule.metadata.api.utils.MetadataTypeUtils.getLocalPart)3 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)3 JavaTypeUtils.getType (org.mule.metadata.java.api.utils.JavaTypeUtils.getType)3 NestableElementModel (org.mule.runtime.api.meta.model.nested.NestableElementModel)3 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)3 DslElementModel (org.mule.runtime.config.api.dsl.model.DslElementModel)3 MuleContext (org.mule.runtime.core.api.MuleContext)3