Search in sources :

Example 66 with ParameterModel

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

the class InjectedFieldsModelValidatorTestCase method repeatedEncodingOperationArgumentObjectFields.

@Test(expected = IllegalModelDefinitionException.class)
public void repeatedEncodingOperationArgumentObjectFields() {
    when(extensionModel.getOperationModels()).thenReturn(asList(operationModel));
    withMethod(operationModel, "argumentWithRepeatedEncodingFields");
    ParameterModel parameterModel = mock(ParameterModel.class);
    when(parameterModel.getType()).thenReturn(toMetadataType(RepeatedEncoding.class));
    mockParameters(operationModel, parameterModel);
    validate(extensionModel, validator);
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 67 with ParameterModel

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

the class InjectedFieldsModelValidatorTestCase method repeatedEncodingPojoField.

@Test(expected = IllegalModelDefinitionException.class)
public void repeatedEncodingPojoField() {
    when(extensionModel.getSourceModels()).thenReturn(asList(sourceModel));
    when(sourceModel.getSuccessCallback()).thenReturn(java.util.Optional.empty());
    when(sourceModel.getErrorCallback()).thenReturn(java.util.Optional.empty());
    ParameterModel parameterModel = mock(ParameterModel.class);
    when(parameterModel.getType()).thenReturn(toMetadataType(RepeatedEncoding.class));
    mockParameters(sourceModel, parameterModel);
    mockImplementingType(sourceModel, SourceRepeatedEncoding.class);
    validate(extensionModel, validator);
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 68 with ParameterModel

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

the class ExtensionsTestUtils method getParameter.

public static ParameterModel getParameter(String name, MetadataType metadataType) {
    ParameterModel parameterModel = getParameter();
    when(parameterModel.getName()).thenReturn(name);
    when(parameterModel.getType()).thenReturn(metadataType);
    return parameterModel;
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel)

Example 69 with ParameterModel

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

the class ExtensionsTestUtils method getParameter.

public static ParameterModel getParameter(String name, Class<?> type) {
    ParameterModel parameterModel = getParameter();
    when(parameterModel.getName()).thenReturn(name);
    when(parameterModel.getType()).thenReturn(toMetadataType(type));
    when(parameterModel.getLayoutModel()).thenReturn(empty());
    return parameterModel;
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel)

Example 70 with ParameterModel

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

the class XmlExtensionLoaderTestCase method testModuleXsdCustomTypes.

@Test
public void testModuleXsdCustomTypes() throws IOException {
    String modulePath = "modules/module-xsd-custom-types.xml";
    ExtensionModel extensionModel = getExtensionModelFrom(modulePath);
    assertThat(extensionModel.getName(), is("module-xsd-custom-types"));
    assertThat(extensionModel.getConfigurationModels().size(), is(0));
    assertThat(extensionModel.getModelProperty(GlobalElementComponentModelModelProperty.class).isPresent(), is(false));
    assertThat(extensionModel.getOperationModels().size(), is(4));
    Optional<OperationModel> operationModel = extensionModel.getOperationModel("operation-with-custom-types");
    assertThat(operationModel.isPresent(), is(true));
    final OperationModel operation = operationModel.get();
    assertThat(operation.getAllParameterModels().size(), is(4));
    assertThat(operation.getAllParameterModels().get(2).getName(), is(TARGET_PARAMETER_NAME));
    assertThat(operation.getAllParameterModels().get(3).getName(), is(TARGET_VALUE_PARAMETER_NAME));
    final ParameterModel firstParameterValueModel = operation.getAllParameterModels().get(0);
    assertThat(firstParameterValueModel.getName(), is("value"));
    assertThat(firstParameterValueModel.getType().getMetadataFormat(), is(MetadataFormat.XML));
    assertThat(firstParameterValueModel.getType(), instanceOf(ObjectType.class));
    final ObjectType firstInputParameterObjectType = (ObjectType) firstParameterValueModel.getType();
    assertThat(firstInputParameterObjectType.getFields().size(), is(1));
    assertThat(firstInputParameterObjectType.getFieldByName("User").isPresent(), is(true));
    final ParameterModel secondParameterValueModel = operation.getAllParameterModels().get(1);
    assertThat(secondParameterValueModel.getName(), is("value2"));
    assertThat(secondParameterValueModel.getType().getMetadataFormat(), is(MetadataFormat.XML));
    assertThat(secondParameterValueModel.getType(), instanceOf(ObjectType.class));
    final ObjectType secondInputParameterObjectType = (ObjectType) secondParameterValueModel.getType();
    assertThat(secondInputParameterObjectType.getFields().size(), is(1));
    assertThat(secondInputParameterObjectType.getFieldByName("Root").isPresent(), is(true));
    assertThat(operation.getOutput().getType().getMetadataFormat(), is(MetadataFormat.XML));
    assertThat(operation.getOutput().getType(), instanceOf(ObjectType.class));
    final ObjectType outputObjectType = (ObjectType) operation.getOutput().getType();
    assertThat(outputObjectType.getFields().size(), is(1));
    assertThat(outputObjectType.getFieldByName("Root0").isPresent(), is(true));
    Optional<OperationComponentModelModelProperty> modelProperty = operation.getModelProperty(OperationComponentModelModelProperty.class);
    assertThat(modelProperty.isPresent(), is(true));
    assertThat(modelProperty.get().getBodyComponentModel().getInnerComponents().size(), is(1));
}
Also used : ObjectType(org.mule.metadata.api.model.ObjectType) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) Matchers.containsString(org.hamcrest.Matchers.containsString) OperationComponentModelModelProperty(org.mule.runtime.config.internal.dsl.model.extension.xml.property.OperationComponentModelModelProperty) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) 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