Search in sources :

Example 1 with PathModel

use of org.mule.runtime.api.meta.model.display.PathModel in project mule by mulesoft.

the class DisplayDeclarationEnricherTestCase method parseSimplePathParameter.

@Test
public void parseSimplePathParameter() {
    ExtensionDeclaration declaration = marvelDeclarer.getDeclaration();
    ConfigurationDeclaration config = findConfigByName(declaration, IronMan.CONFIG_NAME);
    List<ParameterDeclaration> params = config.getAllParameters();
    assertThat(params, hasSize(2));
    ParameterDeclaration pathParam = params.get(0);
    Optional<PathModel> pathModel = pathParam.getDisplayModel().getPathModel();
    assertThat(pathModel.isPresent(), is(true));
    assertThat(pathModel.get().getType(), is(ANY));
    assertThat(pathModel.get().acceptsUrls(), is(true));
    assertThat(pathModel.get().getFileExtensions(), empty());
}
Also used : ConfigurationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration) PathModel(org.mule.runtime.api.meta.model.display.PathModel) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Example 2 with PathModel

use of org.mule.runtime.api.meta.model.display.PathModel in project mule by mulesoft.

the class DisplayDeclarationEnricherTestCase method parsePathParameterThatIsDirectory.

@Test
public void parsePathParameterThatIsDirectory() {
    ExtensionDeclaration declaration = marvelDeclarer.getDeclaration();
    ConfigurationDeclaration config = findConfigByName(declaration, IronMan.CONFIG_NAME);
    ConnectionProviderDeclaration missileProvider = findProviderByName(config, MissileProvider.NAME);
    List<ParameterDeclaration> params = missileProvider.getAllParameters();
    assertThat(params, hasSize(1));
    ParameterDeclaration pathParam = params.get(0);
    Optional<PathModel> pathModel = pathParam.getDisplayModel().getPathModel();
    assertThat(pathModel.isPresent(), is(true));
    assertThat(pathModel.get().getType(), is(DIRECTORY));
    assertThat(pathModel.get().acceptsUrls(), is(false));
    assertThat(pathModel.get().getFileExtensions(), empty());
}
Also used : ConfigurationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration) PathModel(org.mule.runtime.api.meta.model.display.PathModel) ConnectionProviderDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclaration) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Example 3 with PathModel

use of org.mule.runtime.api.meta.model.display.PathModel in project mule by mulesoft.

the class MuleExtensionModelDeclarer method declareConfigurationProperties.

private void declareConfigurationProperties(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    ConstructDeclarer configuration = extensionDeclarer.withConstruct("configurationProperties").allowingTopLevelDefinition().withStereotype(APP_CONFIG).describedAs("Configuration properties are key/value pairs that can be stored in configuration files or set as system environment variables. " + "\nEach property%2Cs value can be referenced inside the attributes of a mule configuration file by wrapping the property%2Cs key name in the syntax: \n${key_name}. " + "\n At runtime, each property placeholder expression is substituted with the property's value. " + "\nThis allows you to externalize configuration of properties outside" + " the Mule application's deployable archive, and to allow others to change these properties based on the environment the application is being deployed to. " + "Note that a system environment variable with a matching key name will override the same key%2Cs value from a properties file. Each property has a key and a value. \n" + "The key can be referenced from the mule configuration files using the following semantics: \n" + "${key_name}. This allows to externalize configuration and change it based\n" + "on the environment the application is being deployed to.");
    configuration.onDefaultParameterGroup().withRequiredParameter("file").ofType(typeLoader.load(String.class)).withExpressionSupport(NOT_SUPPORTED).withDisplayModel(DisplayModel.builder().path(new PathModel(FILE, false, EMBEDDED, new String[] { "properties" })).build()).describedAs(" The location of the file with the configuration properties to use. " + "It may be a location in the classpath or an absolute location. \nThe file location" + " value may also contains references to properties that will only be resolved based on " + "system properties or properties set at deployment time.");
}
Also used : ConstructDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer) PathModel(org.mule.runtime.api.meta.model.display.PathModel)

Example 4 with PathModel

use of org.mule.runtime.api.meta.model.display.PathModel in project mule by mulesoft.

the class DisplayDeclarationEnricher method createDisplayModelProperty.

private void createDisplayModelProperty(BaseDeclaration declaration, Summary summaryAnnotation, DisplayName displayNameAnnotation, Example exampleAnnotation, Path pathAnnotation, ClassValue classValue) {
    String summary = summaryAnnotation != null ? summaryAnnotation.value() : null;
    String displayName = displayNameAnnotation != null ? displayNameAnnotation.value() : null;
    String example = exampleAnnotation != null ? exampleAnnotation.value() : null;
    PathModel pathModel = null;
    ClassValueModel classValueModel = null;
    if (pathAnnotation != null) {
        pathModel = new PathModel(pathAnnotation.type(), pathAnnotation.acceptsUrls(), pathAnnotation.location(), pathAnnotation.acceptedFileExtensions());
    }
    if (classValue != null) {
        classValueModel = toClassValueModel(classValue);
    }
    if (summary != null || displayName != null || example != null || pathModel != null || classValueModel != null) {
        declaration.setDisplayModel(DisplayModel.builder().displayName(displayName).summary(summary).example(example).path(pathModel).classValue(classValueModel).build());
    }
}
Also used : PathModel(org.mule.runtime.api.meta.model.display.PathModel) ClassValueModel(org.mule.runtime.api.meta.model.display.ClassValueModel) ExtensionModelUtils.toClassValueModel(org.mule.runtime.extension.api.util.ExtensionModelUtils.toClassValueModel)

Example 5 with PathModel

use of org.mule.runtime.api.meta.model.display.PathModel in project mule by mulesoft.

the class DisplayDeclarationEnricherTestCase method parsePathParameterWithFileExtensions.

@Test
public void parsePathParameterWithFileExtensions() {
    ExtensionDeclaration declaration = marvelDeclarer.getDeclaration();
    OperationDeclaration findInstructionsOperation = getOperation(declaration, "findInstructions");
    List<ParameterDeclaration> params = findInstructionsOperation.getAllParameters();
    assertThat(params, hasSize(2));
    ParameterDeclaration pathParam = params.get(0);
    Optional<PathModel> pathModel = pathParam.getDisplayModel().getPathModel();
    assertThat(pathModel.isPresent(), is(true));
    assertThat(pathModel.get().getType(), is(ANY));
    assertThat(pathModel.get().acceptsUrls(), is(false));
    assertThat(pathModel.get().getFileExtensions(), hasItem("xml"));
}
Also used : PathModel(org.mule.runtime.api.meta.model.display.PathModel) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Aggregations

PathModel (org.mule.runtime.api.meta.model.display.PathModel)5 Test (org.junit.Test)3 ExtensionDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration)3 ParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)3 ConfigurationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration)2 ConnectionProviderDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclaration)1 ConstructDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer)1 OperationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)1 ClassValueModel (org.mule.runtime.api.meta.model.display.ClassValueModel)1 ExtensionModelUtils.toClassValueModel (org.mule.runtime.extension.api.util.ExtensionModelUtils.toClassValueModel)1