You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "reschke (via GitHub)" <gi...@apache.org> on 2025/08/13 13:04:29 UTC

[PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

reschke opened a new pull request, #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke merged PR #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

Posted by "joerghoh (via GitHub)" <gi...@apache.org>.
joerghoh commented on code in PR #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189#discussion_r2273568820


##########
src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java:
##########
@@ -511,16 +512,20 @@ public void test_doRemoveAttributesWithDisableAliasOptimization() throws Excepti
         Resource parent = createMockedResource("/parent");
         Resource result = createMockedResource("/parent/child");
 
-        // TODO: using attachChildResource causes the test to fail
-        // attachChildResource(parent, result);
+        attachChildResource(parent, result);
 
-        when(result.getParent()).thenReturn(parent);
         when(result.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, "alias"));
 
+        Map<String, Collection<String>> aliasMapBefore = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapBefore.size());
+
+        // this simulates a remove event, but that is immaterial here as there is no cache anyway
         removeAlias(mapEntries, resourceResolver, "/parent", "/parent/child", NOOP);
 
-        Map<String, Collection<String>> aliasMap = mapEntries.getAliasMap("/parent");
-        assertEquals(Collections.emptyMap(), aliasMap);
+        Map<String, Collection<String>> aliasMapAfter = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapAfter.size());

Review Comment:
   same as above



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189#issuecomment-3183860237

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

Posted by "joerghoh (via GitHub)" <gi...@apache.org>.
joerghoh commented on code in PR #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189#discussion_r2273567848


##########
src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java:
##########
@@ -487,18 +487,19 @@ public void test_doUpdateAttributesWithDisableAliasOptimization() throws Excepti
 
         Resource parent = createMockedResource("/parent");
         Resource result = createMockedResource("/parent/child");
-
-        // TODO: using attachChildResource causes the test to fail
-        // attachChildResource(parent, result);
-
-        when(result.getParent()).thenReturn(parent);
+        attachChildResource(parent, result);
 
         when(result.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, "alias"));
+        Map<String, Collection<String>> aliasMapBefore = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapBefore.size());
 
+        // this simulates an add event, but that is immaterial here as there is no cache anyway
         addResource(mapEntries, "/parent/child", new AtomicBoolean());
 
-        Map<String, Collection<String>> aliasMap = mapEntries.getAliasMap("/parent");
-        assertEquals(Collections.emptyMap(), aliasMap);
+        Map<String, Collection<String>> aliasMapAfter = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapAfter.size());

Review Comment:
   isn't this a different assertion?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189#discussion_r2273718788


##########
src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java:
##########
@@ -487,18 +487,19 @@ public void test_doUpdateAttributesWithDisableAliasOptimization() throws Excepti
 
         Resource parent = createMockedResource("/parent");
         Resource result = createMockedResource("/parent/child");
-
-        // TODO: using attachChildResource causes the test to fail
-        // attachChildResource(parent, result);
-
-        when(result.getParent()).thenReturn(parent);
+        attachChildResource(parent, result);
 
         when(result.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, "alias"));
+        Map<String, Collection<String>> aliasMapBefore = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapBefore.size());
 
+        // this simulates an add event, but that is immaterial here as there is no cache anyway
         addResource(mapEntries, "/parent/child", new AtomicBoolean());
 
-        Map<String, Collection<String>> aliasMap = mapEntries.getAliasMap("/parent");
-        assertEquals(Collections.emptyMap(), aliasMap);
+        Map<String, Collection<String>> aliasMapAfter = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapAfter.size());

Review Comment:
   yes, that's one of the two test cases that were actually incorrect (relying on a broken parent/child relation).
   
   See https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189#issue-3318395659



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189#issuecomment-3183931076

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-resourceresolver&pullRequest=189)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189#discussion_r2273718788


##########
src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java:
##########
@@ -487,18 +487,19 @@ public void test_doUpdateAttributesWithDisableAliasOptimization() throws Excepti
 
         Resource parent = createMockedResource("/parent");
         Resource result = createMockedResource("/parent/child");
-
-        // TODO: using attachChildResource causes the test to fail
-        // attachChildResource(parent, result);
-
-        when(result.getParent()).thenReturn(parent);
+        attachChildResource(parent, result);
 
         when(result.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, "alias"));
+        Map<String, Collection<String>> aliasMapBefore = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapBefore.size());
 
+        // this simulates an add event, but that is immaterial here as there is no cache anyway
         addResource(mapEntries, "/parent/child", new AtomicBoolean());
 
-        Map<String, Collection<String>> aliasMap = mapEntries.getAliasMap("/parent");
-        assertEquals(Collections.emptyMap(), aliasMap);
+        Map<String, Collection<String>> aliasMapAfter = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapAfter.size());

Review Comment:
   yes, that's one of the two test cases that were actually incorrect (relying on a broken parent/child relation).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-12884: ResourceResolver: refactor mocking in AliasMapEntriesTest [sling-org-apache-sling-resourceresolver]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #189:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/189#discussion_r2273720135


##########
src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java:
##########
@@ -511,16 +512,20 @@ public void test_doRemoveAttributesWithDisableAliasOptimization() throws Excepti
         Resource parent = createMockedResource("/parent");
         Resource result = createMockedResource("/parent/child");
 
-        // TODO: using attachChildResource causes the test to fail
-        // attachChildResource(parent, result);
+        attachChildResource(parent, result);
 
-        when(result.getParent()).thenReturn(parent);
         when(result.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, "alias"));
 
+        Map<String, Collection<String>> aliasMapBefore = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapBefore.size());
+
+        // this simulates a remove event, but that is immaterial here as there is no cache anyway
         removeAlias(mapEntries, resourceResolver, "/parent", "/parent/child", NOOP);
 
-        Map<String, Collection<String>> aliasMap = mapEntries.getAliasMap("/parent");
-        assertEquals(Collections.emptyMap(), aliasMap);
+        Map<String, Collection<String>> aliasMapAfter = mapEntries.getAliasMap("/parent");
+        assertEquals(1, aliasMapAfter.size());

Review Comment:
   Same answer :-).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org