### Question:
PageMappingService { public PageReference getPage(final HttpServletRequest request, final APISession apiSession, final String mappingKey, final Locale locale, final boolean executeAuthorizationRules) throws BonitaException { final Map<String, Serializable> context = new HashMap<>(); Map<String, String[]> parametersMapCopy = request.getParameterMap().entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().clone())); context.put(URLAdapterConstants.QUERY_PARAMETERS, (Serializable) parametersMapCopy); context.put(AuthorizationRuleConstants.IS_ADMIN, isLoggedUserAdmin(request)); context.put(URLAdapterConstants.LOCALE, locale.toString()); context.put(URLAdapterConstants.CONTEXT_PATH, request.getContextPath()); final PageAPI pageAPI = getPageAPI(apiSession); final PageURL pageURL = pageAPI.resolvePageOrURL(mappingKey, context, executeAuthorizationRules); return new PageReference(pageURL.getPageId(), pageURL.getUrl()); }  PageReference getPage(final HttpServletRequest request, final APISession apiSession, final String mappingKey, final Locale locale,
            final boolean executeAuthorizationRules);  }### Answer:
@SuppressWarnings("unchecked") @Test public void getPage() throws Exception { final PageURL pageURL = mock(PageURL.class); when(pageURL.getUrl()).thenReturn("/externalURL"); when(pageURL.getPageId()).thenReturn(null); ArgumentCaptor<Map> contextCaptor = ArgumentCaptor.forClass(Map.class); when(pageAPI.resolvePageOrURL(eq("process/processName/processVersion"), anyMap(), eq(true))).thenReturn(pageURL); final Set<String> userPermissions = new HashSet<>(); when(httpSession.getAttribute(SessionUtil.PERMISSIONS_SESSION_PARAM_KEY)).thenReturn(userPermissions); final PageReference returnedPageReference = pageMappingService.getPage(hsRequest, apiSession, "process/processName/processVersion", new Locale("en"), true); verify(pageAPI).resolvePageOrURL(eq("process/processName/processVersion"), contextCaptor.capture(), eq(true)); Map<String, Serializable> capturedContext = contextCaptor.getValue(); assertEquals("/bonita", (String)capturedContext.get(URLAdapterConstants.CONTEXT_PATH)); assertEquals("en", (String)capturedContext.get(URLAdapterConstants.LOCALE)); assertEquals(false, (Boolean)capturedContext.get(AuthorizationRuleConstants.IS_ADMIN)); assertEquals("value", ((Map<String, String[]>)capturedContext.get(URLAdapterConstants.QUERY_PARAMETERS)).get("key")[0]); assertNotNull(returnedPageReference); assertEquals(null, returnedPageReference.getPageId()); assertEquals("/externalURL", returnedPageReference.getURL()); }