use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method idempotentMessageValidator.
@Test
public void idempotentMessageValidator() {
final OperationModel filterModel = coreExtensionModel.getOperationModel("idempotentMessageValidator").get();
assertThat(filterModel.getStereotype(), is(PROCESSOR));
assertOutputSameAsInput(filterModel);
assertThat(filterModel.getAllParameterModels(), hasSize(4));
assertThat(filterModel.getAllParameterModels().get(0).getName(), is("idExpression"));
assertThat(filterModel.getAllParameterModels().get(0).getExpressionSupport(), is(SUPPORTED));
assertThat(filterModel.getAllParameterModels().get(0).getType(), instanceOf(DefaultStringType.class));
assertThat(filterModel.getAllParameterModels().get(0).isRequired(), is(false));
assertThat(filterModel.getAllParameterModels().get(1).getName(), is("valueExpression"));
assertThat(filterModel.getAllParameterModels().get(1).getExpressionSupport(), is(SUPPORTED));
assertThat(filterModel.getAllParameterModels().get(1).getType(), instanceOf(DefaultStringType.class));
assertThat(filterModel.getAllParameterModels().get(1).isRequired(), is(false));
assertThat(filterModel.getAllParameterModels().get(2).getName(), is("storePrefix"));
assertThat(filterModel.getAllParameterModels().get(2).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(filterModel.getAllParameterModels().get(2).getType(), instanceOf(DefaultStringType.class));
assertThat(filterModel.getAllParameterModels().get(2).isRequired(), is(false));
assertThat(filterModel.getAllParameterModels().get(3).getName(), is("objectStore"));
assertThat(filterModel.getAllParameterModels().get(3).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(filterModel.getAllParameterModels().get(3).getType(), instanceOf(DefaultObjectType.class));
assertThat(filterModel.getAllParameterModels().get(3).isRequired(), is(false));
assertThat(filterModel.getAllParameterModels().get(3).getAllowedStereotypes().size(), is(1));
assertThat(filterModel.getAllParameterModels().get(3).getAllowedStereotypes().get(0), is(OBJECT_STORE));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method logger.
@Test
public void logger() {
final OperationModel loggerModel = coreExtensionModel.getOperationModel("logger").get();
assertThat(loggerModel.getStereotype(), is(PROCESSOR));
assertThat(loggerModel.getErrorModels(), empty());
assertThat(loggerModel.getExecutionType(), is(CPU_LITE));
assertOutputSameAsInput(loggerModel);
final List<ParameterModel> paramModels = loggerModel.getAllParameterModels();
assertThat(paramModels, hasSize(3));
assertThat(paramModels.get(0).getName(), is("message"));
assertThat(paramModels.get(0).getExpressionSupport(), is(SUPPORTED));
assertThat(paramModels.get(0).getType(), instanceOf(StringType.class));
assertThat(paramModels.get(0).isRequired(), is(false));
assertThat(paramModels.get(1).getName(), is("level"));
assertThat(paramModels.get(1).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(paramModels.get(1).getType(), instanceOf(DefaultStringType.class));
assertThat(paramModels.get(1).isRequired(), is(false));
assertThat(paramModels.get(2).getName(), is("category"));
assertThat(paramModels.get(2).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(paramModels.get(2).getType(), instanceOf(StringType.class));
assertThat(paramModels.get(2).isRequired(), is(false));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method raiseError.
@Test
public void raiseError() {
final OperationModel raiseErrorModel = coreExtensionModel.getOperationModel("raiseError").get();
assertThat(raiseErrorModel.getStereotype(), is(PROCESSOR));
assertThat(raiseErrorModel.getErrorModels(), empty());
assertThat(raiseErrorModel.getExecutionType(), is(CPU_LITE));
assertOutputSameAsInput(raiseErrorModel);
final List<ParameterModel> paramModels = raiseErrorModel.getAllParameterModels();
assertThat(paramModels, hasSize(2));
assertThat(paramModels.get(0).getName(), is("type"));
assertThat(paramModels.get(0).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(paramModels.get(0).getType(), instanceOf(DefaultStringType.class));
assertThat(paramModels.get(0).isRequired(), is(true));
assertThat(paramModels.get(1).getName(), is("description"));
assertThat(paramModels.get(1).getExpressionSupport(), is(SUPPORTED));
assertThat(paramModels.get(1).getType(), instanceOf(StringType.class));
assertThat(paramModels.get(1).isRequired(), is(false));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class ExportedPackagesValidatorTestCase method setUpInvalidExtension.
private void setUpInvalidExtension() {
OutputModel appleList = mockOutputModel(InternalTestClass.class);
OperationModel firstOperation = mockOperationModel(appleList, mockOutputModel(InternalTestClass.class));
withMethod(firstOperation, getApiMethods(InternalTestClass.class).stream().filter(m -> m.getName().equals("someOperation")).findFirst());
ParameterModel parameter = mockParameterModel(Shape.class);
OutputModel resultList = mockOutputModel(new TypeToken<List<Result<Apple, VeganAttributes>>>() {
}.getType());
OperationModel secondOperation = mockOperationModel(resultList, mockOutputModel(List.class), parameter);
withMethod(secondOperation, empty());
when(extensionModel.getOperationModels()).thenReturn(asList(firstOperation, secondOperation));
visitableMock(firstOperation, secondOperation);
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class DefaultExtensionBuildingDefinitionProvider method registerExtensionParsers.
private void registerExtensionParsers(ExtensionModel extensionModel) {
XmlDslModel xmlDslModel = extensionModel.getXmlDslModel();
final ExtensionParsingContext parsingContext = createParsingContext(extensionModel);
final Builder definitionBuilder = new Builder().withNamespace(xmlDslModel.getPrefix());
final DslSyntaxResolver dslSyntaxResolver = DslSyntaxResolver.getDefault(extensionModel, DslResolvingContext.getDefault(extensions));
if (extensionModel.getModelProperty(CustomBuildingDefinitionProviderModelProperty.class).isPresent()) {
return;
}
if (extensionModel.getModelProperty(XmlExtensionModelProperty.class).isPresent()) {
registerXmlExtensionParsers(definitionBuilder, extensionModel, dslSyntaxResolver);
} else {
final ClassLoader extensionClassLoader = getClassLoader(extensionModel);
withContextClassLoader(extensionClassLoader, () -> {
ReflectionCache reflectionCache = new ReflectionCache();
new IdempotentExtensionWalker() {
@Override
public void onConfiguration(ConfigurationModel model) {
parseWith(new ConfigurationDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
}
@Override
protected void onConstruct(ConstructModel model) {
parseWith(new ConstructDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
}
@Override
public void onOperation(OperationModel model) {
parseWith(new OperationDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
}
@Override
public void onConnectionProvider(ConnectionProviderModel model) {
parseWith(new ConnectionProviderDefinitionParser(definitionBuilder, model, extensionModel, dslSyntaxResolver, parsingContext));
}
@Override
public void onSource(SourceModel model) {
parseWith(new SourceDefinitionParser(definitionBuilder, extensionModel, model, dslSyntaxResolver, parsingContext));
}
@Override
protected void onParameter(ParameterGroupModel groupModel, ParameterModel model) {
registerTopLevelParameter(model.getType(), definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
}
}.walk(extensionModel);
registerExportedTypesTopLevelParsers(extensionModel, definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
registerSubTypes(definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
});
}
}
Aggregations