> getContextAwareServiceTrackerMap() {
diff --git a/src/main/java/io/wcm/sling/commons/resource/ImmutableValueMap.java b/src/main/java/io/wcm/sling/commons/resource/ImmutableValueMap.java
index bee8a5e..11ca568 100644
--- a/src/main/java/io/wcm/sling/commons/resource/ImmutableValueMap.java
+++ b/src/main/java/io/wcm/sling/commons/resource/ImmutableValueMap.java
@@ -24,7 +24,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import java.util.SortedMap;
+import java.util.TreeMap;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
@@ -32,10 +32,6 @@
import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSortedMap;
-
/**
* {@link ValueMap} that does not support changing its content.
*
@@ -129,8 +125,7 @@ public boolean equals(Object obj) {
@Override
public String toString() {
- SortedMap sortedMap = ImmutableSortedMap.copyOf(this.map);
- return "{" + Joiner.on(",").withKeyValueSeparator("=").join(sortedMap) + "}";
+ return new TreeMap<>(map).toString();
}
// mutable operations not supported
@@ -190,8 +185,9 @@ public void clear() {
* @param v1 Value 1
* @return ImmutableValueMap
*/
+ @SuppressWarnings("null")
public static @NotNull ImmutableValueMap of(@NotNull String k1, @NotNull Object v1) {
- return new ImmutableValueMap(ImmutableMap.of(k1, v1));
+ return new ImmutableValueMap(Map.of(k1, v1));
}
/**
@@ -203,9 +199,10 @@ public void clear() {
* @return ImmutableValueMap
* @throws IllegalArgumentException if duplicate keys are provided
*/
+ @SuppressWarnings("null")
public static @NotNull ImmutableValueMap of(@NotNull String k1, @NotNull Object v1,
@NotNull String k2, @NotNull Object v2) {
- return new ImmutableValueMap(ImmutableMap.of(k1, v1, k2, v2));
+ return new ImmutableValueMap(Map.of(k1, v1, k2, v2));
}
/**
@@ -219,11 +216,12 @@ public void clear() {
* @return ImmutableValueMap
* @throws IllegalArgumentException if duplicate keys are provided
*/
+ @SuppressWarnings("null")
public static @NotNull ImmutableValueMap of(
@NotNull String k1, @NotNull Object v1,
@NotNull String k2, @NotNull Object v2,
@NotNull String k3, @NotNull Object v3) {
- return new ImmutableValueMap(ImmutableMap.of(k1, v1, k2, v2, k3, v3));
+ return new ImmutableValueMap(Map.of(k1, v1, k2, v2, k3, v3));
}
/**
@@ -239,13 +237,13 @@ public void clear() {
* @return ImmutableValueMap
* @throws IllegalArgumentException if duplicate keys are provided
*/
- @SuppressWarnings({ "java:S107", "PMD.UseObjectForClearerAPI" })
+ @SuppressWarnings({ "null", "java:S107", "PMD.UseObjectForClearerAPI" })
public static @NotNull ImmutableValueMap of(
@NotNull String k1, @NotNull Object v1,
@NotNull String k2, @NotNull Object v2,
@NotNull String k3, @NotNull Object v3,
@NotNull String k4, @NotNull Object v4) {
- return new ImmutableValueMap(ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4));
+ return new ImmutableValueMap(Map.of(k1, v1, k2, v2, k3, v3, k4, v4));
}
/**
@@ -263,14 +261,14 @@ public void clear() {
* @return ImmutableValueMap
* @throws IllegalArgumentException if duplicate keys are provided
*/
- @SuppressWarnings({ "java:S107", "PMD.UseObjectForClearerAPI" })
+ @SuppressWarnings({ "null", "java:S107", "PMD.UseObjectForClearerAPI" })
public static ImmutableValueMap of(
@NotNull String k1, @NotNull Object v1,
@NotNull String k2, @NotNull Object v2,
@NotNull String k3, @NotNull Object v3,
@NotNull String k4, @NotNull Object v4,
@NotNull String k5, @NotNull Object v5) {
- return new ImmutableValueMap(ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5));
+ return new ImmutableValueMap(Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5));
}
// looking for of() with > 5 entries? Use the builder instead.
diff --git a/src/main/java/io/wcm/sling/commons/util/Escape.java b/src/main/java/io/wcm/sling/commons/util/Escape.java
index 8d27ff2..8c7c470 100644
--- a/src/main/java/io/wcm/sling/commons/util/Escape.java
+++ b/src/main/java/io/wcm/sling/commons/util/Escape.java
@@ -30,15 +30,13 @@
import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
-import com.google.common.collect.ImmutableSet;
-
/**
* Encoding utility functions.
*/
@ProviderType
public final class Escape {
private static final char LIKE_ESCAPE_CHARACTER = '\\';
- private static final Set LIKE_SPECIAL_CHARACTERS = ImmutableSet.of('%', '_');
+ private static final Set LIKE_SPECIAL_CHARACTERS = Set.of('%', '_');
private Escape() {
// Utility class - no instancing allowed
diff --git a/src/site/markdown/context-aware-services.md b/src/site/markdown/context-aware-services.md
index 96ca61b..b1d25e8 100644
--- a/src/site/markdown/context-aware-services.md
+++ b/src/site/markdown/context-aware-services.md
@@ -54,7 +54,7 @@ Define references to services via Declarative Services:
```java
@Reference(cardinality = ReferenceCardinality.MULTIPLE, fieldOption = FieldOption.UPDATE,
policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
- private Collection> services;
+ private SortedSet> services = new ConcurrentSkipListSet<>(Collections.reverseOrder());
```
Setup `ContextAwareServiceCollectionResolver` which get's a view filtered by resource context of these services:
@@ -62,7 +62,7 @@ Setup `ContextAwareServiceCollectionResolver` which get's a view filtered by res
```java
@Reference
private ContextAwareServiceResolver serviceResolver;
- private ContextAwareServiceCollectionResolver serviceCollectionResolver;
+ private ContextAwareServiceCollectionResolver serviceCollectionResolver;
@Activate
private void activate() {
diff --git a/src/test/java/io/wcm/sling/commons/caservice/impl/ContextAwareServiceCollectionResolverImplTest.java b/src/test/java/io/wcm/sling/commons/caservice/impl/ContextAwareServiceCollectionResolverImplTest.java
index 62c896e..d1e9fc4 100644
--- a/src/test/java/io/wcm/sling/commons/caservice/impl/ContextAwareServiceCollectionResolverImplTest.java
+++ b/src/test/java/io/wcm/sling/commons/caservice/impl/ContextAwareServiceCollectionResolverImplTest.java
@@ -23,6 +23,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
+import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
@@ -30,8 +31,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import com.google.common.collect.ImmutableList;
-
import io.wcm.sling.commons.caservice.ContextAwareServiceCollectionResolver;
import io.wcm.sling.commons.caservice.ContextAwareServiceResolver;
import io.wcm.sling.commons.caservice.PathPreprocessor;
@@ -75,7 +74,7 @@ void testWithDefaultImpl() {
assertSame(contentDamImpl, underTest.resolve(context.create().resource("/content/dam/test1")));
assertSame(defaultImpl, underTest.resolve(context.create().resource("/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl, defaultImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl, defaultImpl),
underTest.resolveAll(context.create().resource("/content/dam/test2")).collect(Collectors.toList()));
}
}
@@ -93,7 +92,7 @@ void testWithDefaultImpl_Decorated() {
assertSame(contentDamImpl, underTest.resolveDecorated(context.create().resource("/content/dam/test1")).getService());
assertSame(defaultImpl, underTest.resolveDecorated(context.create().resource("/etc/test1")).getService());
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl, defaultImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl, defaultImpl),
underTest.resolveAllDecorated(context.create().resource("/content/dam/test2"))
.map(DummySpiDecorator::getService).collect(Collectors.toList()));
}
@@ -109,13 +108,13 @@ void testWithDefaultImpl_DynamicListChange() {
assertSame(contentImpl, underTest.resolve(context.create().resource("/content/sample/exclude/test1")));
assertSame(contentDamImpl, underTest.resolve(context.create().resource("/content/dam/test1")));
assertNull(underTest.resolve(context.create().resource("/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl),
underTest.resolveAll(context.create().resource("/content/dam/test2")).collect(Collectors.toList()));
DummySpi defaultImpl = testServices.addDefaultService();
assertSame(defaultImpl, underTest.resolve(context.create().resource("/etc/test2")));
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl, defaultImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl, defaultImpl),
underTest.resolveAll(context.create().resource("/content/dam/test3")).collect(Collectors.toList()));
}
}
@@ -131,9 +130,9 @@ void testWithoutDefaultImpl() {
assertSame(contentDamImpl, underTest.resolve(context.create().resource("/content/dam/test1")));
assertNull(underTest.resolve(context.create().resource("/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl),
underTest.resolveAll(context.create().resource("/content/dam/test2")).collect(Collectors.toList()));
- assertEquals(ImmutableList.of(contentSampleImpl, contentImpl),
+ assertEquals(List.of(contentSampleImpl, contentImpl),
underTest.resolveAll(context.create().resource("/content/sample/test2")).collect(Collectors.toList()));
}
}
@@ -147,7 +146,7 @@ void testWithSlingHttpServletRequest() {
context.currentResource(context.create().resource("/content/sample/test1"));
assertSame(contentSampleImpl, underTest.resolve(context.request()));
- assertEquals(ImmutableList.of(contentSampleImpl, contentImpl, defaultImpl),
+ assertEquals(List.of(contentSampleImpl, contentImpl, defaultImpl),
underTest.resolveAll(context.request()).collect(Collectors.toList()));
}
}
@@ -166,7 +165,7 @@ void testWithSlingHttpServletRequest_ResourceOtherContext() {
context.currentResource(context.create().resource("/content/experience-fragments/test1"));
assertSame(contentSampleImpl, underTest.resolve(context.request()));
- assertEquals(ImmutableList.of(contentSampleImpl, contentImpl, defaultImpl),
+ assertEquals(List.of(contentSampleImpl, contentImpl, defaultImpl),
underTest.resolveAll(context.request()).collect(Collectors.toList()));
}
}
@@ -180,7 +179,7 @@ void testWithNull() {
assertSame(defaultImpl, underTest.resolve(null));
- assertEquals(ImmutableList.of(defaultImpl), underTest.resolveAll(null).collect(Collectors.toList()));
+ assertEquals(List.of(defaultImpl), underTest.resolveAll(null).collect(Collectors.toList()));
}
}
@@ -196,7 +195,7 @@ void testWithBundleHeader() {
assertSame(contentDamImplWithBundleHeader, underTest.resolve(context.create().resource("/content/dam/test1")));
assertNull(underTest.resolve(context.create().resource("/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImplWithBundleHeader, contentDamImpl, contentImpl),
+ assertEquals(List.of(contentDamImplWithBundleHeader, contentDamImpl, contentImpl),
underTest.resolveAll(context.create().resource("/content/dam/test2")).collect(Collectors.toList()));
}
}
@@ -214,7 +213,7 @@ void testWithPathPreProcessor() {
assertSame(contentDamImpl, underTest.resolve(context.create().resource("/pathprefix/content/dam/test1")));
assertNull(underTest.resolve(context.create().resource("/pathprefix/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl),
underTest.resolveAll(context.create().resource("/pathprefix/content/dam/test2")).collect(Collectors.toList()));
}
}
diff --git a/src/test/java/io/wcm/sling/commons/caservice/impl/ContextAwareServiceResolverImplTest.java b/src/test/java/io/wcm/sling/commons/caservice/impl/ContextAwareServiceResolverImplTest.java
index e83753e..289b764 100644
--- a/src/test/java/io/wcm/sling/commons/caservice/impl/ContextAwareServiceResolverImplTest.java
+++ b/src/test/java/io/wcm/sling/commons/caservice/impl/ContextAwareServiceResolverImplTest.java
@@ -24,6 +24,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
+import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
@@ -31,8 +32,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import com.google.common.collect.ImmutableList;
-
import io.wcm.sling.commons.caservice.ContextAwareServiceResolver;
import io.wcm.sling.commons.caservice.ContextAwareServiceResolver.ResolveAllResult;
import io.wcm.sling.commons.caservice.PathPreprocessor;
@@ -74,7 +73,7 @@ void testWithDefaultImpl() {
assertSame(contentDamImpl, underTest.resolve(DummySpi.class, context.create().resource("/content/dam/test1")));
assertSame(defaultImpl, underTest.resolve(DummySpi.class, context.create().resource("/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl, defaultImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl, defaultImpl),
underTest.resolveAll(DummySpi.class, context.create().resource("/content/dam/test2")).getServices().collect(Collectors.toList()));
}
@@ -86,9 +85,9 @@ void testWithoutDefaultImpl() {
assertSame(contentDamImpl, underTest.resolve(DummySpi.class, context.create().resource("/content/dam/test1")));
assertNull(underTest.resolve(DummySpi.class, context.create().resource("/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl),
underTest.resolveAll(DummySpi.class, context.create().resource("/content/dam/test2")).getServices().collect(Collectors.toList()));
- assertEquals(ImmutableList.of(contentSampleImpl, contentImpl),
+ assertEquals(List.of(contentSampleImpl, contentImpl),
underTest.resolveAll(DummySpi.class, context.create().resource("/content/sample/test2")).getServices().collect(Collectors.toList()));
}
@@ -99,7 +98,7 @@ void testWithSlingHttpServletRequest() {
context.currentResource(context.create().resource("/content/sample/test1"));
assertSame(contentSampleImpl, underTest.resolve(DummySpi.class, context.request()));
- assertEquals(ImmutableList.of(contentSampleImpl, contentImpl, defaultImpl),
+ assertEquals(List.of(contentSampleImpl, contentImpl, defaultImpl),
underTest.resolveAll(DummySpi.class, context.request()).getServices().collect(Collectors.toList()));
}
@@ -115,7 +114,7 @@ void testWithSlingHttpServletRequest_ResourceOtherContext() {
context.currentResource(context.create().resource("/content/experience-fragments/test1"));
assertSame(contentSampleImpl, underTest.resolve(DummySpi.class, context.request()));
- assertEquals(ImmutableList.of(contentSampleImpl, contentImpl, defaultImpl),
+ assertEquals(List.of(contentSampleImpl, contentImpl, defaultImpl),
underTest.resolveAll(DummySpi.class, context.request()).getServices().collect(Collectors.toList()));
}
@@ -125,7 +124,7 @@ void testWithNull() {
assertSame(defaultImpl, underTest.resolve(DummySpi.class, null));
- assertEquals(ImmutableList.of(defaultImpl), underTest.resolveAll(DummySpi.class, null).getServices().collect(Collectors.toList()));
+ assertEquals(List.of(defaultImpl), underTest.resolveAll(DummySpi.class, null).getServices().collect(Collectors.toList()));
}
@Test
@@ -148,7 +147,7 @@ void testWithBundleHeader() {
assertSame(contentDamImplWithBundleHeader, underTest.resolve(DummySpi.class, context.create().resource("/content/dam/test1")));
assertNull(underTest.resolve(DummySpi.class, context.create().resource("/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImplWithBundleHeader, contentDamImpl, contentImpl),
+ assertEquals(List.of(contentDamImplWithBundleHeader, contentDamImpl, contentImpl),
underTest.resolveAll(DummySpi.class, context.create().resource("/content/dam/test2")).getServices().collect(Collectors.toList()));
}
@@ -163,7 +162,7 @@ void testWithPathPreProcessor() {
assertSame(contentDamImpl, underTest.resolve(DummySpi.class, context.create().resource("/pathprefix/content/dam/test1")));
assertNull(underTest.resolve(DummySpi.class, context.create().resource("/pathprefix/etc/test1")));
- assertEquals(ImmutableList.of(contentDamImpl, contentImpl),
+ assertEquals(List.of(contentDamImpl, contentImpl),
underTest.resolveAll(DummySpi.class, context.create().resource("/pathprefix/content/dam/test2")).getServices().collect(Collectors.toList()));
}
diff --git a/src/test/java/io/wcm/sling/commons/caservice/impl/TestServices.java b/src/test/java/io/wcm/sling/commons/caservice/impl/TestServices.java
index 010108d..0b6ec4f 100644
--- a/src/test/java/io/wcm/sling/commons/caservice/impl/TestServices.java
+++ b/src/test/java/io/wcm/sling/commons/caservice/impl/TestServices.java
@@ -27,6 +27,7 @@
import java.util.Collection;
import java.util.Comparator;
import java.util.Dictionary;
+import java.util.Map;
import java.util.TreeSet;
import org.apache.sling.testing.mock.osgi.MapUtil;
@@ -34,8 +35,6 @@
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-import com.google.common.collect.ImmutableMap;
-
import io.wcm.testing.mock.aem.junit5.AemContext;
/**
@@ -106,7 +105,7 @@ DummySpi addDefaultService() {
@SuppressWarnings("null")
DummySpi addContentDamImplWithBundleHeader() {
// service gets path pattern from bundle header instead of service property
- ((MockBundle)context.bundleContext().getBundle()).setHeaders(ImmutableMap.of(
+ ((MockBundle)context.bundleContext().getBundle()).setHeaders(Map.of(
PROPERTY_CONTEXT_PATH_PATTERN, "^/content/dam(/.*)?$"));
return register(new DummySpiImpl("/content/dam (bundle header)"),
SERVICE_RANKING, 1000);
diff --git a/src/test/java/io/wcm/sling/commons/osgi/RankedServicesTest.java b/src/test/java/io/wcm/sling/commons/osgi/RankedServicesTest.java
index c8db53f..25586a2 100644
--- a/src/test/java/io/wcm/sling/commons/osgi/RankedServicesTest.java
+++ b/src/test/java/io/wcm/sling/commons/osgi/RankedServicesTest.java
@@ -26,26 +26,27 @@
import java.util.Map;
+import org.apache.commons.collections4.IteratorUtils;
import org.junit.jupiter.api.Test;
import org.osgi.framework.Constants;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterators;
-
import io.wcm.sling.commons.osgi.RankedServices.ChangeListener;
@SuppressWarnings({ "deprecation", "null" })
class RankedServicesTest {
private static final String SERVICE_1 = "service1";
- private static final Map SERVICE_1_PROPS = ImmutableMap.builder()
- .put(Constants.SERVICE_RANKING, 50).put(Constants.SERVICE_ID, 1L).build();
+ private static final Map SERVICE_1_PROPS = Map.of(
+ Constants.SERVICE_RANKING, 50,
+ Constants.SERVICE_ID, 1L);
private static final String SERVICE_2 = "service2";
- private static final Map SERVICE_2_PROPS = ImmutableMap.builder()
- .put(Constants.SERVICE_RANKING, 10).put(Constants.SERVICE_ID, 2L).build();
+ private static final Map SERVICE_2_PROPS = Map.of(
+ Constants.SERVICE_RANKING, 10,
+ Constants.SERVICE_ID, 2L);
private static final String SERVICE_3 = "service3";
- private static final Map SERVICE_3_PROPS = ImmutableMap.builder()
- .put(Constants.SERVICE_RANKING, 100).put(Constants.SERVICE_ID, 3L).build();
+ private static final Map SERVICE_3_PROPS = Map.of(
+ Constants.SERVICE_RANKING, 100,
+ Constants.SERVICE_ID, 3L);
@Test
void testSortedServices() {
@@ -55,20 +56,20 @@ void testSortedServices() {
underTest.bind(SERVICE_1, SERVICE_1_PROPS);
assertEquals(1, underTest.get().size());
- Comparable[] services = Iterators.toArray(underTest.get().iterator(), Comparable.class);
+ Comparable[] services = IteratorUtils.toArray(underTest.get().iterator(), Comparable.class);
assertSame(SERVICE_1, services[0]);
underTest.bind(SERVICE_2, SERVICE_2_PROPS);
underTest.bind(SERVICE_3, SERVICE_3_PROPS);
assertEquals(3, underTest.get().size());
- services = Iterators.toArray(underTest.get().iterator(), Comparable.class);
+ services = IteratorUtils.toArray(underTest.get().iterator(), Comparable.class);
assertSame(SERVICE_2, services[0]);
assertSame(SERVICE_1, services[1]);
assertSame(SERVICE_3, services[2]);
underTest.unbind(SERVICE_2, SERVICE_2_PROPS);
assertEquals(2, underTest.get().size());
- services = Iterators.toArray(underTest.get().iterator(), Comparable.class);
+ services = IteratorUtils.toArray(underTest.get().iterator(), Comparable.class);
assertSame(SERVICE_1, services[0]);
assertSame(SERVICE_3, services[1]);
diff --git a/src/test/java/io/wcm/sling/commons/request/QueryStringBuilderTest.java b/src/test/java/io/wcm/sling/commons/request/QueryStringBuilderTest.java
index 769bbbb..e83fac6 100644
--- a/src/test/java/io/wcm/sling/commons/request/QueryStringBuilderTest.java
+++ b/src/test/java/io/wcm/sling/commons/request/QueryStringBuilderTest.java
@@ -22,11 +22,13 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.jupiter.api.Test;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSortedMap;
-import com.google.common.collect.ImmutableSortedSet;
+import org.junit.jupiter.api.Test;
import io.wcm.sling.commons.util.Escape;
@@ -61,8 +63,8 @@ void testUrlEncoding() {
void testMulti() {
assertEquals("p1=value1&p1=value2&p1=&p2=1&p2=2&p3=false&p3=true&p4=abc", new QueryStringBuilder()
.param("p1", new String[] { "value1", "value2", null })
- .param("p2", ImmutableList.of(1, 2))
- .param("p3", ImmutableSortedSet.of(false, true))
+ .param("p2", List.of(1, 2))
+ .param("p3", new TreeSet<>(Set.of(false, true)))
.param("p4", "abc")
.build());
}
@@ -70,12 +72,12 @@ void testMulti() {
@Test
void testMap() {
assertEquals("p1=value1&p1=value2&p1=&p2=1&p2=2&p3=false&p3=true&p4=abc", new QueryStringBuilder()
- .params(ImmutableSortedMap.of(
+ .params(new TreeMap<>(Map.of(
"p1", new String[] { "value1", "value2", null },
- "p2", ImmutableList.of(1, 2),
- "p3", ImmutableSortedSet.of(false, true),
+ "p2", List.of(1, 2),
+ "p3", new TreeSet<>(Set.of(false, true)),
"p4", "abc"
- ))
+ )))
.build());
}
diff --git a/src/test/java/io/wcm/sling/commons/request/RequestParamTest.java b/src/test/java/io/wcm/sling/commons/request/RequestParamTest.java
index e3317fe..f1ea73e 100644
--- a/src/test/java/io/wcm/sling/commons/request/RequestParamTest.java
+++ b/src/test/java/io/wcm/sling/commons/request/RequestParamTest.java
@@ -33,8 +33,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import com.google.common.collect.ImmutableMap;
-
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
@@ -73,34 +71,18 @@ void setUp() throws Exception {
request.setParameterMap(paramMap);
}
+ @SuppressWarnings("null")
protected Map getParamMap() {
- return ImmutableMap.builder()
- .put(STRING_PARAM, new String[] {
- STRING_VALUE
- })
- .put(MULTI_STRING_PARAM, MULTI_STRING_VALUE)
- .put(INTEGER_PARAM, new String[] {
- Integer.toString(INTEGER_VALUE)
- })
- .put(LONG_PARAM, new String[] {
- Long.toString(LONG_VALUE)
- })
- .put(FLOAT_PARAM, new String[] {
- Float.toString(FLOAT_VALUE)
- })
- .put(DOUBLE_PARAM, new String[] {
- Double.toString(DOUBLE_VALUE)
- })
- .put(BOOLEAN_PARAM, new String[] {
- Boolean.toString(BOOLEAN_VALUE)
- })
- .put(ENUM_PARAM, new String[] {
- ENUM_VALUE.name()
- })
- .put(RequestParam.PARAMETER_FORMENCODING, new String[] {
- StandardCharsets.UTF_8.name()
- })
- .build();
+ return Map.of(
+ STRING_PARAM, new String[] { STRING_VALUE },
+ MULTI_STRING_PARAM, MULTI_STRING_VALUE,
+ INTEGER_PARAM, new String[] { Integer.toString(INTEGER_VALUE) },
+ LONG_PARAM, new String[] { Long.toString(LONG_VALUE) },
+ FLOAT_PARAM, new String[] { Float.toString(FLOAT_VALUE) },
+ DOUBLE_PARAM, new String[] { Double.toString(DOUBLE_VALUE) },
+ BOOLEAN_PARAM, new String[] { Boolean.toString(BOOLEAN_VALUE) },
+ ENUM_PARAM, new String[] { ENUM_VALUE.name() },
+ RequestParam.PARAMETER_FORMENCODING, new String[] { StandardCharsets.UTF_8.name() });
}
enum SAMPLE_ENUM {
diff --git a/src/test/java/io/wcm/sling/commons/resource/ImmutableValueMapTest.java b/src/test/java/io/wcm/sling/commons/resource/ImmutableValueMapTest.java
index b7aeea5..f8a8409 100644
--- a/src/test/java/io/wcm/sling/commons/resource/ImmutableValueMapTest.java
+++ b/src/test/java/io/wcm/sling/commons/resource/ImmutableValueMapTest.java
@@ -32,14 +32,11 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import com.google.common.collect.ImmutableMap;
-
class ImmutableValueMapTest {
- private static final Map SAMPLE_PROPS = ImmutableMap.builder()
- .put("prop1", "value1")
- .put("prop2", 55)
- .build();
+ private static final Map SAMPLE_PROPS = Map.of(
+ "prop1", "value1",
+ "prop2", 55);
private ValueMap underTest;
@@ -95,10 +92,9 @@ void testMapPut() {
@Test
void testMapPutAll() {
assertThrows(UnsupportedOperationException.class, () -> {
- underTest.putAll(ImmutableMap.builder()
- .put("prop4", 25)
- .put("prop5", 33)
- .build());
+ underTest.putAll(Map.of(
+ "prop4", 25,
+ "prop5", 33));
});
}
@@ -157,8 +153,8 @@ void testOfx5() {
void testBuilder() {
ValueMap map = ImmutableValueMap.builder()
.put("p1", "v1")
- .putAll(ImmutableMap.of("p2", "v2", "p3", "v3"))
- .put(ImmutableMap.of("p4", "v4").entrySet().iterator().next())
+ .putAll(Map.of("p2", "v2", "p3", "v3"))
+ .put(Map.of("p4", "v4").entrySet().iterator().next())
.put("p5", "v5")
.build();
assertEquals(5, map.size());
@@ -210,7 +206,7 @@ void testToString() {
.put("prop2", 55)
.put("prop0", true)
.build();
- assertEquals("{prop0=true,prop1=value1,prop2=55}", map.toString());
+ assertEquals("{prop0=true, prop1=value1, prop2=55}", map.toString());
assertEquals("{}", ImmutableValueMap.of().toString());
}