Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Feb 24, 2023
2 parents a0485db + 97f8af2 commit b055eef
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [8, 11, 17]
java: [11, 17]
os: [ubuntu-latest]
distribution: [temurin]

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Deploy snapshots to Sonatpe OSS repository and deploy site to GitHub Pages
# Deploy snapshots to Sonatype OSS repository and deploy site to GitHub Pages

name: Deploy

Expand All @@ -15,19 +15,19 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Configure GIT
run: |
git config --global user.email "${{ secrets.GH_SITE_DEPLOY_EMAIL }}"
git config --global user.name "${{ secrets.GH_SITE_DEPLOY_NAME }}"
- name: Setup JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
cache: 'maven'
java-version: 11
cache: maven

- name: Build, verify, deploy, generate site
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ncipollo/release-action@v1
with:
body: 'Changes: https://wcm.io/caconfig/editor/changes-report.html'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Context-Aware Configuration Editor Template for AEM.

Documentation: https://wcm.io/caconfig/editor/<br/>
Issues: https://wcm-io.atlassian.net/browse/WCON<br/>
Issues: https://github.com/wcm-io/io.wcm.caconfig.editor/issues<br/>
Wiki: https://wcm-io.atlassian.net/wiki/<br/>
Continuous Integration: https://github.com/wcm-io/io.wcm.caconfig.editor/actions<br/>
Commercial support: https://wcm.io/commercial-support.html
Expand Down
11 changes: 8 additions & 3 deletions bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.caconfig.editor.parent</artifactId>
<version>1.15.2</version>
<version>1.15.4</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm</groupId>
<artifactId>io.wcm.caconfig.editor</artifactId>
<version>1.15.2</version>
<version>1.15.4</version>
<packaging>jar</packaging>

<name>Context-Aware Configuration Editor</name>
Expand All @@ -42,7 +42,7 @@
<site.url.module.prefix>caconfig/editor/bundle</site.url.module.prefix>

<!-- Enable reproducible builds -->
<project.build.outputTimestamp>2022-12-15T11:40:34Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2023-02-24T14:52:49Z</project.build.outputTimestamp>
</properties>

<dependencies>
Expand Down Expand Up @@ -179,6 +179,11 @@
Sling-Initial-Content: \
SLING-INF/app-root;overwrite:=true;ignoreImportProviders:=xml;path:=/apps/wcm-io/caconfig/editor

<!-- register non-standard JCR namespaces for conversion with cp2fm into enhanced DocView files -->
Sling-Namespaces: \
cq=http://www.day.com/jcr/cq/1.0,\
sling=http://sling.apache.org/jcr/sling/1.0

<!-- Make compatible with different AEM versions -->
Import-Package: \
javax.annotation;version="[0.0,2)",\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,28 @@
*/
package io.wcm.caconfig.editor.impl;

import static io.wcm.caconfig.editor.impl.NameConstants.RP_COLLECTION;
import static io.wcm.caconfig.editor.impl.NameConstants.RP_CONFIGNAME;
import static io.wcm.caconfig.extensions.persistence.testcontext.PersistenceTestUtils.writeConfiguration;
import static io.wcm.caconfig.extensions.persistence.testcontext.PersistenceTestUtils.writeConfigurationCollection;
import static org.apache.sling.api.resource.ResourceResolver.PROPERTY_RESOURCE_TYPE;
import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.sling.testing.mock.caconfig.MockContextAwareConfig;
import org.apache.sling.testing.mock.osgi.MockOsgi;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.skyscreamer.jsonassert.JSONAssert;

import com.day.cq.wcm.api.Page;
import com.google.common.collect.ImmutableList;

import io.wcm.caconfig.extensions.persistence.example.ListConfig;
import io.wcm.caconfig.extensions.persistence.example.ListNestedConfig;
import io.wcm.caconfig.extensions.persistence.example.NestedConfig;
Expand All @@ -32,22 +52,6 @@
import io.wcm.testing.mock.aem.junit5.AemContextBuilder;
import io.wcm.testing.mock.aem.junit5.AemContextCallback;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import javax.servlet.http.HttpServletResponse;
import org.apache.sling.testing.mock.caconfig.MockContextAwareConfig;
import org.apache.sling.testing.mock.osgi.MockOsgi;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.skyscreamer.jsonassert.JSONAssert;

import static io.wcm.caconfig.editor.impl.NameConstants.RP_COLLECTION;
import static io.wcm.caconfig.editor.impl.NameConstants.RP_CONFIGNAME;
import static io.wcm.caconfig.extensions.persistence.testcontext.PersistenceTestUtils.writeConfiguration;
import static io.wcm.caconfig.extensions.persistence.testcontext.PersistenceTestUtils.writeConfigurationCollection;
import static org.apache.sling.api.resource.ResourceResolver.PROPERTY_RESOURCE_TYPE;
import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;
import static org.junit.jupiter.api.Assertions.assertEquals;

@ExtendWith(AemContextExtension.class)
class ConfigDataServletPagePersistenceTest {
Expand Down Expand Up @@ -121,7 +125,7 @@ void testListConfig() throws Exception {
MockContextAwareConfig.registerAnnotationClasses(context, ListConfig.class);

// write config
writeConfigurationCollection(context, contentPage.getPath(), ListConfig.class.getName(), ImmutableList.of(
writeConfigurationCollection(context, contentPage.getPath(), ListConfig.class.getName(), List.of(
ImmutableValueMap.of("stringParam", "value1", "intParam", 123)),
ImmutableValueMap.of("sling:configCollectionInherit", true));

Expand Down Expand Up @@ -154,9 +158,9 @@ void testListNestedConfig() throws Exception {
MockContextAwareConfig.registerAnnotationClasses(context, ListNestedConfig.class);

// write config
writeConfigurationCollection(context, contentPage.getPath(), ListNestedConfig.class.getName(), ImmutableList.of(
writeConfigurationCollection(context, contentPage.getPath(), ListNestedConfig.class.getName(), List.of(
ImmutableValueMap.of("stringParam", "value1", "intParam", 123)));
writeConfigurationCollection(context, contentPage.getPath(), ListNestedConfig.class.getName() + "/item0/jcr:content/subListConfig", ImmutableList.of(
writeConfigurationCollection(context, contentPage.getPath(), ListNestedConfig.class.getName() + "/item0/jcr:content/subListConfig", List.of(
ImmutableValueMap.of("stringParam", "value11")));

context.request().setParameterMap(ImmutableValueMap.of(
Expand Down Expand Up @@ -201,7 +205,7 @@ void testNestedConfig() throws Exception {
writeConfiguration(context, contentPage.getPath(), NestedConfig.class.getName() + "/jcr:content/subConfig",
"stringParam", "value2",
"intParam", 234);
writeConfigurationCollection(context, contentPage.getPath(), NestedConfig.class.getName() + "/jcr:content/subListConfig", ImmutableList.of(
writeConfigurationCollection(context, contentPage.getPath(), NestedConfig.class.getName() + "/jcr:content/subListConfig", List.of(
ImmutableValueMap.of("stringParam", "value3", "intParam", 345)));

context.request().setParameterMap(ImmutableValueMap.of(
Expand Down Expand Up @@ -259,7 +263,7 @@ void testDeeplyNestedConfig_WCON60_MenuConfig() throws Exception {
MockContextAwareConfig.registerAnnotationClasses(context, FooterConfig.class);

// create menu item
writeConfigurationCollection(context, contentPage.getPath(), FooterConfig.class.getName() + "/jcr:content/menu", ImmutableList.of(
writeConfigurationCollection(context, contentPage.getPath(), FooterConfig.class.getName() + "/jcr:content/menu", List.of(
ImmutableValueMap.of()));

context.request().setParameterMap(ImmutableValueMap.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import javax.servlet.http.HttpServletResponse;

import org.apache.sling.caconfig.management.ConfigurationCollectionData;
Expand All @@ -47,10 +52,6 @@
import org.mockito.stubbing.Answer;
import org.skyscreamer.jsonassert.JSONAssert;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;

import io.wcm.caconfig.editor.DropdownOptionItem;
import io.wcm.caconfig.editor.DropdownOptionProvider;
import io.wcm.caconfig.editor.EditorProperties;
Expand Down Expand Up @@ -125,8 +126,8 @@ void testCollection() throws Exception {
ConfigurationData configDataNew = buildConfigData("new", 0);
ConfigurationCollectionData configCollectionData = mock(ConfigurationCollectionData.class);
when(configCollectionData.getConfigName()).thenReturn("name1");
when(configCollectionData.getItems()).thenReturn(ImmutableList.of(configData1, configData2));
when(configCollectionData.getProperties()).thenReturn(ImmutableMap.<String, Object>of("colProp1", true));
when(configCollectionData.getItems()).thenReturn(List.of(configData1, configData2));
when(configCollectionData.getProperties()).thenReturn(Map.<String, Object>of("colProp1", true));
when(configManager.getConfigurationCollection(context.currentResource(), "name1")).thenReturn(configCollectionData);
when(configManager.newCollectionItem(context.currentResource(), "name1")).thenReturn(configDataNew);

Expand All @@ -147,7 +148,7 @@ void testCollection() throws Exception {
void testNested() throws Exception {
ConfigurationData configData = mock(ConfigurationData.class);
when(configData.getConfigName()).thenReturn("nestedConfig");
when(configData.getPropertyNames()).thenReturn(ImmutableSet.of("param1", "subConfig", "subConfigList"));
when(configData.getPropertyNames()).thenReturn(new TreeSet<>(Set.of("param1", "subConfig", "subConfigList")));

ValueInfo param1 = mock(ValueInfo.class);
when(param1.getName()).thenReturn("param1");
Expand All @@ -160,7 +161,7 @@ void testNested() throws Exception {
when(subConfig.getPropertyMetadata()).thenReturn(new PropertyMetadata<>("subConfig", ConfigurationMetadata.class)
.label("subConfig-label")
.description("subConfig-desc")
.configurationMetadata(new ConfigurationMetadata("subConfig", ImmutableList.<PropertyMetadata<?>>of(), false)));
.configurationMetadata(new ConfigurationMetadata("subConfig", List.<PropertyMetadata<?>>of(), false)));
when(configData.getValueInfo("subConfig")).thenReturn(subConfig);

ValueInfo subConfigList = mock(ValueInfo.class);
Expand All @@ -173,7 +174,7 @@ void testNested() throws Exception {
when(subConfigList.getPropertyMetadata()).thenReturn(new PropertyMetadata<>("subConfigList", ConfigurationMetadata[].class)
.label("subConfigList-label")
.description("subConfigList-desc")
.configurationMetadata(new ConfigurationMetadata("subConfigList", ImmutableList.<PropertyMetadata<?>>of(), true)));
.configurationMetadata(new ConfigurationMetadata("subConfigList", List.<PropertyMetadata<?>>of(), true)));
when(configData.getValueInfo("subConfigList")).thenReturn(subConfigList);


Expand Down Expand Up @@ -289,7 +290,7 @@ private ConfigurationData buildConfigData(String configName, int index) {
if (index > 0) {
when(configData.getCollectionItemName()).thenReturn("item" + index);
}
when(configData.getPropertyNames()).thenReturn(ImmutableSet.of("param1", "param2", "param3"));
when(configData.getPropertyNames()).thenReturn(new TreeSet<>(Set.of("param1", "param2", "param3")));

ValueInfo param1 = buildValueInfo("param1", new String[] {
"v1"
Expand All @@ -311,12 +312,12 @@ private ConfigurationData buildConfigData(String configName, int index) {
private ConfigurationData buildConfigDataWithDropdown(String configName) {
ConfigurationData configData = mock(ConfigurationData.class);
when(configData.getConfigName()).thenReturn(configName);
when(configData.getPropertyNames()).thenReturn(ImmutableSet.of("param1", "param2"));
when(configData.getPropertyNames()).thenReturn(new TreeSet<>(Set.of("param1", "param2")));

ValueInfo param1 = buildValueInfo("param1", "option1", "option1", null);
when(param1.getPropertyMetadata()).thenReturn(
new PropertyMetadata<>("param1", String.class)
.properties(ImmutableMap.of(
.properties(Map.of(
EditorProperties.PROPERTY_WIDGET_TYPE, EditorProperties.WIDGET_TYPE_DROPDOWN,
EditorProperties.PROPERTY_DROPDOWN_OPTIONS, "["
+ "{'value':'option1','description':'First option'},"
Expand All @@ -328,7 +329,7 @@ private ConfigurationData buildConfigDataWithDropdown(String configName) {
ValueInfo param2 = buildValueInfo("param2", 5, 5, 0);
when(param2.getPropertyMetadata()).thenReturn(
new PropertyMetadata<>("param2", 0)
.properties(ImmutableMap.of(
.properties(Map.of(
EditorProperties.PROPERTY_WIDGET_TYPE, EditorProperties.WIDGET_TYPE_DROPDOWN,
EditorProperties.PROPERTY_DROPDOWN_OPTIONS, "["
+ "{'value':1,'description':'Number One'},"
Expand All @@ -343,12 +344,12 @@ private ConfigurationData buildConfigDataWithDropdown(String configName) {
private ConfigurationData buildConfigDataWithDropdownDynamic(String configName) {
ConfigurationData configData = mock(ConfigurationData.class);
when(configData.getConfigName()).thenReturn(configName);
when(configData.getPropertyNames()).thenReturn(ImmutableSet.of("param1"));
when(configData.getPropertyNames()).thenReturn(Set.of("param1"));

ValueInfo param1 = buildValueInfo("param1", "option1", "option1", null);
when(param1.getPropertyMetadata()).thenReturn(
new PropertyMetadata<>("param1", String.class)
.properties(ImmutableMap.of(
.properties(Map.of(
EditorProperties.PROPERTY_WIDGET_TYPE, EditorProperties.WIDGET_TYPE_DROPDOWN,
EditorProperties.PROPERTY_DROPDOWN_OPTIONS_PROVIDER, "provider1")));
when(configData.getValueInfo("param1")).thenReturn(param1);
Expand All @@ -357,7 +358,7 @@ private ConfigurationData buildConfigDataWithDropdownDynamic(String configName)
context.registerService(DropdownOptionProvider.class, provider,
DropdownOptionProvider.PROPERTY_SELECTOR, "provider1");

when(provider.getDropdownOptions(context.currentResource())).thenReturn(ImmutableList.of(
when(provider.getDropdownOptions(context.currentResource())).thenReturn(List.of(
new DropdownOptionItem("option1", "First option"),
new DropdownOptionItem("option2", "Second option"),
new DropdownOptionItem("option3", "Third option")));
Expand All @@ -369,12 +370,12 @@ private ConfigurationData buildConfigDataWithDropdownDynamic(String configName)
private ConfigurationData buildConfigDataWithPathBrowserRootPathDynamic(String configName) {
ConfigurationData configData = mock(ConfigurationData.class);
when(configData.getConfigName()).thenReturn(configName);
when(configData.getPropertyNames()).thenReturn(ImmutableSet.of("param1"));
when(configData.getPropertyNames()).thenReturn(Set.of("param1"));

ValueInfo param1 = buildValueInfo("param1", "option1", "option1", null);
when(param1.getPropertyMetadata()).thenReturn(
new PropertyMetadata<>("param1", String.class)
.properties(ImmutableMap.of(
.properties(Map.of(
EditorProperties.PROPERTY_WIDGET_TYPE, EditorProperties.WIDGET_TYPE_PATHBROWSER,
EditorProperties.PROPERTY_PATHBROWSER_ROOT_PATH_PROVIDER, "provider1")));
when(configData.getValueInfo("param1")).thenReturn(param1);
Expand All @@ -391,12 +392,12 @@ private ConfigurationData buildConfigDataWithPathBrowserRootPathDynamic(String c
private ConfigurationData buildConfigDataWithTagBrowserRootPathDynamic(String configName) {
ConfigurationData configData = mock(ConfigurationData.class);
when(configData.getConfigName()).thenReturn(configName);
when(configData.getPropertyNames()).thenReturn(ImmutableSet.of("param1"));
when(configData.getPropertyNames()).thenReturn(Set.of("param1"));

ValueInfo param1 = buildValueInfo("param1", "option1", "option1", null);
when(param1.getPropertyMetadata()).thenReturn(
new PropertyMetadata<>("param1", String.class)
.properties(ImmutableMap.of(
.properties(Map.of(
EditorProperties.PROPERTY_WIDGET_TYPE, EditorProperties.WIDGET_TYPE_TAGBROWSER,
EditorProperties.PROPERTY_TAGBROWSER_ROOT_PATH_PROVIDER, "provider1")));
when(configData.getValueInfo("param1")).thenReturn(param1);
Expand All @@ -422,7 +423,7 @@ private <T> ValueInfo<T> buildValueInfo(String name, T value, T effectiveValue,
when(valueInfo.getPropertyMetadata()).thenReturn(new PropertyMetadata<>(name, defaultValue)
.label(name + "-label")
.description(name + "-desc")
.properties(ImmutableMap.of("custom", name + "-custom")));
.properties(Map.of("custom", name + "-custom")));
}
return valueInfo;
}
Expand Down
Loading

0 comments on commit b055eef

Please sign in to comment.