use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class SingleTabUrlNodeSyntaxHelperTest method getPortletForFolderNameFnameTest.
@Test
public void getPortletForFolderNameFnameTest() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final String folder = "fname";
final MockPortletWindowId portletWindowId = new MockPortletWindowId("wid");
when(this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, folder)).thenReturn(portletWindow);
when(portletWindow.getPortletWindowId()).thenReturn(portletWindowId);
final IPortletWindowId parsedPortletWindowId = this.urlNodeSyntaxHelper.getPortletForFolderName(request, null, folder);
assertNotNull(parsedPortletWindowId);
assertEquals(portletWindowId, parsedPortletWindowId);
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderPortletDelegationFnameSubscribeIdMinimizedRenderUrlParsingTwo.
@Test
public void testSingleFolderPortletDelegationFnameSubscribeIdMinimizedRenderUrlParsingTwo() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
request.setRequestURI("/p/portlet-admin.ctf3/max/action.uP");
request.setQueryString("?pCa=71_dlg-44-ctf3-8_8&pCd_71_dlg-44-ctf3-8_8=44_ctf3_8&pP_71_dlg-44-ctf3-8_8_action=updateKey&pP_execution=e4s4&pP__eventId=configModeAction");
request.addParameter("pCa", "71_dlg-44-ctf3-8_8");
request.addParameter("pCd_71_dlg-44-ctf3-8_8", "44_ctf3_8");
request.addParameter("pP_71_dlg-44-ctf3-8_8_action", "updateKey");
request.addParameter("pP_execution", "e4s4");
request.addParameter("pP__eventId", "configModeAction");
request.addParameter("googleApiKey", "12345");
final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("44_ctf3_8");
final MockPortletWindowId portletWindowId2 = new MockPortletWindowId("71_dlg-44-ctf3-8_8");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
when(this.urlNodeSyntaxHelper.getPortletForFolderName(request, null, "portlet-admin.ctf3")).thenReturn(portletWindowId1);
when(this.portletWindowRegistry.getPortletWindowId(request, "71_dlg-44-ctf3-8_8")).thenReturn(portletWindowId2);
when(this.portletWindowRegistry.getPortletWindowId(request, "44_ctf3_8")).thenReturn(portletWindowId1);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
assertNotNull(portalRequestInfo);
assertNull(portalRequestInfo.getTargetedLayoutNodeId());
assertEquals(portletWindowId1, portalRequestInfo.getTargetedPortletWindowId());
assertEquals(UrlState.MAX, portalRequestInfo.getUrlState());
assertEquals(UrlType.ACTION, portalRequestInfo.getUrlType());
final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
assertNotNull(portletRequestInfoMap);
assertEquals(2, portletRequestInfoMap.size());
final IPortletRequestInfo portletRequestInfo = portletRequestInfoMap.get(portletWindowId1);
assertNotNull(portletRequestInfo);
assertEquals(portletWindowId1, portletRequestInfo.getPortletWindowId());
assertEquals(ImmutableMap.of("execution", Arrays.asList("e4s4"), "_eventId", Arrays.asList("configModeAction")), portletRequestInfo.getPortletParameters());
assertEquals(WindowState.MAXIMIZED, portletRequestInfo.getWindowState());
assertNull(portletRequestInfo.getPortletMode());
assertNull(portletRequestInfo.getDelegateParentWindowId());
final IPortletRequestInfo portletRequestInfo2 = portletRequestInfoMap.get(portletWindowId2);
assertNotNull(portletRequestInfo2);
assertEquals(portletWindowId2, portletRequestInfo2.getPortletWindowId());
assertEquals(ImmutableMap.of("action", Arrays.asList("updateKey"), "googleApiKey", Arrays.asList("12345")), portletRequestInfo2.getPortletParameters());
assertNull(portletRequestInfo2.getWindowState());
assertNull(portletRequestInfo2.getPortletMode());
assertEquals(portletWindowId1, portletRequestInfo2.getDelegateParentWindowId());
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderMultiplePortletFnameSubscribeIdMinimizedRenderUrlGeneration.
@Test
public void testSingleFolderMultiplePortletFnameSubscribeIdMinimizedRenderUrlGeneration() throws Exception {
final String layoutNodeId = "n2";
final String subscribeId = "s3";
final String fname = "fname";
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("pw1");
final MockPortletWindowId portletWindowId2 = new MockPortletWindowId("pw2");
when(portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
when(urlNodeSyntaxHelper.getFolderNamesForLayoutNode(request, subscribeId)).thenReturn(Arrays.asList(layoutNodeId));
when(urlNodeSyntaxHelper.getFolderNameForPortlet(request, portletWindowId1)).thenReturn(fname + "." + subscribeId);
when(portletWindowRegistry.getPortletWindow(request, portletWindowId1)).thenReturn(portletWindow1);
when(portletWindowRegistry.getPortletWindow(request, portletWindowId2)).thenReturn(portletWindow2);
when(portletWindow1.getPortletEntity()).thenReturn(portletEntity1);
when(portletEntity1.getLayoutNodeId()).thenReturn(subscribeId);
final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, layoutNodeId, portletWindowId1, UrlType.RENDER);
final IPortletUrlBuilder portletUrlBuilder1 = portalUrlBuilder.getPortletUrlBuilder(portletWindowId1);
portletUrlBuilder1.setWindowState(WindowState.MINIMIZED);
portletUrlBuilder1.setParameter("action", "dashboard");
final IPortletUrlBuilder portletUrlBuilder2 = portalUrlBuilder.getPortletUrlBuilder(portletWindowId2);
portletUrlBuilder2.setParameter("a", "b");
portletUrlBuilder2.setParameter("b", "c");
portletUrlBuilder2.setPortletMode(PortletMode.HELP);
final String url = portalUrlBuilder.getUrlString();
assertEquals("/uPortal/f/n2/normal/render.uP?pCt=fname.s3&pCs=minimized&pP_action=dashboard&pCm_pw2=help&pP_pw2_a=b&pP_pw2_b=c&pCa=pw2", url);
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testDetachedResourceUrlParsing.
@Test
public void testDetachedResourceUrlParsing() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
request.setRequestURI("/f/u12l1s5/p/news.u12l1n7/detached/calendar.2012-06-01.7.resource.uP");
request.setQueryString("?pCc=cacheLevelPage");
request.addParameter("pCc", "cacheLevelPage");
final MockPortletWindowId portletWindowId = new MockPortletWindowId("s3");
final MockPortletWindowId detachedPortletWindowId = new MockPortletWindowId("d3");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
when(this.urlNodeSyntaxHelper.getLayoutNodeForFolderNames(request, Arrays.asList("u12l1s5"))).thenReturn("u12l1s5");
when(this.urlNodeSyntaxHelper.getPortletForFolderName(request, "u12l1s5", "news.u12l1n7")).thenReturn(portletWindowId);
when(this.portletWindowRegistry.getOrCreateStatelessPortletWindow(request, portletWindowId)).thenReturn(portletWindow1);
when(portletWindow1.getPortletWindowId()).thenReturn(detachedPortletWindowId);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
assertNotNull(portalRequestInfo);
assertEquals("u12l1s5", portalRequestInfo.getTargetedLayoutNodeId());
assertEquals(detachedPortletWindowId, portalRequestInfo.getTargetedPortletWindowId());
assertEquals(UrlState.DETACHED, portalRequestInfo.getUrlState());
assertEquals(UrlType.RESOURCE, portalRequestInfo.getUrlType());
final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
assertNotNull(portletRequestInfoMap);
assertEquals(1, portletRequestInfoMap.size());
final IPortletRequestInfo portletRequestInfo = portletRequestInfoMap.get(detachedPortletWindowId);
assertNotNull(portletRequestInfo);
assertEquals(detachedPortletWindowId, portletRequestInfo.getPortletWindowId());
assertEquals(Collections.EMPTY_MAP, portletRequestInfo.getPortletParameters());
assertEquals(IPortletRenderer.DETACHED, portletRequestInfo.getWindowState());
assertNull(portletRequestInfo.getPortletMode());
assertEquals(ResourceURL.PAGE, portletRequestInfo.getCacheability());
assertEquals("calendar.2012-06-01.7", portletRequestInfo.getResourceId());
final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, "u12l1s5", detachedPortletWindowId, UrlType.RESOURCE);
when(this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, detachedPortletWindowId, UrlType.RESOURCE)).thenReturn(portalUrlBuilder);
when(this.portletWindowRegistry.getPortletWindow(request, detachedPortletWindowId)).thenReturn(portletWindow2);
when(portletWindow2.getPortletEntity()).thenReturn(portletEntity1);
when(portletEntity1.getLayoutNodeId()).thenReturn("u12l1s5");
when(urlNodeSyntaxHelper.getFolderNameForPortlet(request, detachedPortletWindowId)).thenReturn("news.u12l1n7");
when(urlNodeSyntaxHelper.getFolderNamesForLayoutNode(request, "u12l1s5")).thenReturn(Collections.singletonList("u12l1s5"));
final String canonicalUrl = this.urlSyntaxProvider.getCanonicalUrl(request);
assertEquals("/uPortal/f/u12l1s5/p/news.u12l1n7/detached/calendar.2012-06-01.7.resource.uP?pCc=cacheLevelPage", canonicalUrl);
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderPortletResourceDelegationFnameSubscribeIdResourceUrlGeneration.
@Test
public void testSingleFolderPortletResourceDelegationFnameSubscribeIdResourceUrlGeneration() throws Exception {
final String layoutNodeId = "n2";
final String subscribeId1 = "s3";
final String subscribeId2 = "dlg-71-44";
final String fname = "fname";
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("pw1");
final MockPortletWindowId portletWindowId2 = new MockPortletWindowId("pw2");
when(portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
when(urlNodeSyntaxHelper.getFolderNamesForLayoutNode(request, subscribeId1)).thenReturn(Arrays.asList(layoutNodeId));
when(urlNodeSyntaxHelper.getFolderNameForPortlet(request, portletWindowId1)).thenReturn(fname + "." + subscribeId1);
when(portletWindowRegistry.getPortletWindow(request, portletWindowId1)).thenReturn(portletWindow1);
when(portletWindow1.getPortletEntity()).thenReturn(portletEntity1);
when(portletEntity1.getLayoutNodeId()).thenReturn(subscribeId1);
when(portletWindowRegistry.getPortletWindow(request, portletWindowId2)).thenReturn(portletWindow2);
when(portletWindow2.getPortletEntity()).thenReturn(portletEntity2);
when(portletWindow2.getDelegationParentId()).thenReturn(portletWindowId1);
when(portletEntity2.getLayoutNodeId()).thenReturn(subscribeId2);
final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, layoutNodeId, portletWindowId1, UrlType.RESOURCE);
final IPortletUrlBuilder portletUrlBuilder1 = portalUrlBuilder.getPortletUrlBuilder(portletWindowId1);
portletUrlBuilder1.setWindowState(WindowState.NORMAL);
portletUrlBuilder1.setParameter("action", "dashboard");
final IPortletUrlBuilder portletUrlBuilder2 = portalUrlBuilder.getPortletUrlBuilder(portletWindowId2);
portletUrlBuilder2.setParameter("a", "b");
portletUrlBuilder2.setParameter("b", "c");
portletUrlBuilder2.setPortletMode(PortletMode.HELP);
portletUrlBuilder2.setResourceId("delegateResourceId");
final String url = portalUrlBuilder.getUrlString();
assertEquals("/uPortal/f/n2/p/fname.s3/normal/resource.uP?pP_action=dashboard&pCd_pw2=pw1&pCr_pw2=delegateResourceId&pP_pw2_a=b&pP_pw2_b=c&pCa=pw2", url);
}
Aggregations