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());
}
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());
}
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.");
}
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());
}
}
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"));
}
Aggregations