Search in sources :

Example 1 with FLOW

use of org.mule.runtime.extension.api.stereotype.MuleStereotypes.FLOW 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));
}
Also used : OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) ErrorModelBuilder.newError(org.mule.runtime.api.meta.model.error.ErrorModelBuilder.newError) DefaultAnyType(org.mule.metadata.api.model.impl.DefaultAnyType) VoidType(org.mule.metadata.api.model.VoidType) Assert.assertThat(org.junit.Assert.assertThat) CPU_LITE(org.mule.runtime.api.meta.model.operation.ExecutionType.CPU_LITE) ErrorModel(org.mule.runtime.api.meta.model.error.ErrorModel) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) IsCollectionContaining.hasItem(org.hamcrest.core.IsCollectionContaining.hasItem) ArrayType(org.mule.metadata.api.model.ArrayType) TARGET_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TARGET_PARAMETER_NAME) ON_ERROR(org.mule.runtime.extension.api.stereotype.MuleStereotypes.ON_ERROR) SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.SUPPORTED) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) TypeIdAnnotation(org.mule.metadata.api.annotation.TypeIdAnnotation) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) ObjectType(org.mule.metadata.api.model.ObjectType) REQUIRED(org.mule.runtime.api.meta.ExpressionSupport.REQUIRED) ClassInformationAnnotation(org.mule.metadata.java.api.annotation.ClassInformationAnnotation) DefaultObjectType(org.mule.metadata.api.model.impl.DefaultObjectType) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) MuleManifest.getVendorName(org.mule.runtime.core.api.config.MuleManifest.getVendorName) EnumAnnotation(org.mule.metadata.api.annotation.EnumAnnotation) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) StringType(org.mule.metadata.api.model.StringType) Matchers.contains(org.hamcrest.Matchers.contains) AbstractMuleContextTestCase(org.mule.tck.junit4.AbstractMuleContextTestCase) DefaultNumberType(org.mule.metadata.api.model.impl.DefaultNumberType) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) FLOW(org.mule.runtime.extension.api.stereotype.MuleStereotypes.FLOW) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) DefaultStringType(org.mule.metadata.api.model.impl.DefaultStringType) MuleManifest.getProductVersion(org.mule.runtime.core.api.config.MuleManifest.getProductVersion) IsEmptyCollection.empty(org.hamcrest.collection.IsEmptyCollection.empty) Matchers.arrayContainingInAnyOrder(org.hamcrest.Matchers.arrayContainingInAnyOrder) TARGET_VALUE_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.TARGET_VALUE_PARAMETER_NAME) TRANSFORMATION(org.mule.runtime.core.api.exception.Errors.ComponentIdentifiers.Handleable.TRANSFORMATION) SOURCE(org.mule.runtime.extension.api.stereotype.MuleStereotypes.SOURCE) COMMUNITY(org.mule.runtime.api.meta.Category.COMMUNITY) OBJECT_STORE(org.mule.runtime.extension.api.stereotype.MuleStereotypes.OBJECT_STORE) Iterator(java.util.Iterator) ERROR_HANDLER(org.mule.runtime.extension.api.stereotype.MuleStereotypes.ERROR_HANDLER) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) DefaultBooleanType(org.mule.metadata.api.model.impl.DefaultBooleanType) Test(org.junit.Test) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) MULE_VERSION(org.mule.runtime.core.api.extension.MuleExtensionModelProvider.MULE_VERSION) MuleExtensionModelProvider.getExtensionModel(org.mule.runtime.core.api.extension.MuleExtensionModelProvider.getExtensionModel) PROCESSOR(org.mule.runtime.extension.api.stereotype.MuleStereotypes.PROCESSOR) Scheduler(org.mule.runtime.core.api.source.scheduler.Scheduler) NestedComponentModel(org.mule.runtime.api.meta.model.nested.NestedComponentModel) MULE_NAME(org.mule.runtime.core.api.extension.MuleExtensionModelProvider.MULE_NAME) NOT_SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED) SubTypesModel(org.mule.runtime.api.meta.model.SubTypesModel) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) NestedComponentModel(org.mule.runtime.api.meta.model.nested.NestedComponentModel) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) Test(org.junit.Test)

Example 2 with FLOW

use of org.mule.runtime.extension.api.stereotype.MuleStereotypes.FLOW in project mule by mulesoft.

the class ParameterAllowedStereotypesDeclarionEnricher method getStereotypes.

private List<StereotypeModel> getStereotypes(AnnotatedElement element) {
    ConfigReferences references = element.getAnnotation(ConfigReferences.class);
    if (references != null) {
        return stream(references.value()).map(ref -> newStereotype(ref.name(), ref.namespace()).withParent(CONFIG).build()).collect(toList());
    }
    ConfigReference ref = element.getAnnotation(ConfigReference.class);
    if (ref != null) {
        return singletonList(newStereotype(ref.name(), ref.namespace()).withParent(CONFIG).build());
    }
    if (element.getAnnotation(FlowReference.class) != null) {
        return singletonList(FLOW);
    }
    if (element.getAnnotation(ObjectStoreReference.class) != null) {
        return singletonList(OBJECT_STORE);
    }
    return emptyList();
}
Also used : ConfigReferences(org.mule.runtime.extension.api.annotation.ConfigReferences) OBJECT_STORE(org.mule.runtime.extension.api.stereotype.MuleStereotypes.OBJECT_STORE) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) StereotypeModel(org.mule.runtime.api.meta.model.stereotype.StereotypeModel) Collections.emptyList(java.util.Collections.emptyList) ExtensionLoadingContext(org.mule.runtime.extension.api.loader.ExtensionLoadingContext) FlowReference(org.mule.runtime.extension.api.annotation.param.reference.FlowReference) ImplementingParameterModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingParameterModelProperty) Collections.singletonList(java.util.Collections.singletonList) DeclaringMemberModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.DeclaringMemberModelProperty) CONFIG(org.mule.runtime.extension.api.stereotype.MuleStereotypes.CONFIG) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) StereotypeModelBuilder.newStereotype(org.mule.runtime.api.meta.model.stereotype.StereotypeModelBuilder.newStereotype) ConfigReference(org.mule.runtime.extension.api.annotation.param.reference.ConfigReference) ObjectStoreReference(org.mule.runtime.extension.api.annotation.param.reference.ObjectStoreReference) ParameterGroupDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration) Arrays.stream(java.util.Arrays.stream) FLOW(org.mule.runtime.extension.api.stereotype.MuleStereotypes.FLOW) IdempotentDeclarationWalker(org.mule.runtime.extension.api.declaration.fluent.util.IdempotentDeclarationWalker) AnnotatedElement(java.lang.reflect.AnnotatedElement) ObjectStoreReference(org.mule.runtime.extension.api.annotation.param.reference.ObjectStoreReference) ConfigReferences(org.mule.runtime.extension.api.annotation.ConfigReferences) ConfigReference(org.mule.runtime.extension.api.annotation.param.reference.ConfigReference) FlowReference(org.mule.runtime.extension.api.annotation.param.reference.FlowReference)

Aggregations

List (java.util.List)2 FLOW (org.mule.runtime.extension.api.stereotype.MuleStereotypes.FLOW)2 OBJECT_STORE (org.mule.runtime.extension.api.stereotype.MuleStereotypes.OBJECT_STORE)2 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Arrays.stream (java.util.Arrays.stream)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 Iterator (java.util.Iterator)1 Optional (java.util.Optional)1 Collectors.toList (java.util.stream.Collectors.toList)1 Matchers.arrayContainingInAnyOrder (org.hamcrest.Matchers.arrayContainingInAnyOrder)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)1 Matchers.is (org.hamcrest.Matchers.is)1 IsCollectionWithSize.hasSize (org.hamcrest.collection.IsCollectionWithSize.hasSize)1 IsEmptyCollection.empty (org.hamcrest.collection.IsEmptyCollection.empty)1 IsCollectionContaining.hasItem (org.hamcrest.core.IsCollectionContaining.hasItem)1 Assert.assertThat (org.junit.Assert.assertThat)1 Test (org.junit.Test)1 EnumAnnotation (org.mule.metadata.api.annotation.EnumAnnotation)1