use of org.mule.runtime.api.meta.model.nested.NestedComponentModel 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.nested.NestedComponentModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method flow.
@Test
public void flow() {
final ConstructModel flow = coreExtensionModel.getConstructModel("flow").get();
assertThat(flow.getStereotype().getType(), is(FLOW.getType()));
assertThat(flow.allowsTopLevelDeclaration(), is(true));
final List<ParameterModel> paramModels = flow.getAllParameterModels();
assertThat(paramModels, hasSize(2));
ParameterModel initialState = paramModels.get(0);
assertThat(initialState.getName(), is("initialState"));
assertThat(initialState.getDefaultValue(), is("started"));
ParameterModel maxConcurrency = paramModels.get(1);
assertThat(maxConcurrency.getName(), is("maxConcurrency"));
List<? extends NestableElementModel> nestedComponents = flow.getNestedComponents();
assertThat(nestedComponents, hasSize(3));
NestableElementModel source = nestedComponents.get(0);
assertThat(source.getName(), is("source"));
assertThat(source.isRequired(), is(false));
assertThat(source, instanceOf(NestedComponentModel.class));
assertThat(((NestedComponentModel) source).getAllowedStereotypes(), contains(SOURCE));
NestableElementModel chain = nestedComponents.get(1);
assertThat(chain.getName(), is("processors"));
assertThat(chain.isRequired(), is(true));
assertThat(chain, instanceOf(NestedChainModel.class));
assertThat(((NestedChainModel) chain).getAllowedStereotypes().stream().anyMatch(s -> s.getType().equals(PROCESSOR.getType())), is(true));
NestableElementModel errorHandler = nestedComponents.get(2);
assertThat(errorHandler.getName(), is("errorHandler"));
assertThat(errorHandler.isRequired(), is(false));
assertThat(errorHandler, instanceOf(NestedComponentModel.class));
assertThat(((NestedComponentModel) errorHandler).getAllowedStereotypes(), contains(ERROR_HANDLER));
}
Aggregations