Copilot commented on code in PR #78:
URL: 
https://github.com/apache/sling-org-apache-sling-api/pull/78#discussion_r3079601539


##########
src/test/java/org/apache/sling/api/uri/SlingUriRebaseTest.java:
##########
@@ -310,4 +312,62 @@ public void testRebaseNotAllowedWithoutResolver() throws 
URISyntaxException {
         String testPath = "/path/to/page.html";
         SlingUriBuilder.parse(testPath, null).rebaseResourcePath().build();
     }
+
+    @Test
+    public void testRebaseResourcePathWithTrailingSlashResourceExists() {
+        // path with trailing slash, resource exists at path without trailing 
slash
+        when(resolver.getResource("/apidocs/sling12")).thenReturn(resource);
+        SlingUri slingUri = SlingUriBuilder.parse("/apidocs/sling12/", 
resolver).build();
+        assertNotNull(slingUri);
+        assertEquals("/apidocs/sling12", slingUri.getResourcePath());
+        assertEquals(null, slingUri.getSelectorString());
+        assertEquals(null, slingUri.getExtension());
+        assertEquals(null, slingUri.getSuffix());

Review Comment:
   `assertEquals(null, ...)` should be replaced with `assertNull(...)` for 
clearer intent and better failure messages (JUnit reports expected/actual more 
cleanly for null checks). Consider importing `assertNull` and using it for 
these null assertions.



##########
src/test/java/org/apache/sling/api/uri/SlingUriRebaseTest.java:
##########
@@ -310,4 +312,62 @@ public void testRebaseNotAllowedWithoutResolver() throws 
URISyntaxException {
         String testPath = "/path/to/page.html";
         SlingUriBuilder.parse(testPath, null).rebaseResourcePath().build();
     }
+
+    @Test
+    public void testRebaseResourcePathWithTrailingSlashResourceExists() {
+        // path with trailing slash, resource exists at path without trailing 
slash
+        when(resolver.getResource("/apidocs/sling12")).thenReturn(resource);
+        SlingUri slingUri = SlingUriBuilder.parse("/apidocs/sling12/", 
resolver).build();

Review Comment:
   This test relies on the internal lookup behavior (i.e., that the resolver 
lookup will occur for `"/apidocs/sling12"` and not `"/apidocs/sling12/"`). To 
make the test less brittle against implementation changes, stub both variants 
(with and without trailing slash) or use a single stub that normalizes the 
argument and returns `resource` for either input.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to