use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class ExportedArtifactsCollectorTestCase method mockOperationModel.
private OperationModel mockOperationModel(OutputModel output, OutputModel attributes, ParameterModel... params) {
OperationModel op = mock(OperationModel.class);
when(op.getOutput()).thenReturn(output);
when(op.getOutputAttributes()).thenReturn(attributes);
if (params != null) {
mockParameters(op, params);
}
return op;
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class OperationExecutorFactoryWrapperTestCase method mockOperation.
private OperationModel mockOperation(boolean blocking) {
OperationModel operationModel = mock(OperationModel.class);
when(operationModel.isBlocking()).thenReturn(blocking);
return operationModel;
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class XmlExtensionLoaderTestCase method testModuleSimple.
@Test
public void testModuleSimple() {
String modulePath = "modules/module-simple.xml";
ExtensionModel extensionModel = getExtensionModelFrom(modulePath);
assertThat(extensionModel.getName(), is("module-simple"));
assertThat(extensionModel.getConfigurationModels().size(), is(0));
assertThat(extensionModel.getModelProperty(GlobalElementComponentModelModelProperty.class).isPresent(), is(false));
assertThat(extensionModel.getOperationModels().size(), is(11));
Optional<OperationModel> operationModelOptional = extensionModel.getOperationModel("set-payload-concat-params-values");
assertThat(operationModelOptional.isPresent(), is(true));
final OperationModel operationModel = operationModelOptional.get();
assertThat(operationModel.getAllParameterModels().size(), is(4));
assertThat(operationModel.getAllParameterModels().get(0).getName(), is("value1"));
assertThat(operationModel.getAllParameterModels().get(1).getName(), is("value2"));
assertThat(operationModel.getAllParameterModels().get(2).getName(), is(TARGET_PARAMETER_NAME));
assertThat(operationModel.getAllParameterModels().get(3).getName(), is(TARGET_VALUE_PARAMETER_NAME));
Optional<OperationComponentModelModelProperty> modelProperty = operationModel.getModelProperty(OperationComponentModelModelProperty.class);
assertThat(modelProperty.isPresent(), is(true));
assertThat(modelProperty.get().getBodyComponentModel().getInnerComponents().size(), is(1));
assertThat(operationModel.getOutput().getType().getMetadataFormat(), is(MetadataFormat.JAVA));
assertThat(operationModel.getOutput().getType(), instanceOf(StringType.class));
assertThat(operationModel.getOutputAttributes().getType().getMetadataFormat(), is(MetadataFormat.JAVA));
assertThat(operationModel.getOutputAttributes().getType(), instanceOf(StringType.class));
assertThat(operationModel.getErrorModels().size(), is(0));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class XmlExtensionLoaderTestCase method testModuleWrongBodyContent.
@Test
public void testModuleWrongBodyContent() {
String modulePath = "validation/module-wrong-body-content.xml";
if (validateXml) {
try {
getExtensionModelFrom(modulePath);
fail("Should not have reached up to this point, the XML is invalid and the ExtensionModel should not be generated.");
} catch (MuleRuntimeException e) {
assertThat(e.getMessage(), containsString("There were '2' error"));
assertThat(e.getMessage(), containsString("Invalid content was found starting with element 'mule:fake-request-config'"));
assertThat(e.getMessage(), containsString("Invalid content was found starting with element 'mule:non-existing-operation'"));
}
} else {
ExtensionModel extensionModel = getExtensionModelFrom(modulePath);
assertThat(extensionModel.getName(), is("module-wrong-body-content"));
assertThat(extensionModel.getOperationModels().size(), is(0));
assertThat(extensionModel.getConfigurationModels().size(), is(1));
ConfigurationModel configurationModel = extensionModel.getConfigurationModels().get(0);
assertThat(configurationModel.getName(), is(CONFIG_NAME));
assertThat(configurationModel.getAllParameterModels().size(), is(2));
Optional<GlobalElementComponentModelModelProperty> globalElementComponentModelModelProperty = configurationModel.getModelProperty(GlobalElementComponentModelModelProperty.class);
assertThat(globalElementComponentModelModelProperty.isPresent(), is(true));
assertThat(globalElementComponentModelModelProperty.get().getGlobalElements().size(), is(1));
Optional<OperationModel> operationModelOptional = configurationModel.getOperationModel("operation-with-non-valid-body");
assertThat(operationModelOptional.isPresent(), is(true));
final OperationModel operationModel = operationModelOptional.get();
assertThat(operationModel.getAllParameterModels().size(), is(0));
Optional<OperationComponentModelModelProperty> modelProperty = operationModel.getModelProperty(OperationComponentModelModelProperty.class);
assertThat(modelProperty.isPresent(), is(true));
assertThat(modelProperty.get().getBodyComponentModel().getInnerComponents().size(), is(1));
assertThat(operationModel.getOutput().getType().getMetadataFormat(), is(MetadataFormat.JAVA));
assertThat(operationModel.getOutput().getType(), instanceOf(VoidType.class));
assertThat(operationModel.getOutputAttributes().getType().getMetadataFormat(), is(MetadataFormat.JAVA));
assertThat(operationModel.getOutputAttributes().getType(), instanceOf(VoidType.class));
assertThat(operationModel.getErrorModels().size(), is(0));
}
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class XmlExtensionLoaderTestCase method testModuleProperties.
@Test
public void testModuleProperties() {
String modulePath = "modules/module-properties.xml";
ExtensionModel extensionModel = getExtensionModelFrom(modulePath);
assertThat(extensionModel.getName(), is("module-properties"));
assertThat(extensionModel.getConfigurationModels().size(), is(1));
ConfigurationModel configurationModel = extensionModel.getConfigurationModels().get(0);
assertThat(configurationModel.getName(), is(CONFIG_NAME));
assertThat(configurationModel.getAllParameterModels().size(), is(5));
assertThat(configurationModel.getAllParameterModels().get(0).getName(), is("configParam"));
assertThat(configurationModel.getAllParameterModels().get(1).getName(), is("defaultConfigParam"));
Optional<GlobalElementComponentModelModelProperty> globalElementComponentModelModelProperty = configurationModel.getModelProperty(GlobalElementComponentModelModelProperty.class);
assertThat(globalElementComponentModelModelProperty.isPresent(), is(true));
assertThat(globalElementComponentModelModelProperty.get().getGlobalElements().size(), is(0));
assertThat(configurationModel.getOperationModels().size(), is(7));
Optional<OperationModel> operationModel = configurationModel.getOperationModel("set-payload-add-param-and-property-values");
assertThat(operationModel.isPresent(), is(true));
assertThat(operationModel.get().getAllParameterModels().size(), is(3));
assertThat(operationModel.get().getAllParameterModels().get(0).getName(), is("value1"));
assertThat(operationModel.get().getAllParameterModels().get(1).getName(), is(TARGET_PARAMETER_NAME));
assertThat(operationModel.get().getAllParameterModels().get(2).getName(), is(TARGET_VALUE_PARAMETER_NAME));
Optional<OperationComponentModelModelProperty> modelProperty = operationModel.get().getModelProperty(OperationComponentModelModelProperty.class);
assertThat(modelProperty.isPresent(), is(true));
assertThat(modelProperty.get().getBodyComponentModel().getInnerComponents().size(), is(1));
}
Aggregations