private DisplayModel getDisplayModel(ComponentModel componentModel) { final DisplayModel.DisplayModelBuilder displayModelBuilder = DisplayModel.builder(); displayModelBuilder.displayName(componentModel.getParameters().get(DISPLAY_NAME_ATTRIBUTE)); displayModelBuilder.summary(componentModel.getParameters().get(SUMMARY_ATTRIBUTE)); displayModelBuilder.example(componentModel.getParameters().get(EXAMPLE_ATTRIBUTE)); return displayModelBuilder.build(); }
private void assertParameterDisplayName(ParameterDeclaration param, String displayName) { DisplayModel display = param.getDisplayModel(); assertThat(display.getDisplayName(), is(displayName)); }
private void assertParameterExample(ParameterDeclaration param, String example) { DisplayModel display = param.getDisplayModel(); assertThat(display.getExample(), is(example)); }
assertThat(configurationParameterModels.get(2).getDescription(), is("")); assertThat(configurationParameterModels.get(2).getDisplayModel().isPresent(), is(true)); assertThat(configurationParameterModels.get(2).getDisplayModel().get().getDisplayName(), is("A pretty name property")); assertThat(configurationParameterModels.get(2).getDisplayModel().get().getSummary(), is("a summary tooltip property")); assertThat(configurationParameterModels.get(2).getDisplayModel().get().getExample(), is("SOME_PROPERTY_SAMPLE_DATA")); assertThat(operationModel.getDescription(), is("Documentation for the operation")); assertThat(operationModel.getDisplayModel().isPresent(), is(true)); assertThat(operationModel.getDisplayModel().get().getDisplayName(), is("A pretty name for the operation")); assertThat(operationModel.getDisplayModel().get().getSummary(), is("a summary tooltip operation")); assertThat(operationModel.getDisplayModel().get().getExample(), is("SOME_OPERATION_SAMPLE_DATA")); assertThat(allParameterModels.get(2).getDescription(), is("")); assertThat(allParameterModels.get(2).getDisplayModel().isPresent(), is(true)); assertThat(allParameterModels.get(2).getDisplayModel().get().getDisplayName(), is("A pretty name parameter")); assertThat(allParameterModels.get(2).getDisplayModel().get().getSummary(), is("a summary tooltip parameter")); assertThat(allParameterModels.get(2).getDisplayModel().get().getExample(), is("SOME_PARAMETER_SAMPLE_DATA"));
private void assertParameterSummary(ParameterDeclaration param, String summary) { DisplayModel display = param.getDisplayModel(); assertThat(display.getSummary(), is(summary)); }
@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()); }
@Test public void parseClassParameter() { ExtensionDeclaration declaration = marvelDeclarer.getDeclaration(); ConfigurationDeclaration config = findConfigByName(declaration, IronMan.CONFIG_NAME); List<ParameterDeclaration> params = config.getAllParameters(); assertThat(params, hasSize(2)); ParameterDeclaration pathParam = params.get(1); Optional<ClassValueModel> classValueModel = pathParam.getDisplayModel().getClassValueModel(); assertThat(classValueModel.isPresent(), is(true)); assertThat(classValueModel.get().getAssignableFrom(), hasSize(1)); assertThat(classValueModel.get().getAssignableFrom().get(0), equalTo("com.starkindustries.AIEngine")); }
@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")); }
@Test public void parseClassParameterInOperation() { ExtensionDeclaration declaration = marvelDeclarer.getDeclaration(); OperationDeclaration findInstructionsOperation = getOperation(declaration, "findInstructions"); List<ParameterDeclaration> params = findInstructionsOperation.getAllParameters(); assertThat(params, hasSize(2)); ParameterDeclaration pathParam = params.get(1); Optional<ClassValueModel> classValueModel = pathParam.getDisplayModel().getClassValueModel(); assertThat(classValueModel.isPresent(), is(true)); assertThat(classValueModel.get().getAssignableFrom(), hasSize(1)); assertThat(classValueModel.get().getAssignableFrom().get(0), equalTo("com.starkindustries.Reader")); }
.ifPresent(displayName -> declarer.withDisplayModel(DisplayModel.builder().displayName(displayName.value()).build()));
@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()); }
.defaultingTo(PAYLOAD) .withLayout(getLayout(3)) .withDisplayModel(DisplayModel.builder() .summary("The XML body to include in the SOAP message, with all the required parameters.") .build()); .withRole(CONTENT) .withLayout(getLayout(4)) .withDisplayModel(DisplayModel.builder() .displayName(HEADERS_DISPLAY_NAME) .summary("The XML headers to include in the SOAP message.") .withRole(CONTENT) .withLayout(getLayout(5)) .withDisplayModel(DisplayModel.builder() .summary("The attachments to include in the SOAP request.") .build()); .withDsl(ParameterDslConfiguration.getDefaultInstance()) .withLayout(LayoutModel.builder().order(2).tabName(TRANSPORT).build()) .withDisplayModel(DisplayModel.builder() .displayName(HEADERS_DISPLAY_NAME) .summary("The headers to set in the transport configuration.")
declaration.setDisplayModel(DisplayModel.builder() .displayName(displayName) .summary(summary)
/** * Declares a new connection provider for a configuration given a {@link SoapServiceProviderWrapper} declaration. * * @param configDeclarer the configuration declarer that will own the provider * @param provider a {@link SoapServiceProviderWrapper} that describes the {@link SoapServiceProvider} Type. * @param hasCustomTransports if declares custom transport or not. */ public void declare(ConfigurationDeclarer configDeclarer, SoapServiceProviderWrapper provider, boolean hasCustomTransports) { String description = provider.getDescription(); // Declares the Service Provider as a Connection Provider. ConnectionProviderDeclarer providerDeclarer = configDeclarer.withConnectionProvider(provider.getAlias()) .describedAs(description) .withModelProperty(new ConnectionTypeModelProperty(ForwardingSoapClient.class)) //TODO - MULE-14311 - Make loader work in compile time .withModelProperty(new ImplementingTypeModelProperty(provider.getDeclaringClass().get())) .withConnectionManagementType(POOLING) .supportsConnectivityTesting(provider.supportsConnectivityTesting()); ParameterDeclarationContext context = new ParameterDeclarationContext("Service Provider", providerDeclarer.getDeclaration()); parametersLoader.declare(providerDeclarer, provider.getParameters(), context); if (hasCustomTransports) { providerDeclarer.onParameterGroup(TRANSPORT_GROUP) .withRequiredParameter(TRANSPORT_PARAM) .withDisplayModel(DisplayModel.builder().displayName(TRANSPORT_GROUP).build()) .ofType(typeLoader.load(MessageDispatcherProvider.class)) .withLayout(LayoutModel.builder().order(1).tabName(TRANSPORT).build()) .withExpressionSupport(NOT_SUPPORTED); } }
.ifPresent(displayName -> declarer.withDisplayModel(DisplayModel.builder().displayName(displayName.value()).build()));
private void declareConfigurationProperties(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer configuration = extensionDeclarer.withConstruct("configurationProperties") .allowingTopLevelDefinition() .withStereotype(APP_CONFIG) .describedAs("References a file with configuration properties. 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. The file location\n" + " value may also contains references to properties that will only be resolved based on " + "system properties or properties set at deployment time."); }
declaration.setDisplayModel(DisplayModel.builder() .displayName(displayName) .summary(summary)
.describedAs(TARGET_VALUE_PARAMETER_DESCRIPTION) .withRole(BEHAVIOUR) .withDisplayModel(DisplayModel.builder().displayName(TARGET_VALUE_PARAMETER_DISPLAY_NAME).build()) .withLayout(LayoutModel.builder().tabName(ADVANCED_TAB).build()) .withModelProperty(new TargetModelProperty());