Search in sources :

Example 56 with ParameterModel

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

the class NameClashModelValidatorTestCase method connectionProviderWithRepeatedParameterName.

@Test
public void connectionProviderWithRepeatedParameterName() {
    exception.expect(IllegalModelDefinitionException.class);
    ParameterModel offending = getParameter(SIMPLE_PARAM_NAME, String.class);
    mockParameters(connectionProviderModel, simpleConfigParam, topLevelConfigParam, offending);
    validate();
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 57 with ParameterModel

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

the class NameClashModelValidatorTestCase method connectionProviderNameClashesWithOperationParameterType.

@Test
public void connectionProviderNameClashesWithOperationParameterType() {
    exception.expect(IllegalModelDefinitionException.class);
    String clashingName = SIMPLE_PARAM_NAME + CONNECTION_PROVIDER_SUFFIX;
    when(connectionProviderModel.getName()).thenReturn(clashingName);
    ParameterModel offending = getParameter(clashingName, TopLevelTest.class);
    when(operationModel.getAllParameterModels()).thenReturn(asList(topLevelOperationParam, offending));
    validate();
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 58 with ParameterModel

use of org.mule.runtime.api.meta.model.parameter.ParameterModel 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 59 with ParameterModel

use of org.mule.runtime.api.meta.model.parameter.ParameterModel 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 60 with ParameterModel

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

the class NameClashModelValidatorTestCase method contentParameterValidationIsSkipped.

@Test
public void contentParameterValidationIsSkipped() {
    ParameterModel offending = getParameter(SIMPLE_PARAM_NAME, String.class);
    when(offending.getRole()).thenReturn(CONTENT);
    when(connectionProviderModel.getAllParameterModels()).thenReturn(asList(simpleConnectionProviderParam, topLevelConnectionProviderParam, offending));
    validate();
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)133 Test (org.junit.Test)91 SmallTest (org.mule.tck.size.SmallTest)68 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)29 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)21 List (java.util.List)19 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)19 Optional (java.util.Optional)16 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)15 Collectors.toList (java.util.stream.Collectors.toList)13 ObjectType (org.mule.metadata.api.model.ObjectType)13 String.format (java.lang.String.format)12 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)12 ParameterizedModel (org.mule.runtime.api.meta.model.parameter.ParameterizedModel)12 ExtensionsTypeLoaderFactory (org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory)12 StringType (org.mule.metadata.api.model.StringType)11 ClassTypeLoader (org.mule.metadata.api.ClassTypeLoader)10 ArrayType (org.mule.metadata.api.model.ArrayType)10 MetadataType (org.mule.metadata.api.model.MetadataType)10 Map (java.util.Map)9