Search in sources :

Example 1 with ConstructModel

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()));
}
Also used : ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) NestedComponentModel(org.mule.runtime.api.meta.model.nested.NestedComponentModel) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) Test(org.junit.Test)

Example 2 with ConstructModel

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));
}
Also used : ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) DefaultNumberType(org.mule.metadata.api.model.impl.DefaultNumberType) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) DefaultStringType(org.mule.metadata.api.model.impl.DefaultStringType) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) Test(org.junit.Test)

Example 3 with ConstructModel

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));
}
Also used : ArrayType(org.mule.metadata.api.model.ArrayType) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) DefaultNumberType(org.mule.metadata.api.model.impl.DefaultNumberType) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) DefaultStringType(org.mule.metadata.api.model.impl.DefaultStringType) ClassInformationAnnotation(org.mule.metadata.java.api.annotation.ClassInformationAnnotation) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) Test(org.junit.Test)

Example 4 with ConstructModel

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));
}
Also used : ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) Test(org.junit.Test)

Example 5 with ConstructModel

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());
}
Also used : ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) DefaultBooleanType(org.mule.metadata.api.model.impl.DefaultBooleanType) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) Test(org.junit.Test)

Aggregations

ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)20 Test (org.junit.Test)12 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)10 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)9 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)8 NestedRouteModel (org.mule.runtime.api.meta.model.nested.NestedRouteModel)7 DslSyntaxResolver (org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver)6 ArrayType (org.mule.metadata.api.model.ArrayType)5 DefaultNumberType (org.mule.metadata.api.model.impl.DefaultNumberType)5 DefaultStringType (org.mule.metadata.api.model.impl.DefaultStringType)5 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)5 NestableElementModel (org.mule.runtime.api.meta.model.nested.NestableElementModel)5 ExtensionWalker (org.mule.runtime.api.meta.model.util.ExtensionWalker)5 List (java.util.List)4 Optional (java.util.Optional)4 ObjectType (org.mule.metadata.api.model.ObjectType)4 ComponentModel (org.mule.runtime.api.meta.model.ComponentModel)4 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)4 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)4 NestedChainModel (org.mule.runtime.api.meta.model.nested.NestedChainModel)4