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);
}
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);
}
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;
}
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;
}
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));
}
Aggregations