@@ -227,6 +227,66 @@ void testGetDataUrl() throws Exception {
227227 .getDataUrl ());
228228 }
229229
230+ @ Test
231+ void testGetActionWithResourceResolverMapping () throws Exception {
232+ // Create a spy of the resource resolver to mock the map method
233+ org .apache .sling .api .resource .ResourceResolver resourceResolver = Mockito .spy (context .resourceResolver ());
234+
235+ // Mock the map method to return a mapped path
236+ String originalPath = "/adobe/forms/af/submit/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" ;
237+ String mappedPath = "/content/adobe/forms/af/submit/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" ;
238+ Mockito .when (resourceResolver .map ("/adobe/forms/af/submit/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" )).thenReturn (mappedPath );
239+
240+ // Set the mocked resource resolver in the context
241+ context .registerService (org .apache .sling .api .resource .ResourceResolver .class , resourceResolver );
242+
243+ FormContainer formContainer = Utils .getComponentUnderTest (PATH_FORM_1 , FormContainer .class , context );
244+ String action = formContainer .getAction ();
245+
246+ // Verify that the mapped path is used in the action URL
247+ assertTrue (action .contains (mappedPath ));
248+
249+ // Verify that the map method was called with the correct path (called during mock setup + actual execution)
250+ Mockito .verify (resourceResolver , times (2 )).map ("/adobe/forms/af/submit/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" );
251+ }
252+
253+ @ Test
254+ void testGetDataUrlWithResourceResolverMapping () throws Exception {
255+ // Create a spy of the resource resolver to mock the map method
256+ org .apache .sling .api .resource .ResourceResolver resourceResolver = Mockito .spy (context .resourceResolver ());
257+
258+ // Mock the map method to return a mapped path
259+ String originalPath = "/adobe/forms/af/data/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" ;
260+ String mappedPath = "/content/adobe/forms/af/data/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" ;
261+ Mockito .when (resourceResolver .map ("/adobe/forms/af/data/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" )).thenReturn (mappedPath );
262+
263+ // Set the mocked resource resolver in the context
264+ context .registerService (org .apache .sling .api .resource .ResourceResolver .class , resourceResolver );
265+
266+ FormContainer formContainer = Utils .getComponentUnderTest (PATH_FORM_1 , FormContainer .class , context );
267+ String dataUrl = formContainer .getDataUrl ();
268+
269+ // Verify that the mapped path is used in the data URL
270+ assertTrue (dataUrl .contains (mappedPath ));
271+ assertEquals (mappedPath , dataUrl );
272+
273+ // Verify that the map method was called with the correct path (called during mock setup + actual execution)
274+ Mockito .verify (resourceResolver , times (2 )).map ("/adobe/forms/af/data/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" );
275+ }
276+
277+ @ Test
278+ void testResourceResolverMappingIdentityWhenNoMapping () throws Exception {
279+ // Test the case where resourceResolver.map() returns the same path (no mapping configured)
280+ FormContainer formContainer = Utils .getComponentUnderTest (PATH_FORM_1 , FormContainer .class , context );
281+
282+ String action = formContainer .getAction ();
283+ String dataUrl = formContainer .getDataUrl ();
284+
285+ // These should match the original expected values when no mapping is applied
286+ assertEquals ("/adobe/forms/af/submit/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" , action );
287+ assertEquals ("/adobe/forms/af/data/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" , dataUrl );
288+ }
289+
230290 @ Test
231291 void testGetDorProperties () throws Exception {
232292 FormContainer formContainer = Utils .getComponentUnderTest (PATH_FORM_1 , FormContainer .class , context );
@@ -597,6 +657,30 @@ void testCustomFunctionUrl() throws Exception {
597657 assertEquals ("/adobe/forms/af/customfunctions/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" , formContainer .getCustomFunctionUrl ());
598658 }
599659
660+ @ Test
661+ void testGetCustomFunctionUrlWithResourceResolverMapping () throws Exception {
662+ // Create a spy of the resource resolver to mock the map method
663+ org .apache .sling .api .resource .ResourceResolver resourceResolver = Mockito .spy (context .resourceResolver ());
664+
665+ // Mock the map method to return a mapped path
666+ String originalPath = "/adobe/forms/af/customfunctions/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" ;
667+ String mappedPath = "/content/adobe/forms/af/customfunctions/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" ;
668+ Mockito .when (resourceResolver .map ("/adobe/forms/af/customfunctions/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" )).thenReturn (mappedPath );
669+
670+ // Set the mocked resource resolver in the context
671+ context .registerService (org .apache .sling .api .resource .ResourceResolver .class , resourceResolver );
672+
673+ FormContainer formContainer = Utils .getComponentUnderTest (PATH_FORM_1 , FormContainer .class , context );
674+ String customFunctionUrl = formContainer .getCustomFunctionUrl ();
675+
676+ // Verify that the mapped path is used in the custom function URL
677+ assertTrue (customFunctionUrl .contains (mappedPath ));
678+ assertEquals (mappedPath , customFunctionUrl );
679+
680+ // Verify that the map method was called with the correct path (called during mock setup + actual execution)
681+ Mockito .verify (resourceResolver , times (2 )).map ("/adobe/forms/af/customfunctions/L2NvbnRlbnQvZm9ybXMvYWYvZGVtbw==" );
682+ }
683+
600684 @ Test
601685 public void testGetAutoSaveProperties () throws Exception {
602686 context .load ().json (BASE + "/test-content-auto-save.json" , PATH_FORM_WITH_AUTO_SAVE );
0 commit comments