From f0508af76b5c115861a00f0b0d58bd18710e7f2f Mon Sep 17 00:00:00 2001 From: david g Date: Fri, 31 Jan 2025 12:27:59 -0500 Subject: [PATCH 1/3] Fixed issues (that have fixes) identified by AEM Analyse 1.6.6 --- all/pom.xml | 2 +- .../components/actions/download/Download.java | 3 +- .../predicates/impl/PagePredicateImpl.java | 83 +++++++++------- .../properties/impl/ContentTypeImpl.java | 65 ++++++------ .../impl/AssetRenditionDispatchersImpl.java | 3 +- .../PropertyValuesPredicateEvaluator.java | 3 +- .../util/impl/EmailServiceImpl.java | 1 + .../impl/AssetKitCreatorWorkflowProcess.java | 6 +- .../MetadataSchemaPropertiesImplTest.java | 27 +++-- .../AssetRenditionsDataSourceTest.java | 99 ++++++++++--------- .../AssetRenditionsDownloadServletTest.java | 24 ++--- .../impl/AssetRenditionsZipperImplTest.java | 25 +++-- .../impl/AssetRenditionServletTest.java | 33 ++++--- ...alRedirectRenditionDispatcherImplTest.java | 71 ++++++------- ...alRedirectRenditionDispatcherImplTest.java | 58 +++++------ .../StaticRenditionDispatcherImplTest.java | 51 +++++----- .../search/impl/FastPropertiesImplTest.java | 37 +++---- .../PropertyValuesPredicateEvaluatorTest.java | 8 +- .../assetshare/testing/RequireAemMock.java | 15 +-- pom.xml | 2 +- ....factory.config~asset-share-commons.config | 1 - ....factory.config~asset-share-commons.config | 1 - ....factory.config~asset-share-commons.config | 1 - .../content/jcr_root/content/.content.xml | 5 - .../content/jcr_root/content/dam/.content.xml | 4 - 25 files changed, 321 insertions(+), 307 deletions(-) delete mode 100644 ui.content.sample/src/main/content/jcr_root/content/.content.xml delete mode 100644 ui.content.sample/src/main/content/jcr_root/content/dam/.content.xml diff --git a/all/pom.xml b/all/pom.xml index 5878738b3..93e515a4f 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -187,7 +187,7 @@ com.adobe.aem aemanalyser-maven-plugin - 1.5.8 + 1.6.6 aem-analyser diff --git a/core/src/main/java/com/adobe/aem/commons/assetshare/components/actions/download/Download.java b/core/src/main/java/com/adobe/aem/commons/assetshare/components/actions/download/Download.java index 4ed83943f..67e33fc43 100644 --- a/core/src/main/java/com/adobe/aem/commons/assetshare/components/actions/download/Download.java +++ b/core/src/main/java/com/adobe/aem/commons/assetshare/components/actions/download/Download.java @@ -22,7 +22,6 @@ import com.adobe.aem.commons.assetshare.content.AssetModel; import com.adobe.cq.wcm.core.components.models.form.OptionItem; import com.adobe.cq.wcm.core.components.models.form.Options; -import com.google.common.collect.ImmutableList; import org.osgi.annotation.versioning.ConsumerType; import java.util.ArrayList; @@ -98,7 +97,7 @@ public String getTitle() { } public List getItems() { - return ImmutableList.copyOf(options); + return Collections.unmodifiableList(options); } } } diff --git a/core/src/main/java/com/adobe/aem/commons/assetshare/components/predicates/impl/PagePredicateImpl.java b/core/src/main/java/com/adobe/aem/commons/assetshare/components/predicates/impl/PagePredicateImpl.java index 60cfe5ccb..2db158fa4 100644 --- a/core/src/main/java/com/adobe/aem/commons/assetshare/components/predicates/impl/PagePredicateImpl.java +++ b/core/src/main/java/com/adobe/aem/commons/assetshare/components/predicates/impl/PagePredicateImpl.java @@ -36,8 +36,6 @@ import com.day.cq.search.eval.PathPredicateEvaluator; import com.day.cq.search.eval.TypePredicateEvaluator; import com.day.cq.wcm.api.Page; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.sling.api.SlingHttpServletRequest; @@ -53,11 +51,7 @@ import javax.annotation.Nonnull; import javax.annotation.PostConstruct; import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Model( adaptables = {SlingHttpServletRequest.class}, @@ -161,7 +155,7 @@ public int getOffset() { } } - return offset; + return offset; } public String getGuessTotal() { @@ -248,7 +242,6 @@ public PredicateGroup getPredicateGroup(ParamTypes... excludeParamTypes) { addFacetStrategyAsParameterPredicate(parameterGroup); } - root.add(parameterGroup); return root; @@ -256,39 +249,60 @@ public PredicateGroup getPredicateGroup(ParamTypes... excludeParamTypes) { private void addIndexTagAsParameterPredicate(final PredicateGroup parameterGroup) { String indexTag = getIndexTag(); - if (StringUtils.isBlank(indexTag)) { return; } + if (StringUtils.isBlank(indexTag)) { + return; + } + + Map map = new HashMap() { + { + put(Predicate.PARAM_OPTIONS_INDEXTAG, indexTag); + } + }; - parameterGroup.addAll(PredicateConverter.createPredicates(ImmutableMap.builder(). - put(Predicate.PARAM_OPTIONS_INDEXTAG, indexTag). - build())); + parameterGroup.addAll(PredicateConverter.createPredicates(Collections.unmodifiableMap(map))); } private void addFacetStrategyAsParameterPredicate(final PredicateGroup parameterGroup) { String facetStrategy = getFacetStrategy(); - if (StringUtils.isBlank(facetStrategy)) { return; } + if (StringUtils.isBlank(facetStrategy)) { + return; + } + + Map map = new HashMap() { + { + put(Predicate.PARAM_FACET_STRATEGY, facetStrategy); + } + }; - parameterGroup.addAll(PredicateConverter.createPredicates(ImmutableMap.builder(). - put(Predicate.PARAM_FACET_STRATEGY, facetStrategy). - build())); + parameterGroup.addAll(PredicateConverter.createPredicates(Collections.unmodifiableMap(map))); } private void addGuessTotalAsParameterPredicate(final PredicateGroup parameterGroup) { - parameterGroup.addAll(PredicateConverter.createPredicates(ImmutableMap.builder(). - put(Predicate.PARAM_GUESS_TOTAL, getGuessTotal()). - build())); + Map map = new HashMap() { + { + put(Predicate.PARAM_GUESS_TOTAL, getGuessTotal()); + + } + }; + + parameterGroup.addAll(PredicateConverter.createPredicates(Collections.unmodifiableMap(map))); } private void addOffsetAsParameterPredicate(final PredicateGroup parameterGroup) { - parameterGroup.addAll(PredicateConverter.createPredicates(ImmutableMap.builder(). - put(Predicate.PARAM_OFFSET, String.valueOf(getOffset())). - build())); + Map map = new HashMap() {{ + put(Predicate.PARAM_OFFSET, String.valueOf(getOffset())); + }}; + + parameterGroup.addAll(PredicateConverter.createPredicates(Collections.unmodifiableMap(map))); } private void addLimitAsParameterPredicate(final PredicateGroup parameterGroup) { - parameterGroup.addAll(PredicateConverter.createPredicates(ImmutableMap.builder(). - put(Predicate.PARAM_LIMIT, String.valueOf(getLimit())). - build())); + Map map = new HashMap() {{ + put(Predicate.PARAM_LIMIT, String.valueOf(getLimit())); + }}; + + parameterGroup.addAll(PredicateConverter.createPredicates(Collections.unmodifiableMap(map))); } private void addSearchPredicateAsPredicateGroups(final PredicateGroup root) { @@ -340,21 +354,22 @@ private void addPathAsPredicateGroup(final PredicateGroup root) { } private void addTypeAsPredicate(final PredicateGroup root) { - root.addAll(PredicateConverter.createPredicates(ImmutableMap.builder(). - put(TypePredicateEvaluator.TYPE, DamConstants.NT_DAM_ASSET). - build())); + Map map = new HashMap<>(); + map.put(TypePredicateEvaluator.TYPE, DamConstants.NT_DAM_ASSET); + + root.addAll(PredicateConverter.createPredicates(Collections.unmodifiableMap(map))); } private void addOrderByAsPredicate(final PredicateGroup root) { - Builder orderPredicateBuilder = ImmutableMap.builder(). - put(Predicate.ORDER_BY, searchConfig.getOrderBy()). - put(Predicate.ORDER_BY + "." + Predicate.PARAM_SORT, searchConfig.getOrderBySort()); + Map map = new HashMap<>(); + map.put(Predicate.ORDER_BY, searchConfig.getOrderBy()); + map.put(Predicate.ORDER_BY + "." + Predicate.PARAM_SORT, searchConfig.getOrderBySort()); if (!isOrderByCase()) { - orderPredicateBuilder.put(Predicate.ORDER_BY + "." + Predicate.PARAM_CASE, Predicate.IGNORE_CASE); + map.put(Predicate.ORDER_BY + "." + Predicate.PARAM_CASE, Predicate.IGNORE_CASE); } - root.addAll(PredicateConverter.createPredicates(orderPredicateBuilder.build())); + root.addAll(PredicateConverter.createPredicates(Collections.unmodifiableMap(map))); } private List getSearchPredicates() { diff --git a/core/src/main/java/com/adobe/aem/commons/assetshare/content/properties/impl/ContentTypeImpl.java b/core/src/main/java/com/adobe/aem/commons/assetshare/content/properties/impl/ContentTypeImpl.java index fc5918e9f..ef8a7fa91 100644 --- a/core/src/main/java/com/adobe/aem/commons/assetshare/content/properties/impl/ContentTypeImpl.java +++ b/core/src/main/java/com/adobe/aem/commons/assetshare/content/properties/impl/ContentTypeImpl.java @@ -22,7 +22,7 @@ import com.adobe.aem.commons.assetshare.content.properties.AbstractComputedProperty; import com.adobe.aem.commons.assetshare.content.properties.ComputedProperty; import com.day.cq.dam.api.Asset; -import com.google.common.collect.ImmutableMap; + import org.apache.commons.lang3.StringUtils; import org.osgi.framework.Constants; import org.osgi.service.component.annotations.Activate; @@ -31,6 +31,8 @@ import org.osgi.service.metatype.annotations.Designate; import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; import static com.adobe.aem.commons.assetshare.content.properties.ComputedProperty.DEFAULT_ASC_COMPUTED_PROPERTY_SERVICE_RANKING; @@ -64,39 +66,38 @@ public String[] getTypes() { // Full mime type to label map - private static final Map mimeTypeToLabelMap = ImmutableMap.builder() - .put("image/vnd.adobe.photoshop", "Photoshop") - .put("application/msword", "Word Doc") - .put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word Doc") - .put("application/vnd.ms-excel", "Excel") - .put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel") - .put("application/vnd.ms-powerpoint", "PowerPoint") - .put("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint") - .put("application/pdf", "PDF") - .put("application/xml", "XML") - .put("application/zip", "Zip") - .put("application/json", "JSON") - .put("application/vnd.adobe.illustrator", "Illustrator") - .put("application/vnd.adobe.indesign", "InDesign") - .put("application/vnd.adobe.indesignml", "InDesign") - .put("application/vnd.adobe.indesignx", "InDesign") - .put("application/vnd.adobe.aftereffects", "After Effects") - .put("application/vnd.adobe.premiere", "Premiere") - .put("application/vnd.adobe.xd", "XD") - .put("text/html", "HTML") - .put("text/csv", "CSV") - .build(); - + private static final Map mimeTypeToLabelMap = Collections.unmodifiableMap(new HashMap() {{ + put("image/vnd.adobe.photoshop", "Photoshop"); + put("application/msword", "Word Doc"); + put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word Doc"); + put("application/vnd.ms-excel", "Excel"); + put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel"); + put("application/vnd.ms-powerpoint", "PowerPoint"); + put("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint"); + put("application/pdf", "PDF"); + put("application/xml", "XML"); + put("application/zip", "Zip"); + put("application/json", "JSON"); + put("application/vnd.adobe.illustrator", "Illustrator"); + put("application/vnd.adobe.indesign", "InDesign"); + put("application/vnd.adobe.indesignml", "InDesign"); + put("application/vnd.adobe.indesignx", "InDesign"); + put("application/vnd.adobe.aftereffects", "After Effects"); + put("application/vnd.adobe.premiere", "Premiere"); + put("application/vnd.adobe.xd", "XD"); + put("text/html", "HTML"); + put("text/csv", "CSV"); + }}); // Fallback mime type prefix to label map - private static final Map mimeTypePrefixToLabelMap = ImmutableMap.builder() - .put("image", "Image") - .put("video", "Video") - .put("audio", "Audio") - .put("font", "Font") - .put("model", "3D") - .put("text", "Text") - .build(); + private static final Map mimeTypePrefixToLabelMap = Collections.unmodifiableMap(new HashMap() {{ + put("image", "Image"); + put("video", "Video"); + put("audio", "Audio"); + put("font", "Font"); + put("model", "3D"); + put("text", "Text"); + }}); @Override public String get(Asset asset) { diff --git a/core/src/main/java/com/adobe/aem/commons/assetshare/content/renditions/impl/AssetRenditionDispatchersImpl.java b/core/src/main/java/com/adobe/aem/commons/assetshare/content/renditions/impl/AssetRenditionDispatchersImpl.java index bd6302c50..cb108c132 100644 --- a/core/src/main/java/com/adobe/aem/commons/assetshare/content/renditions/impl/AssetRenditionDispatchersImpl.java +++ b/core/src/main/java/com/adobe/aem/commons/assetshare/content/renditions/impl/AssetRenditionDispatchersImpl.java @@ -21,7 +21,6 @@ import com.adobe.aem.commons.assetshare.content.renditions.AssetRenditionDispatcher; import com.adobe.aem.commons.assetshare.content.renditions.AssetRenditionDispatchers; -import com.google.common.collect.ImmutableList; import org.apache.sling.commons.osgi.Order; import org.apache.sling.commons.osgi.RankedServices; import org.osgi.service.component.annotations.Component; @@ -74,7 +73,7 @@ public List getAssetRenditionDispatchers() { if (assetRenditionDispatchers == null || assetRenditionDispatchers.getList() == null) { return Collections.EMPTY_LIST; } else { - return ImmutableList.copyOf(assetRenditionDispatchers.getList()); + return Collections.unmodifiableList((assetRenditionDispatchers.getList())); } } diff --git a/core/src/main/java/com/adobe/aem/commons/assetshare/search/impl/predicateevaluators/PropertyValuesPredicateEvaluator.java b/core/src/main/java/com/adobe/aem/commons/assetshare/search/impl/predicateevaluators/PropertyValuesPredicateEvaluator.java index 9dcc802cc..420c6d25d 100644 --- a/core/src/main/java/com/adobe/aem/commons/assetshare/search/impl/predicateevaluators/PropertyValuesPredicateEvaluator.java +++ b/core/src/main/java/com/adobe/aem/commons/assetshare/search/impl/predicateevaluators/PropertyValuesPredicateEvaluator.java @@ -25,7 +25,6 @@ import com.day.cq.search.eval.JcrPropertyPredicateEvaluator; import com.day.cq.search.eval.PredicateEvaluator; import com.day.cq.search.facets.FacetExtractor; -import com.google.common.collect.ImmutableList; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.osgi.service.component.annotations.Activate; @@ -213,7 +212,7 @@ public FacetExtractor getFacetExtractor(Predicate predicate, EvaluationContext e protected List getValues(final String data, final List delimiters) { if (delimiters.size() == 0) { - return ImmutableList.builder().add(data).build(); + Collections.unmodifiableList(Arrays.asList(data)); } final String regex = delimiters.stream() diff --git a/core/src/main/java/com/adobe/aem/commons/assetshare/util/impl/EmailServiceImpl.java b/core/src/main/java/com/adobe/aem/commons/assetshare/util/impl/EmailServiceImpl.java index 65d36ea8e..e7ecc95a8 100644 --- a/core/src/main/java/com/adobe/aem/commons/assetshare/util/impl/EmailServiceImpl.java +++ b/core/src/main/java/com/adobe/aem/commons/assetshare/util/impl/EmailServiceImpl.java @@ -235,6 +235,7 @@ private Email getEmail(final MailTemplate mailTemplate, final Class mailType, final Map params) throws EmailException, MessagingException, IOException { + // We cannot get rid of StrLookup even tho its deprecated, because the AEM MailTemplate.getEmail(...) requires a parameter of this type final Email email = mailTemplate.getEmail(StrLookup.mapLookup(params), mailType); if (params.containsKey(EmailService.SENDER_EMAIL_ADDRESS) diff --git a/core/src/main/java/com/adobe/aem/commons/assetshare/workflow/assetkit/impl/AssetKitCreatorWorkflowProcess.java b/core/src/main/java/com/adobe/aem/commons/assetshare/workflow/assetkit/impl/AssetKitCreatorWorkflowProcess.java index b0af25506..1e4f132fe 100644 --- a/core/src/main/java/com/adobe/aem/commons/assetshare/workflow/assetkit/impl/AssetKitCreatorWorkflowProcess.java +++ b/core/src/main/java/com/adobe/aem/commons/assetshare/workflow/assetkit/impl/AssetKitCreatorWorkflowProcess.java @@ -28,11 +28,11 @@ import com.adobe.granite.workflow.exec.WorkflowProcess; import com.adobe.granite.workflow.metadata.MetaDataMap; import com.day.cq.commons.jcr.JcrUtil; +import com.day.cq.search.Predicate; import com.day.cq.search.QueryBuilder; import com.day.cq.wcm.api.Page; import com.day.cq.wcm.api.PageManager; import com.day.cq.wcm.api.WCMException; -import com.google.common.collect.ImmutableMap; import org.apache.commons.lang3.StringUtils; import org.apache.sling.api.resource.ModifiableValueMap; import org.apache.sling.api.resource.PersistenceException; @@ -161,7 +161,9 @@ private Resource getOrCreateTrackingResource(Resource resource) throws WorkflowE resource = resource.getChild(JCR_CONTENT); if (resource.getChild("metadata") == null) { try { - resource = resource.getResourceResolver().create(resource, "metadata", ImmutableMap.of(JCR_PRIMARYTYPE, NT_UNSTRUCTURED)); + resource = resource.getResourceResolver().create(resource, "metadata", Collections.unmodifiableMap(new HashMap() {{ + put(JCR_PRIMARYTYPE, NT_UNSTRUCTURED); + }})); } catch (PersistenceException e) { throw new WorkflowException(String.format("Could not create missing metadata node for asset folder [ {} ].", resource.getPath()), e); } diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/content/impl/MetadataSchemaPropertiesImplTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/content/impl/MetadataSchemaPropertiesImplTest.java index 5a7679fc8..50ec57e6e 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/content/impl/MetadataSchemaPropertiesImplTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/content/impl/MetadataSchemaPropertiesImplTest.java @@ -20,16 +20,13 @@ package com.adobe.aem.commons.assetshare.content.impl; import com.adobe.aem.commons.assetshare.content.MetadataProperties; -import com.google.common.collect.ImmutableMap; + import io.wcm.testing.mock.aem.junit.AemContext; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import static org.junit.Assert.assertEquals; @@ -45,10 +42,9 @@ public void setUp() throws Exception { @Test public void collectExtraMetadataProperties() { ctx.registerInjectActivateService(new MetadataSchemaPropertiesImpl(), - ImmutableMap.builder(). - put("extra.metadata.properties", new String[]{ "jcr:content/foo=My Foo", "jcr:content/metadata/bar=My Bar", "./jcr:content/foo=My Foo 2" }). - build()); - + Collections.unmodifiableMap(new HashMap() {{ + put("extra.metadata.properties", new String[]{"jcr:content/foo=My Foo", "jcr:content/metadata/bar=My Bar", "./jcr:content/foo=My Foo 2"}); + }})); MetadataSchemaPropertiesImpl metadataSchemaProperties = (MetadataSchemaPropertiesImpl) ctx.getService(MetadataProperties.class); Map> collectedMetadata = new HashMap<>(); @@ -67,16 +63,15 @@ public void collectExtraMetadataProperties() { @Test public void removeMetadataProperties() { ctx.registerInjectActivateService(new MetadataSchemaPropertiesImpl(), - ImmutableMap.builder(). - put("blacklisted.metadata.properties", new String[]{ "jcr:content/foo" }). - build()); - + Collections.unmodifiableMap(new HashMap() {{ + put("blacklisted.metadata.properties", new String[]{"jcr:content/foo"}); + }})); MetadataSchemaPropertiesImpl metadataSchemaProperties = (MetadataSchemaPropertiesImpl) ctx.getService(MetadataProperties.class); Map> collectedMetadata = new HashMap<>(); - collectedMetadata.put("jcr:content/foo", Arrays.asList("Blacklisted")); - collectedMetadata.put("./jcr:content/foo", Arrays.asList("Blacklisted Too")); - collectedMetadata.put("./jcr:content/metadata/bar", Arrays.asList("Not blacklisted")); + collectedMetadata.put("jcr:content/foo", Collections.singletonList("Blacklisted")); + collectedMetadata.put("./jcr:content/foo", Collections.singletonList("Blacklisted Too")); + collectedMetadata.put("./jcr:content/metadata/bar", Collections.singletonList("Not blacklisted")); collectedMetadata = metadataSchemaProperties.removeBlacklistedMetadataProperties(collectedMetadata); diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/content/impl/datasources/AssetRenditionsDataSourceTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/content/impl/datasources/AssetRenditionsDataSourceTest.java index b45e0b40e..37e47bc4e 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/content/impl/datasources/AssetRenditionsDataSourceTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/content/impl/datasources/AssetRenditionsDataSourceTest.java @@ -30,7 +30,7 @@ import com.adobe.aem.commons.assetshare.util.impl.ExpressionEvaluatorImpl; import com.adobe.aem.commons.assetshare.util.impl.RequireAemImpl; import com.adobe.granite.ui.components.ds.DataSource; -import com.google.common.collect.ImmutableMap; + import io.wcm.testing.mock.aem.junit.AemContext; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ValueMap; @@ -46,9 +46,7 @@ import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.*; import static org.junit.Assert.assertArrayEquals; @@ -74,27 +72,29 @@ public void setUp() throws Exception { ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put(Constants.SERVICE_RANKING, 0). - put("label", "One AssetRenditionDispatcher"). - put("name", "one"). - put ("types", new String[]{"image", "video"}). - put("rendition.mappings", new String[]{ - "a=value", - "b=value",}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put(Constants.SERVICE_RANKING, 0); + put("label", "One AssetRenditionDispatcher"); + put("name", "one"); + put("types", new String[]{"image", "video"}); + put("rendition.mappings", new String[]{ + "a=value", + "b=value" + }); + }})); ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put(Constants.SERVICE_RANKING, 0). - put("label", "Two AssetRenditionDispatcher"). - put("name", "two"). - put ("types", new String[]{"video"}). - put("rendition.mappings", new String[]{ - "c=value", - "d=value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put(Constants.SERVICE_RANKING, 0); + put("label", "Two AssetRenditionDispatcher"); + put("name", "two"); + put("types", new String[]{"video"}); + put("rendition.mappings", new String[]{ + "c=value", + "d=value" + }); + }})); } @Test @@ -205,14 +205,15 @@ public void doGet_ServiceRanking() throws ServletException, IOException { ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put(Constants.SERVICE_RANKING, 1000). - put("label", "Three AssetRenditionDispatcher"). - put("name", "three"). - put("rendition.mappings", new String[]{ - "a=preferred value for a", - "c=preferred value for c"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put(Constants.SERVICE_RANKING, 1000); + put("label", "Three AssetRenditionDispatcher"); + put("name", "three"); + put("rendition.mappings", new String[]{ + "a=preferred value for a", + "c=preferred value for c" + }); + }})); servlet.service(ctx.request(), ctx.response()); @@ -234,15 +235,16 @@ public void doGet_WithHiddenAssetRenditionDispatcher() throws ServletException, ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put(Constants.SERVICE_RANKING, 1000). - put("label", "Three AssetRenditionDispatcher"). - put("name", "three"). - put ("hidden", true). - put("rendition.mappings", new String[]{ - "e=value", - "f=value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put(Constants.SERVICE_RANKING, 1000); + put("label", "Three AssetRenditionDispatcher"); + put("name", "three"); + put("hidden", true); + put("rendition.mappings", new String[]{ + "e=value", + "f=value" + }); + }})); servlet.service(ctx.request(), ctx.response()); @@ -263,15 +265,16 @@ public void doGet_WithAllowedAssetRenditionDispatcherTypes() throws ServletExcep ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put(Constants.SERVICE_RANKING, 1000). - put("label", "Three AssetRenditionDispatcher"). - put("name", "three"). - put ("types", new String[]{"image"}). - put("rendition.mappings", new String[]{ - "e=value", - "f=value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put(Constants.SERVICE_RANKING, 1000); + put("label", "Three AssetRenditionDispatcher"); + put("name", "three"); + put("types", new String[]{"image"}); + put("rendition.mappings", new String[]{ + "e=value", + "f=value" + }); + }})); servlet.service(ctx.request(), ctx.response()); diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/download/impl/AssetRenditionsDownloadServletTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/download/impl/AssetRenditionsDownloadServletTest.java index 774909e86..3ad44a902 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/download/impl/AssetRenditionsDownloadServletTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/download/impl/AssetRenditionsDownloadServletTest.java @@ -30,7 +30,6 @@ import com.adobe.aem.commons.assetshare.util.RequireAem; import com.adobe.aem.commons.assetshare.util.impl.ExpressionEvaluatorImpl; import com.adobe.aem.commons.assetshare.util.impl.ServletHelperImpl; -import com.google.common.collect.ImmutableMap; import io.wcm.testing.mock.aem.junit.AemContext; import org.apache.commons.io.IOUtils; import org.apache.http.osgi.services.HttpClientBuilderFactory; @@ -50,9 +49,10 @@ import org.osgi.framework.Constants; import javax.servlet.RequestDispatcher; -import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; @@ -107,13 +107,13 @@ public void setUp() { ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put(Constants.SERVICE_RANKING, 0). - put("label", "Test AssetRenditionDispatcher"). - put("name", "test"). - put ("types", new String[]{"image", "video"}). - put("rendition.mappings", new String[]{ "test=original" }). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put(Constants.SERVICE_RANKING, 0); + put("label", "Test AssetRenditionDispatcher"); + put("name", "test"); + put("types", new String[]{"image", "video"}); + put("rendition.mappings", new String[]{"test=original"}); + }})); RequireAemMock.setAem(ctx, RequireAem.Distribution.CLASSIC, RequireAem.ServiceType.PUBLISH); @@ -152,7 +152,7 @@ public void doPost() throws ServletException, IOException { servlet.service(ctx.request(), ctx.response()); assertEquals("application/zip", ctx.response().getContentType()); - assertEquals(334, ctx.response().getOutput().length); + assertEquals(334, ctx.response().getOutput().length); } @Test @@ -169,7 +169,7 @@ public void doPost_EmptyRenditionName() throws ServletException, IOException { servlet.service(ctx.request(), ctx.response()); assertEquals("application/zip", ctx.response().getContentType()); - assertEquals(253, ctx.response().getOutput().length); // Size of zip w/ default no content message + assertEquals(253, ctx.response().getOutput().length); // Size of zip w/ default no content message } @Test @@ -186,6 +186,6 @@ public void doPost_InvalidAssetPath() throws ServletException, IOException { servlet.service(ctx.request(), ctx.response()); assertEquals("application/zip", ctx.response().getContentType()); - assertEquals(253, ctx.response().getOutput().length); // Size of zip w/ default no content message + assertEquals(253, ctx.response().getOutput().length); // Size of zip w/ default no content message } } \ No newline at end of file diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/download/impl/AssetRenditionsZipperImplTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/download/impl/AssetRenditionsZipperImplTest.java index 4bfa646f1..9d75b8c0f 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/download/impl/AssetRenditionsZipperImplTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/download/impl/AssetRenditionsZipperImplTest.java @@ -9,7 +9,7 @@ import com.adobe.aem.commons.assetshare.content.renditions.impl.AssetRenditionsImpl; import com.adobe.aem.commons.assetshare.content.renditions.impl.dispatchers.StaticRenditionDispatcherImpl; import com.adobe.aem.commons.assetshare.testing.MockAssetModels; -import com.google.common.collect.ImmutableMap; + import io.wcm.testing.mock.aem.junit.AemContext; import org.apache.commons.io.IOUtils; import org.apache.http.osgi.services.HttpClientBuilderFactory; @@ -31,10 +31,7 @@ import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; +import java.util.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -77,13 +74,13 @@ public void setUp() throws Exception { ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put(Constants.SERVICE_RANKING, 0). - put("label", "Test AssetRenditionDispatcher"). - put("name", "test"). - put ("types", new String[]{"image", "video"}). - put("rendition.mappings", new String[]{ "test=original" }). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put(Constants.SERVICE_RANKING, 0); + put("label", "Test AssetRenditionDispatcher"); + put("name", "test"); + put("types", new String[]{"image", "video"}); + put("rendition.mappings", new String[]{"test=original"}); + }})); ctx.registerInjectActivateService(new AssetRenditionStreamerImpl()); @@ -120,7 +117,9 @@ public void getFileName_FromResource() { AssetRenditionsZipperImpl zipper = (AssetRenditionsZipperImpl) ctx.getService(AssetRenditionsDownloadOrchestrator.class); - assertEquals(expected, zipper.getFileName(new ValueMapDecorator(ImmutableMap.of("fileName", "My Assets")))); + assertEquals(expected, zipper.getFileName(new ValueMapDecorator(Collections.unmodifiableMap(new HashMap() {{ + put("fileName", "My Assets"); + }})))); } @Test diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/AssetRenditionServletTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/AssetRenditionServletTest.java index f24b74701..d6956f33a 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/AssetRenditionServletTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/AssetRenditionServletTest.java @@ -27,7 +27,7 @@ import com.adobe.aem.commons.assetshare.testing.MockAssetModels; import com.adobe.aem.commons.assetshare.util.ServletHelper; import com.adobe.aem.commons.assetshare.util.impl.ServletHelperImpl; -import com.google.common.collect.ImmutableMap; + import io.wcm.testing.mock.aem.junit.AemContext; import org.apache.commons.io.IOUtils; import org.apache.sling.api.SlingHttpServletRequest; @@ -49,6 +49,8 @@ import javax.servlet.Servlet; import javax.servlet.ServletException; import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; @@ -115,18 +117,20 @@ public void doGet() throws IOException, ServletException { ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "testing1=value doesnt matter"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "testing1=value doesnt matter" + }); + }})); ctx.registerInjectActivateService( assetRenditionDispatcher, - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "original=original", - "testing2=^cq5dam\\.web\\..*"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "original=original", + "testing2=^cq5dam\\.web\\..*" + }); + }})); Servlet servlet = ctx.registerInjectActivateService(new AssetRenditionServlet()); @@ -146,10 +150,11 @@ public void doGet_InvalidParameters() throws IOException, ServletException { ctx.registerInjectActivateService( assetRenditionDispatcher, - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "testing=value doesnt matter"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "testing=value doesnt matter" + }); + }})); Servlet servlet = ctx.registerInjectActivateService(new AssetRenditionServlet()); diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/ExternalRedirectRenditionDispatcherImplTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/ExternalRedirectRenditionDispatcherImplTest.java index d630be083..a45715244 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/ExternalRedirectRenditionDispatcherImplTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/ExternalRedirectRenditionDispatcherImplTest.java @@ -27,7 +27,7 @@ import com.adobe.aem.commons.assetshare.content.renditions.impl.AssetRenditionsImpl; import com.adobe.aem.commons.assetshare.util.ExpressionEvaluator; import com.adobe.aem.commons.assetshare.util.impl.ExpressionEvaluatorImpl; -import com.google.common.collect.ImmutableMap; + import io.wcm.testing.mock.aem.junit.AemContext; import org.apache.sling.commons.mime.MimeTypeService; import org.junit.Before; @@ -39,9 +39,7 @@ import javax.servlet.ServletException; import java.io.IOException; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -101,19 +99,20 @@ public void getName() { @Test public void getOptions() { - final Map expected = ImmutableMap.builder(). - put("Foo", "foo"). - put("Foo bar", "foo_bar"). - put("Foo-bar", "foo-bar"). - build(); + final Map expected = Collections.unmodifiableMap(new HashMap() {{ + put("Foo", "foo"); + put("Foo bar", "foo_bar"); + put("Foo-bar", "foo-bar"); + }}); ctx.registerInjectActivateService(new ExternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "foo=foo value", - "foo_bar=foo_bar value", - "foo-bar=foo-bar value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "foo=foo value", + "foo_bar=foo_bar value", + "foo-bar=foo-bar value" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); final Map actual = assetRenditionDispatcher.getOptions(); @@ -127,11 +126,12 @@ public void getRenditionNames() { expected.add("test.ing-rendition"); ctx.registerInjectActivateService(new ExternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "foo=foo value", - "test.ing-rendition=test-rendition value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "foo=foo value", + "test.ing-rendition=test-rendition value" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); final Set actual = assetRenditionDispatcher.getRenditionNames(); @@ -143,10 +143,11 @@ public void getRenditionNames() { @Test public void dispatch() throws IOException, ServletException { ctx.registerInjectActivateService(new ExternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "testing=${dm.domain}is/image/${dm.file}?$greyscale$"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "testing=${dm.domain}is/image/${dm.file}?$greyscale$" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); @@ -162,11 +163,12 @@ public void dispatch() throws IOException, ServletException { @Test public void dispatch_WithSpacesInPath() throws IOException, ServletException { ctx.registerInjectActivateService(new ExternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "testing=${asset.path}.test.500.500.${asset.extension}"}). - put("redirect", 302). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "testing=${asset.path}.test.500.500.${asset.extension}" + }); + put("redirect", 302); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); @@ -184,11 +186,12 @@ public void dispatch_WithSpacesInPath() throws IOException, ServletException { @Test public void dispatch_WithHostAndSpacesInPath() throws IOException, ServletException { ctx.registerInjectActivateService(new ExternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "testing=https://test.com${asset.path}.test.500.500.${asset.extension}"}). - put("redirect", 302). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "testing=https://test.com${asset.path}.test.500.500.${asset.extension}" + }); + put("redirect", 302); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/InternalRedirectRenditionDispatcherImplTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/InternalRedirectRenditionDispatcherImplTest.java index 2ef1a4582..2a0d2623c 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/InternalRedirectRenditionDispatcherImplTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/InternalRedirectRenditionDispatcherImplTest.java @@ -30,7 +30,7 @@ import com.adobe.aem.commons.assetshare.util.RequireAem; import com.adobe.aem.commons.assetshare.util.impl.ExpressionEvaluatorImpl; import com.adobe.aem.commons.assetshare.util.impl.requests.ExtensionOverrideRequestWrapper; -import com.google.common.collect.ImmutableMap; + import io.wcm.testing.mock.aem.junit.AemContext; import org.apache.sling.api.request.RequestDispatcherOptions; import org.apache.sling.api.resource.Resource; @@ -47,9 +47,7 @@ import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import java.io.IOException; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -128,19 +126,20 @@ public void getName() { @Test public void getOptions() { - final Map expected = ImmutableMap.builder(). - put("Foo", "foo"). - put("Foo bar", "foo_bar"). - put("Foo-bar", "foo-bar"). - build(); + final Map expected = Collections.unmodifiableMap(new HashMap() {{ + put("Foo", "foo"); + put("Foo bar", "foo_bar"); + put("Foo-bar", "foo-bar"); + }}); ctx.registerInjectActivateService(new InternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "foo=foo value", - "foo_bar=foo_bar value", - "foo-bar=foo-bar value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "foo=foo value", + "foo_bar=foo_bar value", + "foo-bar=foo-bar value" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); final Map actual = assetRenditionDispatcher.getOptions(); @@ -154,11 +153,12 @@ public void getRenditionNames() { expected.add("test.ing-rendition"); ctx.registerInjectActivateService(new InternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "foo=foo value", - "test.ing-rendition=test-rendition value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "foo=foo value", + "test.ing-rendition=test-rendition value" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); final Set actual = assetRenditionDispatcher.getRenditionNames(); @@ -170,10 +170,11 @@ public void getRenditionNames() { @Test public void dispatch() throws IOException, ServletException { ctx.registerInjectActivateService(new InternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "testing=${asset.path}.test.500.500.${asset.extension}"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "testing=${asset.path}.test.500.500.${asset.extension}" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); @@ -196,10 +197,11 @@ public void dispatch() throws IOException, ServletException { @Test public void dispatch_WithSpacesInPath() throws IOException, ServletException { ctx.registerInjectActivateService(new InternalRedirectRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "testing=${asset.path}.test.500.500.${asset.extension}"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "testing=${asset.path}.test.500.500.${asset.extension}" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/StaticRenditionDispatcherImplTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/StaticRenditionDispatcherImplTest.java index a78935b7d..183d80510 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/StaticRenditionDispatcherImplTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/content/renditions/impl/dispatchers/StaticRenditionDispatcherImplTest.java @@ -25,7 +25,7 @@ import com.adobe.aem.commons.assetshare.content.renditions.AssetRenditionDispatcher; import com.adobe.aem.commons.assetshare.content.renditions.AssetRenditions; import com.adobe.aem.commons.assetshare.content.renditions.impl.AssetRenditionsImpl; -import com.google.common.collect.ImmutableMap; + import io.wcm.testing.mock.aem.junit.AemContext; import org.apache.commons.io.IOUtils; import org.apache.sling.api.SlingHttpServletRequest; @@ -44,9 +44,7 @@ import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import java.io.IOException; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; @@ -120,19 +118,20 @@ public void getName() { @Test public void getOptions() { - final Map expected = ImmutableMap.builder(). - put("Foo", "foo"). - put("Foo bar", "foo_bar"). - put("Foo-bar", "foo-bar"). - build(); + final Map expected = Collections.unmodifiableMap(new HashMap() {{ + put("Foo", "foo"); + put("Foo bar", "foo_bar"); + put("Foo-bar", "foo-bar"); + }}); ctx.registerInjectActivateService(new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "foo=foo value", - "foo_bar=foo_bar value", - "foo-bar=foo-bar value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "foo=foo value", + "foo_bar=foo_bar value", + "foo-bar=foo-bar value" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); final Map actual = assetRenditionDispatcher.getOptions(); @@ -146,11 +145,12 @@ public void getRenditionNames() { expected.add("test.ing"); ctx.registerInjectActivateService(new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "foo=foo value", - "test.ing-rendition=test-rendition value"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "foo=foo value", + "test.ing-rendition=test-rendition value" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); final Set actual = assetRenditionDispatcher.getRenditionNames(); @@ -171,11 +171,12 @@ public void dispatch() throws IOException, ServletException { }).when(requestDispatcher).include(any(SlingHttpServletRequest.class), any(SlingHttpServletResponse.class)); ctx.registerInjectActivateService(new StaticRenditionDispatcherImpl(), - ImmutableMap.builder(). - put("rendition.mappings", new String[]{ - "original=original", - "testing=^cq5dam\\.web\\..*"}). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put("rendition.mappings", new String[]{ + "original=original", + "testing=^cq5dam\\.web\\..*" + }); + }})); final AssetRenditionDispatcher assetRenditionDispatcher = ctx.getService(AssetRenditionDispatcher.class); diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/search/impl/FastPropertiesImplTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/search/impl/FastPropertiesImplTest.java index 47121479c..9ea04b0d4 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/search/impl/FastPropertiesImplTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/search/impl/FastPropertiesImplTest.java @@ -20,7 +20,6 @@ package com.adobe.aem.commons.assetshare.search.impl; import com.adobe.aem.commons.assetshare.search.FastProperties; -import com.google.common.collect.ImmutableList; import io.wcm.testing.mock.aem.junit.AemContext; import org.junit.Before; import org.junit.Rule; @@ -28,7 +27,9 @@ import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; @@ -50,11 +51,12 @@ public void setUp() throws Exception { public void getFastProperties_WithNoParams() { final FastProperties fastProperties = ctx.getService(FastProperties.class); - final List expected = ImmutableList.of( - "jcr:content/analyzedIndexRule", - "jcr:content/propertyAndAnalyzedIndexRule", - "jcr:content/propertyIndexRule", - "jcr:content/vanilla"); + final List expected = + Collections.unmodifiableList(Arrays.asList( + "jcr:content/analyzedIndexRule", + "jcr:content/propertyAndAnalyzedIndexRule", + "jcr:content/propertyIndexRule", + "jcr:content/vanilla")); final List actual = fastProperties.getFastProperties(); @@ -65,9 +67,9 @@ public void getFastProperties_WithNoParams() { public void getFastProperties_WithPropertyIndexParam() { final FastProperties fastProperties = ctx.getService(FastProperties.class); - final List expected = ImmutableList.of( + final List expected = Collections.unmodifiableList(Arrays.asList( "jcr:content/propertyAndAnalyzedIndexRule", - "jcr:content/propertyIndexRule"); + "jcr:content/propertyIndexRule")); final List actual = fastProperties.getFastProperties("propertyIndex"); @@ -78,9 +80,9 @@ public void getFastProperties_WithPropertyIndexParam() { public void getFastProperties_WithAnalyzedIndexParam() { final FastProperties fastProperties = ctx.getService(FastProperties.class); - final List expected = ImmutableList.of( + final List expected = Collections.unmodifiableList(Arrays.asList( "jcr:content/analyzedIndexRule", - "jcr:content/propertyAndAnalyzedIndexRule"); + "jcr:content/propertyAndAnalyzedIndexRule")); final List actual = fastProperties.getFastProperties("analyzed"); @@ -92,10 +94,11 @@ public void getFastProperties_WithAnalyzedIndexParam() { public void getFastProperties_WithAnalyzedAndPropertyIndexParams() { final FastProperties fastProperties = ctx.getService(FastProperties.class); - final List expected = ImmutableList.of( - "jcr:content/propertyAndAnalyzedIndexRule"); + final List expected = Collections.unmodifiableList(Collections.singletonList( + + "jcr:content/propertyAndAnalyzedIndexRule")); - final List actual = fastProperties.getFastProperties(ImmutableList.of("analyzed", "propertyIndex")); + final List actual = fastProperties.getFastProperties(Collections.unmodifiableList(Arrays.asList("analyzed", "propertyIndex"))); assertEquals(expected, actual); } @@ -104,18 +107,18 @@ public void getFastProperties_WithAnalyzedAndPropertyIndexParams() { public void getDeltaProperties() { final FastProperties fastProperties = ctx.getService(FastProperties.class); - final Collection fast = ImmutableList.of( + final Collection fast = Collections.unmodifiableList(Arrays.asList( "./jcr:content/one", "./jcr:content/two", "./jcr:content/three", "./jcr:content/four", - "./jcr:content/five"); + "./jcr:content/five")); - final Collection other = ImmutableList.of( + final Collection other = Collections.unmodifiableList(Arrays.asList( "jcr:content/one", "jcr:content/two", "jcr:content/three", - "jcr:content/five"); + "jcr:content/five")); final List actual = fastProperties.getDeltaProperties(fast, other); diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/search/impl/predicateevaluators/PropertyValuesPredicateEvaluatorTest.java b/core/src/test/java/com/adobe/aem/commons/assetshare/search/impl/predicateevaluators/PropertyValuesPredicateEvaluatorTest.java index 68f23d6fd..fde24d1f6 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/search/impl/predicateevaluators/PropertyValuesPredicateEvaluatorTest.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/search/impl/predicateevaluators/PropertyValuesPredicateEvaluatorTest.java @@ -23,7 +23,6 @@ import com.day.cq.search.eval.FulltextPredicateEvaluator; import com.day.cq.search.eval.JcrPropertyPredicateEvaluator; import com.day.cq.search.eval.PredicateEvaluator; -import com.google.common.collect.ImmutableList; import io.wcm.testing.mock.aem.junit.AemContext; import org.junit.Before; import org.junit.Rule; @@ -31,10 +30,7 @@ import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.regex.Pattern; import static org.junit.Assert.*; @@ -263,7 +259,7 @@ public void getValues_MultipleDelimiters() { @Test public void getValues_WhitespaceDelimiters() { - List expected = ImmutableList.of("one", "two", "three", "four", "five"); + List expected = Collections.unmodifiableList(Arrays.asList("one", "two", "three", "four", "five")); List delimiters = new ArrayList<>(); delimiters.add("\\s"); diff --git a/core/src/test/java/com/adobe/aem/commons/assetshare/testing/RequireAemMock.java b/core/src/test/java/com/adobe/aem/commons/assetshare/testing/RequireAemMock.java index bd7a53bba..fb35bd75b 100644 --- a/core/src/test/java/com/adobe/aem/commons/assetshare/testing/RequireAemMock.java +++ b/core/src/test/java/com/adobe/aem/commons/assetshare/testing/RequireAemMock.java @@ -1,10 +1,13 @@ package com.adobe.aem.commons.assetshare.testing; import com.adobe.aem.commons.assetshare.util.RequireAem; -import com.google.common.collect.ImmutableMap; + import io.wcm.testing.mock.aem.junit.AemContext; import org.osgi.framework.Constants; +import java.util.Collections; +import java.util.HashMap; + public class RequireAemMock { public static void setAem(AemContext ctx, RequireAem.Distribution distribution, RequireAem.ServiceType serviceType) { @@ -21,10 +24,10 @@ public ServiceType getServiceType() { return serviceType; } }, - ImmutableMap.builder(). - put(Constants.SERVICE_RANKING, 1). - put("distribution", distribution.getValue()). - put("service", serviceType.getValue()). - build()); + Collections.unmodifiableMap(new HashMap() {{ + put(Constants.SERVICE_RANKING, 1); + put("distribution", distribution.getValue()); + put("service", serviceType.getValue()); + }})); } } diff --git a/pom.xml b/pom.xml index 929e75a75..f0b541282 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ 6.5.19.0000 - 2023.7.12874.20230726T072051Z-230702 + 2025.1.19149.20250116T154450Z-250100 2.17.14 1.9.0 v14.21.3 diff --git a/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config.prod/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config b/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config.prod/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config index 884972f16..c5c5710f9 100644 --- a/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config.prod/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config +++ b/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config.prod/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config @@ -2,4 +2,3 @@ org.apache.sling.commons.log.additiv="false" org.apache.sling.commons.log.file="logs/error.log" org.apache.sling.commons.log.level="$[env:ASC_LOG_LEVEL;default\=error]" org.apache.sling.commons.log.names=[ "com.adobe.aem.commons.assetshare" ] -org.apache.sling.commons.log.pattern="{0,date,yyyy-MM-dd\ HH:mm:ss.SSS}\ {4}\ [{3}]\ {5}" diff --git a/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config.stage/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config b/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config.stage/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config index 94e2c887f..848f3767f 100644 --- a/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config.stage/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config +++ b/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config.stage/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config @@ -2,4 +2,3 @@ org.apache.sling.commons.log.additiv="false" org.apache.sling.commons.log.file="logs/error.log" org.apache.sling.commons.log.level="$[env:ASC_LOG_LEVEL;default\=warn]" org.apache.sling.commons.log.names=[ "com.adobe.aem.commons.assetshare" ] -org.apache.sling.commons.log.pattern="{0,date,yyyy-MM-dd\ HH:mm:ss.SSS}\ {4}\ [{3}]\ {5}" diff --git a/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config b/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config index 7ea0f42fd..aa93a6889 100644 --- a/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config +++ b/ui.config/src/main/content/jcr_root/apps/asset-share-commons/osgiconfig/config/org.apache.sling.commons.log.LogManager.factory.config~asset-share-commons.config @@ -2,4 +2,3 @@ org.apache.sling.commons.log.additiv="false" org.apache.sling.commons.log.file="logs/error.log" org.apache.sling.commons.log.level="$[env:ASC_LOG_LEVEL;default\=debug]" org.apache.sling.commons.log.names=[ "com.adobe.aem.commons.assetshare" ] -org.apache.sling.commons.log.pattern="{0,date,yyyy-MM-dd\ HH:mm:ss.SSS}\ {4}\ [{3}]\ {5}" diff --git a/ui.content.sample/src/main/content/jcr_root/content/.content.xml b/ui.content.sample/src/main/content/jcr_root/content/.content.xml deleted file mode 100644 index 383bac752..000000000 --- a/ui.content.sample/src/main/content/jcr_root/content/.content.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/ui.content.sample/src/main/content/jcr_root/content/dam/.content.xml b/ui.content.sample/src/main/content/jcr_root/content/dam/.content.xml deleted file mode 100644 index ecfdaf0c2..000000000 --- a/ui.content.sample/src/main/content/jcr_root/content/dam/.content.xml +++ /dev/null @@ -1,4 +0,0 @@ - - From a0462d1c1f823cd7d84c230794129a62379adf0a Mon Sep 17 00:00:00 2001 From: david g Date: Fri, 31 Jan 2025 13:10:21 -0500 Subject: [PATCH 2/3] Trying old version of AEM SDK --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f0b541282..99f156010 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ 6.5.19.0000 - 2025.1.19149.20250116T154450Z-250100 + 2024.10.18459.20241031T210302Z-241000 2.17.14 1.9.0 v14.21.3 From 98a78778d9d713b66b8210d90a9c7ab174d25b32 Mon Sep 17 00:00:00 2001 From: david g Date: Fri, 31 Jan 2025 13:13:57 -0500 Subject: [PATCH 3/3] Remove J8 from build matrix since AEM versions dont support it --- .github/workflows/verify.yaml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 6c8223c59..6d730850a 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [8, 11] + java: [11] steps: - name: Checkout code diff --git a/pom.xml b/pom.xml index 99f156010..f0b541282 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ 6.5.19.0000 - 2024.10.18459.20241031T210302Z-241000 + 2025.1.19149.20250116T154450Z-250100 2.17.14 1.9.0 v14.21.3