use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class SingleTabUrlNodeSyntaxHelperTest method getPortletForFolderNameFanmeIdTest.
@Test
public void getPortletForFolderNameFanmeIdTest() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final String folder = "fname.id";
final MockPortletEntityId portletEntityId = new MockPortletEntityId("eid");
final MockPortletWindowId portletWindowId = new MockPortletWindowId("wid");
when(this.userInstanceManager.getUserInstance(request)).thenReturn(this.userInstance);
when(this.portletEntityRegistry.getOrCreatePortletEntity(request, userInstance, "id")).thenReturn(portletEntity);
when(this.portletEntity.getPortletDefinition()).thenReturn(portletDefinition);
when(this.portletDefinition.getFName()).thenReturn("fname");
when(this.portletEntity.getPortletEntityId()).thenReturn(portletEntityId);
when(this.portletWindowRegistry.getOrCreateDefaultPortletWindow(request, portletEntityId)).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 testParsePortletParameterName.
@Test
public void testParsePortletParameterName() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final Set<String> ids = ImmutableSet.of("pw2");
final MockPortletWindowId expectedPortletWindowId = new MockPortletWindowId("pw2");
when(this.portletWindowRegistry.getPortletWindowId(request, "pw2")).thenReturn(expectedPortletWindowId);
Tuple<String, IPortletWindowId> portletParameterInfo = this.urlSyntaxProvider.parsePortletParameterName(request, UrlSyntaxProviderImpl.PORTLET_PARAM_PREFIX + "pw2" + UrlSyntaxProviderImpl.SEPARATOR + "foo", ids);
assertNotNull(portletParameterInfo);
assertEquals("foo", portletParameterInfo.first);
assertEquals(expectedPortletWindowId, portletParameterInfo.second);
portletParameterInfo = this.urlSyntaxProvider.parsePortletParameterName(request, UrlSyntaxProviderImpl.PORTLET_PARAM_PREFIX + UrlSyntaxProviderImpl.SEPARATOR + "foo", ids);
assertNotNull(portletParameterInfo);
assertEquals("_foo", portletParameterInfo.first);
assertNull(portletParameterInfo.second);
portletParameterInfo = this.urlSyntaxProvider.parsePortletParameterName(request, UrlSyntaxProviderImpl.PORTLET_PARAM_PREFIX + "pw1" + UrlSyntaxProviderImpl.SEPARATOR + "foo", ids);
assertNotNull(portletParameterInfo);
assertEquals("pw1_foo", portletParameterInfo.first);
assertNull(portletParameterInfo.second);
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderPortletFnameSubscribeIdMaximizedActionUrlGeneration.
@Test
public void testSingleFolderPortletFnameSubscribeIdMaximizedActionUrlGeneration() throws Exception {
final String layoutNodeId = "n2";
final String subscribeId = "s3";
final String fname = "fname";
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
final MockPortletWindowId portletWindowId = new MockPortletWindowId("pw1");
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, portletWindowId)).thenReturn(fname + "." + subscribeId);
when(portletWindowRegistry.getPortletWindow(request, portletWindowId)).thenReturn(portletWindow1);
when(portletWindow1.getPortletEntity()).thenReturn(portletEntity1);
when(portletEntity1.getLayoutNodeId()).thenReturn(subscribeId);
final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, layoutNodeId, portletWindowId, UrlType.ACTION);
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
portletUrlBuilder.setWindowState(WindowState.MAXIMIZED);
final String url = portalUrlBuilder.getUrlString();
assertEquals("/uPortal/f/n2/p/fname.s3/max/action.uP", url);
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderPortletResourceDelegationFnameSubscribeIdResourceUrlParsing.
@Test
public void testSingleFolderPortletResourceDelegationFnameSubscribeIdResourceUrlParsing() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
request.setRequestURI("/f/n2/p/fname.s3/normal/resource.uP");
request.setQueryString("?pP_action=dashboard&pCd_pw2=pw1&pCr_pw2=delegateResourceId&pP_pw2_a=b&pP_pw2_b=c&pCa=pw2");
request.addParameter("pP_action", "dashboard");
request.addParameter("pCa", "pw2");
request.addParameter("pCd_pw2", "pw1");
request.addParameter("pCr_pw2", "delegateResourceId");
request.addParameter("pP_pw2_a", "b");
request.addParameter("pP_pw2_b", "c");
final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("pw1");
final MockPortletWindowId portletWindowId2 = new MockPortletWindowId("pw2");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
when(this.urlNodeSyntaxHelper.getLayoutNodeForFolderNames(request, Arrays.asList("n2"))).thenReturn("n2");
when(this.urlNodeSyntaxHelper.getPortletForFolderName(request, "n2", "fname.s3")).thenReturn(portletWindowId1);
when(this.portletWindowRegistry.getPortletWindowId(request, "pw2")).thenReturn(portletWindowId2);
when(this.portletWindowRegistry.getPortletWindowId(request, "pw1")).thenReturn(portletWindowId1);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
assertNotNull(portalRequestInfo);
assertEquals("n2", portalRequestInfo.getTargetedLayoutNodeId());
assertEquals(portletWindowId1, portalRequestInfo.getTargetedPortletWindowId());
assertEquals(UrlState.NORMAL, portalRequestInfo.getUrlState());
assertEquals(UrlType.RESOURCE, 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("action", Arrays.asList("dashboard")), portletRequestInfo.getPortletParameters());
assertNull(portletRequestInfo.getWindowState());
assertNull(portletRequestInfo.getPortletMode());
assertNull(portletRequestInfo.getDelegateParentWindowId());
assertNull(portletRequestInfo.getResourceId());
final IPortletRequestInfo portletRequestInfo2 = portletRequestInfoMap.get(portletWindowId2);
assertNotNull(portletRequestInfo2);
assertEquals(portletWindowId2, portletRequestInfo2.getPortletWindowId());
assertEquals(ImmutableMap.of("a", Arrays.asList("b"), "b", Arrays.asList("c")), portletRequestInfo2.getPortletParameters());
assertNull(portletRequestInfo2.getWindowState());
assertNull(portletRequestInfo2.getPortletMode());
assertEquals(portletWindowId1, portletRequestInfo2.getDelegateParentWindowId());
assertEquals("delegateResourceId", portletRequestInfo2.getResourceId());
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testLegacyDetachedResourceUrlParsing.
@Test
public void testLegacyDetachedResourceUrlParsing() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
request.setRequestURI("/f/u12l1s5/p/news.u12l1n7/detached/resource.uP");
request.setQueryString("?pCc=cacheLevelPage&pCr=calendar.2012-06-01.7");
request.addParameter("pCc", "cacheLevelPage");
request.addParameter("pCr", "calendar.2012-06-01.7");
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);
}
Aggregations