-
Notifications
You must be signed in to change notification settings - Fork 40
Storing component configurations
ComponentConfigurer
is class responsible for setting values in the component dialogs basing on data tables.
The concept is to pass component configuration in one object using one Gherkin sentence. Data table must contain every detail of the configuration:
- tab - name of tab in AemDialog where field is placed,
- type - type of the field in AemDialog,
- label - label of the field in AemDialog,
- value - desired value of the field in AemDialog.
Example:
#...
And I configure component using following data
| tab | type | label | value |
| General | dropdown | Style | none |
| ... | ... | ... | ... |
#...
Type | Value |
---|---|
checkbox | TRUE/FALSE |
text field | Any string |
drop down | Option label |
rich text | Any string |
radio group | Option label |
text area | Any string |
pathfield | Path to node based on the nodes displayed in Select Path window: /node1/node2/node3 |
tags | Tag location in Tag window in following format: Namespace: Tag1/Tag2/Tag3 |
@Inject
private ComponentConfigurerFactory componentConfigurerFactory;
//...
@And("^I configure component using my component configuration data$")
public void I_configure_component_using_my_component_configuration_data(List<ConfigurationEntry> config) {
componentConfigurerFactory.create(aemDialog).configureDialog(config);
}
Sometimes instead of writing data tables in the feature file:
Given my component configuration data is:
| tab | type | label | value |
| General | text area | Text Area | textarea |
| Tab1 | text field | Text Field | textfield |
| Tab1 | pathfield | Pathfield | Node1/Node2/Node3 |
| Tab2 | dropdown | Dropdown | dropdown |
we want to simply state something like:
Given I configure my component with "valid" configuration data
Two utilities were added to allow such steps defined easily: ComponentConfigBuilder
and JsonToComponentConfig
.
To create the configuration in the code, it is possible to use ComponentConfigBuilder. It is a utility based on the Builder pattern, to obtain the configuration invoke the build()
method.
The default tab is assumed to be "General" - to change the tab for set of fields, use setTab()
.
Example of usage
List<ConfigurationEntry> config = new ComponentConfigBuilder()
.addTextArea("Text Area", "textarea")
.setTab("Tab1")
.addTextField("Text Field", "textfield")
.addPathfield("Pathfield", "Node1/Node2/Node3")
.setTab("Tab2")
.addDropdown("Dropdown", "dropdown")
.setTab("Tab3")
.addCheckbox("Checkbox", "TRUE")
.setTab("Tab4")
.addRichText("Rich Text", "richtext")
.addTags("Tags", "Namespace:Tag1/Tag2")
.addRadioGroup("Radio Group", "radiogroup")
.addItemInMultifield("Multifield", 1, DialogFields.RADIO_GROUP, "Radio Group", "radiogroup")
.addItemInFieldset("Fieldset", DialogFields.RADIO_GROUP, "Radio Group", "radiogroup")
.build();
Alternatively, to not keep the configurations for components in the code, we can provide them in JSON files and read in step definitions using JsonToComponentConfig
utility. It assumes that configurations are located under /resources/component-configs/
path.
Example of usage
{
"component": "Component",
"name": "Example",
"config": [
{
"tab": "General",
"type": "text area",
"label": "Text Area",
"value": "textarea"
},
{
"tab": "Tab1",
"type": "text field",
"label": "Text Field",
"value": "textfield"
},
{
"tab": "Tab1",
"type": "pathfield",
"label": "Pathfield",
"value": "Node1/Node2/Node3"
},
{
"tab": "Tab2",
"type": "dropdown",
"label": "Dropdown",
"value": "dropdown"
}
]
}
Step definition:
@When("^I use the \"([^\"]*)\" configuration from JSON$")
public void I_use_the_configuration_from_JSON(String configName) {
ComponentConfig config = new JsonToComponentConfig().readConfig(configName);
scenarioContext.add(configName, config.getConfig());
}
For complex fields handling information please refer to:
- Configuring Bobcat
- Selenium enhancements
- Cucumber enhancements
- Traffic analyzer
- Email support
- Reporting
- Cloud integration
- Mobile integration
- Executing tests on different environments
- Working with multiple threads
- Tips and tricks
- Authoring tutorial - Classic
- AEM Classic Authoring Advanced usage
- Siteadmin
- Sidekick
- Aem Component
- Working with author pages
- Working with Publish pages
- Advanced component interactions
- Working with Context Menu
- Using Aem Content Tree
- Aem Content Finder
- Storing component configurations
- Working with packages
- Jcr Support
- Authoring tutorial - Touch UI
- Adding and editing a component
- Sites management tutorial