Search in sources :

Example 21 with ExtensionDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.

the class DefaultJavaModelLoaderDelegate method declare.

/**
 * {@inheritDoc}
 */
@Override
public ExtensionDeclarer declare(ExtensionLoadingContext context) {
    ExtensionDeclarer declarer = context.getExtensionDeclarer().named(extensionElement.getName()).onVersion(version).fromVendor(extensionElement.getVendor()).withCategory(extensionElement.getCategory()).withModelProperty(new ExtensionTypeDescriptorModelProperty(extensionElement));
    // TODO MULE-14517: This workaround should be replaced for a better and more complete mechanism
    context.getParameter("COMPILATION_MODE").ifPresent(m -> declarer.withModelProperty(new CompileTimeModelProperty()));
    extensionElement.getDeclaringClass().ifPresent(extensionClass -> declarer.withModelProperty(new ImplementingTypeModelProperty(extensionClass)));
    processLicenseRequirements(declarer);
    parseExternalLibs(extensionElement, declarer);
    addExceptionEnricher(extensionElement, declarer);
    configLoaderDelegate.declareConfigurations(declarer, extensionElement);
    connectionProviderModelLoaderDelegate.declareConnectionProviders(declarer, extensionElement);
    if (!isEmpty(extensionElement.getConfigurations())) {
        operationLoaderDelegate.declareOperations(declarer, declarer, null, extensionElement.getOperations(), false);
        functionModelLoaderDelegate.declareFunctions(declarer, declarer, null, extensionElement.getFunctions());
        extensionElement.getSources().forEach(source -> sourceModelLoaderDelegate.declareMessageSource(declarer, declarer, source, false));
    }
    return declarer;
}
Also used : ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) CompileTimeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.CompileTimeModelProperty) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)

Example 22 with ExtensionDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.

the class JavaDeclarationDelegateTestCase method minMuleVersionDefaultValueIsDescribedCorrectly.

@Test
public void minMuleVersionDefaultValueIsDescribedCorrectly() {
    setLoader(loaderFor(PetStoreConnector.class));
    ExtensionDeclarer declarer = declareExtension();
    final ExtensionDeclaration declaration = declarer.getDeclaration();
}
Also used : PetStoreConnector(org.mule.test.petstore.extension.PetStoreConnector) ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 23 with ExtensionDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.

the class JavaDeclarationDelegateTestCase method categoryIsDescribedCorrectly.

@Test
public void categoryIsDescribedCorrectly() {
    setLoader(loaderFor(HeisenbergExtension.class));
    ExtensionDeclarer declarer = declareExtension();
    final ExtensionDeclaration declaration = declarer.getDeclaration();
    assertThat(declaration.getCategory(), is(SELECT));
}
Also used : ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 24 with ExtensionDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.

the class JavaDeclarationDelegateTestCase method flowListeningOperationWithoutAttributes.

@Test
public void flowListeningOperationWithoutAttributes() {
    setLoader(loaderFor(VeganExtension.class));
    ExtensionDeclarer declarer = declareExtension();
    final ExtensionDeclaration declaration = declarer.getDeclaration();
    OperationDeclaration operation = getOperation(getConfiguration(declaration, BANANA), "getLunch");
    assertThat(operation, is(notNullValue()));
    assertOutputType(operation.getOutput(), toMetadataType(Fruit.class), false);
    assertOutputType(operation.getOutputAttributes(), TYPE_BUILDER.voidType().build(), false);
}
Also used : Fruit(org.mule.tck.testmodels.fruit.Fruit) ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) VeganExtension(org.mule.test.vegan.extension.VeganExtension) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 25 with ExtensionDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.

the class JavaDeclarationDelegateTestCase method minMuleVersionIsDescribedCorrectly.

@Test
public void minMuleVersionIsDescribedCorrectly() {
    setLoader(loaderFor(HeisenbergExtension.class));
    ExtensionDeclarer declarer = declareExtension();
    final ExtensionDeclaration declaration = declarer.getDeclaration();
}
Also used : ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Aggregations

ExtensionDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)35 ExtensionDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration)15 Test (org.junit.Test)14 SmallTest (org.mule.tck.size.SmallTest)14 DefaultExtensionLoadingContext (org.mule.runtime.extension.internal.loader.DefaultExtensionLoadingContext)8 MetadataType (org.mule.metadata.api.model.MetadataType)6 ExtensionTypeDescriptorModelProperty (org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty)6 Before (org.junit.Before)5 OperationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)5 HeisenbergExtension (org.mule.test.heisenberg.extension.HeisenbergExtension)5 Declarer (org.mule.runtime.api.meta.model.declaration.fluent.Declarer)4 ExtensionParameter (org.mule.runtime.module.extension.api.loader.java.type.ExtensionParameter)4 Type (org.mule.runtime.module.extension.api.loader.java.type.Type)4 ObjectType (org.mule.metadata.api.model.ObjectType)3 ConfigurationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration)3 HasOperationDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.HasOperationDeclarer)3 IllegalModelDefinitionException (org.mule.runtime.extension.api.exception.IllegalModelDefinitionException)3 ExtensionLoadingContext (org.mule.runtime.extension.api.loader.ExtensionLoadingContext)3 DefaultJavaModelLoaderDelegate (org.mule.runtime.module.extension.internal.loader.java.DefaultJavaModelLoaderDelegate)3 ImplementingMethodModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ImplementingMethodModelProperty)3