You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by re...@apache.org on 2024/07/18 17:08:07 UTC
(sling-org-apache-sling-resourceresolver) 01/01: SLING-12387: ResourceResolver: improve test coverage for PagedQueryIterator
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch SLING-12387
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit e58bc15e01eebed6b8230f95fb0f346a3e5444e3
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu Jul 18 18:07:51 2024 +0100
SLING-12387: ResourceResolver: improve test coverage for PagedQueryIterator
---
.../resourceresolver/impl/mapping/MapEntries.java | 2 +-
.../impl/mapping/PagedQueryIteratorTest.java | 61 ++++++++++++++++++++++
2 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
index 168faeb..3a9f94f 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
@@ -1306,7 +1306,7 @@ public class MapEntries implements
/**
* Utility class for running paged queries.
*/
- private class PagedQueryIterator implements Iterator<Resource> {
+ protected class PagedQueryIterator implements Iterator<Resource> {
private ResourceResolver resolver;
private String subject;
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/PagedQueryIteratorTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/PagedQueryIteratorTest.java
new file mode 100755
index 0000000..65a585c
--- /dev/null
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/PagedQueryIteratorTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourceresolver.impl.mapping;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.path.Path;
+import org.apache.sling.resourceresolver.impl.ResourceResolverMetrics;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+
+public class PagedQueryIteratorTest extends AbstractMappingMapEntriesTest {
+
+ private MapEntries mapEntries;
+
+ @Before
+ public void setup() throws Exception {
+ MockitoAnnotations.openMocks(this).close();
+
+ when(bundle.getSymbolicName()).thenReturn("TESTBUNDLE");
+ when(bundleContext.getBundle()).thenReturn(bundle);
+ when(resourceResolverFactory.getServiceResourceResolver(any(Map.class))).thenReturn(resourceResolver);
+ when(resourceResolverFactory.getObservationPaths()).thenReturn(new Path[] { new Path("/") });
+ when(resourceResolverFactory.getMapRoot()).thenReturn(MapEntries.DEFAULT_MAP_ROOT);
+ when(resourceResolver.findResources(anyString(), eq("JCR-SQL2"))).thenReturn(Collections.<Resource> emptySet().iterator());
+
+ Optional<ResourceResolverMetrics> metrics = Optional.empty();
+
+ mapEntries = new MapEntries(resourceResolverFactory, bundleContext, eventAdmin, stringInterpolationProvider, metrics);
+ }
+
+ @Test
+ public void testInstantiation() {
+ mapEntries.new PagedQueryIterator("alias", "sling:alias", resourceResolver, "foo", 2000);
+ }
+}