use of org.mule.runtime.api.meta.model.construct.ConstructModel 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.construct.ConstructModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method async.
@Test
public void async() {
final ConstructModel asyncModel = coreExtensionModel.getConstructModel("async").get();
assertThat(asyncModel.getNestedComponents(), hasSize(1));
NestableElementModel processors = asyncModel.getNestedComponents().get(0);
assertThat(processors, instanceOf(NestedChainModel.class));
assertThat(processors.isRequired(), is(true));
assertThat(asyncModel.getAllParameterModels(), hasSize(2));
assertThat(asyncModel.getAllParameterModels().get(0).getName(), is("name"));
assertThat(asyncModel.getAllParameterModels().get(0).getExpressionSupport(), is(NOT_SUPPORTED));
assertThat(asyncModel.getAllParameterModels().get(0).getType(), instanceOf(DefaultStringType.class));
assertThat(asyncModel.getAllParameterModels().get(0).isRequired(), is(false));
assertThat(asyncModel.getAllParameterModels().get(1).getName(), is("maxConcurrency"));
assertThat(asyncModel.getAllParameterModels().get(1).getType(), instanceOf(DefaultNumberType.class));
assertThat(asyncModel.getAllParameterModels().get(1).isRequired(), is(false));
}
use of org.mule.runtime.api.meta.model.construct.ConstructModel 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.construct.ConstructModel 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.construct.ConstructModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method choice.
@Test
public void choice() {
final ConstructModel choiceModel = coreExtensionModel.getConstructModel("choice").get();
assertThat(choiceModel.allowsTopLevelDeclaration(), is(false));
assertThat(choiceModel.getAllParameterModels(), empty());
assertThat(choiceModel.getNestedComponents(), hasSize(2));
final NestedRouteModel whenRouteModel = (NestedRouteModel) choiceModel.getNestedComponents().get(0);
assertThat(whenRouteModel.getName(), is("when"));
assertThat(whenRouteModel.getMinOccurs(), is(1));
assertThat(whenRouteModel.getMaxOccurs(), is(Optional.empty()));
assertThat(whenRouteModel.getAllParameterModels(), hasSize(1));
assertThat(whenRouteModel.getAllParameterModels().get(0).getName(), is("expression"));
assertThat(whenRouteModel.getAllParameterModels().get(0).getExpressionSupport(), is(SUPPORTED));
assertThat(whenRouteModel.getAllParameterModels().get(0).getType(), instanceOf(DefaultBooleanType.class));
assertThat(whenRouteModel.getAllParameterModels().get(0).isRequired(), is(true));
final NestedRouteModel otherwiseRouteModel = (NestedRouteModel) choiceModel.getNestedComponents().get(1);
assertThat(otherwiseRouteModel.getName(), is("otherwise"));
assertThat(otherwiseRouteModel.getMinOccurs(), is(0));
assertThat(otherwiseRouteModel.getMaxOccurs().get(), is(1));
assertThat(otherwiseRouteModel.getAllParameterModels(), empty());
}
Aggregations