use of org.mule.runtime.api.meta.model.source.SourceCallbackModel in project mule by mulesoft.
the class InputParametersTypeModelValidator method validate.
@Override
public void validate(ExtensionModel extensionModel, ProblemsReporter problems) {
final Set<Class<?>> validatedTypes = new HashSet<>();
new IdempotentExtensionWalker() {
@Override
public void onOperation(OperationModel model) {
model.getAllParameterModels().forEach(parameterModel -> validateJavaType(model, parameterModel.getType(), problems, validatedTypes));
}
@Override
public void onSource(SourceModel model) {
validateCallback(model, model.getSuccessCallback());
validateCallback(model, model.getErrorCallback());
validateCallback(model, model.getTerminateCallback());
}
private void validateCallback(SourceModel model, Optional<SourceCallbackModel> callback) {
callback.ifPresent(cb -> cb.getAllParameterModels().forEach(parameterModel -> validateJavaType(model, parameterModel.getType(), problems, validatedTypes)));
}
}.walk(extensionModel);
extensionModel.getSubTypes().forEach(subTypesModel -> getClassForValidation(subTypesModel.getBaseType()).filter(validatedTypes::contains).ifPresent(type -> {
subTypesModel.getSubTypes().forEach(subtype -> validateSubtypesHaveGetters(extensionModel, subtype, problems, validatedTypes));
}));
}
use of org.mule.runtime.api.meta.model.source.SourceCallbackModel in project mule by mulesoft.
the class NameClashModelValidatorTestCase method sourceWithRepeatedParameterNameAmongCallbacks.
@Test
public void sourceWithRepeatedParameterNameAmongCallbacks() {
SourceCallbackModel errorCallBack = mock(SourceCallbackModel.class);
when(errorCallBack.getAllParameterModels()).thenReturn(asList(simpleConnectionProviderParam));
when(sourceModel.getErrorCallback()).thenReturn(of(errorCallBack));
SourceCallbackModel successCallback = mock(SourceCallbackModel.class);
when(successCallback.getAllParameterModels()).thenReturn(asList(simpleConnectionProviderParam));
when(sourceModel.getSuccessCallback()).thenReturn(of(successCallback));
validate();
}
use of org.mule.runtime.api.meta.model.source.SourceCallbackModel 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();
}
use of org.mule.runtime.api.meta.model.source.SourceCallbackModel in project mule by mulesoft.
the class NameClashModelValidatorTestCase method sourceWithRepeatedParameterNameWithinCallback.
@Test
public void sourceWithRepeatedParameterNameWithinCallback() {
exception.expect(IllegalModelDefinitionException.class);
ParameterModel offending = getParameter(SIMPLE_PARAM_NAME, String.class);
SourceCallbackModel sourceCallbackModel = mock(SourceCallbackModel.class);
mockParameters(sourceCallbackModel, simpleConnectionProviderParam, offending);
when(sourceModel.getErrorCallback()).thenReturn(of(sourceCallbackModel));
validate();
}
Aggregations