use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method errorHandler.
@Test
public void errorHandler() {
final ConstructModel errorHandlerModel = coreExtensionModel.getConstructModel("errorHandler").get();
assertThat(errorHandlerModel.allowsTopLevelDeclaration(), is(true));
assertThat(errorHandlerModel.getStereotype().getType(), is(ERROR_HANDLER.getType()));
assertThat(errorHandlerModel.getAllParameterModels(), hasSize(1));
ParameterModel ref = errorHandlerModel.getAllParameterModels().get(0);
assertThat(ref.getName(), is("ref"));
assertThat(ref.getType(), is(instanceOf(StringType.class)));
assertThat(ref.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(ref.isRequired(), is(false));
assertThat(ref.getAllowedStereotypes(), hasSize(1));
assertThat(ref.getAllowedStereotypes().iterator().next().getType(), is(ERROR_HANDLER.getType()));
assertThat(errorHandlerModel.getNestedComponents(), hasSize(3));
NestedRouteModel onErrorContinue = (NestedRouteModel) errorHandlerModel.getNestedComponents().get(0);
verifyOnError(onErrorContinue);
NestedRouteModel onErrorPropagate = (NestedRouteModel) errorHandlerModel.getNestedComponents().get(1);
verifyOnError(onErrorPropagate);
NestedComponentModel onErrorDelegate = (NestedComponentModel) errorHandlerModel.getNestedComponents().get(2);
assertThat(onErrorDelegate.isRequired(), is(false));
assertThat(onErrorDelegate.getAllowedStereotypes(), hasSize(1));
assertThat(onErrorDelegate.getAllowedStereotypes().iterator().next().getType(), is(ON_ERROR.getType()));
final ConstructModel onError = coreExtensionModel.getConstructModel("onError").get();
List<ParameterModel> allParameterModels = onError.getAllParameterModels();
assertThat(allParameterModels, hasSize(1));
ParameterModel onErrorRef = allParameterModels.get(0);
assertThat(onErrorRef.getName(), is("ref"));
assertThat(onErrorRef.getType(), is(instanceOf(DefaultStringType.class)));
assertThat(onErrorRef.isRequired(), is(true));
assertThat(onErrorRef.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(onErrorDelegate.getAllowedStereotypes(), hasSize(1));
assertThat(onErrorDelegate.getAllowedStereotypes().iterator().next().getType(), is(ON_ERROR.getType()));
}
use of org.mule.runtime.api.meta.model.parameter.ParameterModel 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.parameter.ParameterModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method foreach.
@Test
public void foreach() {
final ConstructModel foreach = coreExtensionModel.getConstructModel("foreach").get();
assertThat(foreach.getNestedComponents().size(), is(1));
NestableElementModel processorsChain = foreach.getNestedComponents().get(0);
assertThat(processorsChain, instanceOf(NestedChainModel.class));
assertThat(processorsChain.isRequired(), is(true));
assertThat(foreach.getAllParameterModels(), hasSize(4));
ParameterModel collection = foreach.getAllParameterModels().get(0);
assertThat(collection.getName(), is("collection"));
assertThat(collection.getExpressionSupport(), is(REQUIRED));
assertThat(collection.getType(), instanceOf(ArrayType.class));
assertThat(collection.getType().getAnnotation(ClassInformationAnnotation.class).map(ClassInformationAnnotation::getClassname).orElse(""), is(Iterable.class.getName()));
assertThat(collection.isRequired(), is(false));
ParameterModel batchSize = foreach.getAllParameterModels().get(1);
assertThat(batchSize.getName(), is("batchSize"));
assertThat(batchSize.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(batchSize.getType(), instanceOf(DefaultNumberType.class));
assertThat(batchSize.isRequired(), is(false));
ParameterModel rootMessageName = foreach.getAllParameterModels().get(2);
assertThat(rootMessageName.getName(), is("rootMessageVariableName"));
assertThat(rootMessageName.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(rootMessageName.getType(), instanceOf(DefaultStringType.class));
assertThat(rootMessageName.isRequired(), is(false));
ParameterModel counter = foreach.getAllParameterModels().get(3);
assertThat(counter.getName(), is("counterVariableName"));
assertThat(counter.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(counter.getType(), instanceOf(DefaultStringType.class));
assertThat(counter.isRequired(), is(false));
}
use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method tryScope.
@Test
public void tryScope() {
final ConstructModel tryModel = coreExtensionModel.getConstructModel("try").get();
List<ParameterModel> allParameterModels = tryModel.getAllParameterModels();
assertThat(allParameterModels, hasSize(2));
ParameterModel action = allParameterModels.get(0);
assertThat(action.getName(), is("transactionalAction"));
assertThat(action.getType(), is(instanceOf(DefaultStringType.class)));
assertThat(action.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(action.isRequired(), is(false));
ParameterModel type = allParameterModels.get(1);
assertThat(type.getName(), is("transactionType"));
assertThat(type.getType(), is(instanceOf(DefaultStringType.class)));
assertThat(type.getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(type.isRequired(), is(false));
}
use of org.mule.runtime.api.meta.model.parameter.ParameterModel 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));
}
Aggregations