use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class PortletCacheControlServiceImplTest method testGetCacheControlDefault.
@Test
public void testGetCacheControlDefault() {
MockHttpServletRequest httpRequest = new MockHttpServletRequest();
MockPortletWindowId portletWindowId = new MockPortletWindowId("123");
MockPortletDefinitionId portletDefinitionId = new MockPortletDefinitionId(789);
when(portletDescriptor.getCacheScope()).thenReturn(null);
final IPortletWindowRegistry portletWindowRegistry = mock(IPortletWindowRegistry.class);
final IPortletWindow portletWindow = mock(IPortletWindow.class);
final IPortletEntity portletEntity = mock(IPortletEntity.class);
when(portletWindowRegistry.getPortletWindow(httpRequest, portletWindowId)).thenReturn(portletWindow);
when(portletWindow.getPortletEntity()).thenReturn(portletEntity);
when(portletWindow.getWindowState()).thenReturn(WindowState.NORMAL);
when(portletWindow.getPortletMode()).thenReturn(PortletMode.VIEW);
when(portletEntity.getPortletDefinitionId()).thenReturn(portletDefinitionId);
when(portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId)).thenReturn(portletDescriptor);
final CacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult> cacheState = cacheControlService.getPortletRenderState(httpRequest, portletWindowId);
final CacheControl cacheControl = cacheState.getCacheControl();
assertFalse(cacheControl.isPublicScope());
assertNull(cacheControl.getETag());
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class JpaPortalEventStoreTest method generateEvents.
protected List<PortalEvent> generateEvents() throws Exception {
final String sessionId = "1234567890123_system_AAAAAAAAAAA";
final PortalEvent.PortalEventBuilder eventBuilder = new PortalEvent.PortalEventBuilder(this, "example.com", sessionId, SystemPerson.INSTANCE, null);
final Set<String> groups = ImmutableSet.of("Student", "Employee");
final Map<String, List<String>> attributes = ImmutableMap.of("username", (List<String>) ImmutableList.of("system"), "roles", (List<String>) ImmutableList.of("student", "employee"));
final List<PortalEvent> events = new LinkedList<PortalEvent>();
events.add(new LoginEvent(eventBuilder, groups, attributes));
Thread.sleep(EVENT_DELAY);
events.add(new FolderAddedToLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n32"));
Thread.sleep(EVENT_DELAY);
events.add(new FolderMovedInLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n12", "n32"));
Thread.sleep(EVENT_DELAY);
events.add(new FolderDeletedFromLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n24", "n32", "My Tab"));
Thread.sleep(EVENT_DELAY);
events.add(new PortletAddedToLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n32", "portletA"));
Thread.sleep(EVENT_DELAY);
events.add(new PortletMovedInLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n32", "n24", "portletA"));
Thread.sleep(EVENT_DELAY);
events.add(new PortletDeletedFromLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n24", "portletA"));
final PortletExecutionEvent.PortletExecutionEventBuilder portletExecutionEventBuilder = new PortletExecutionEvent.PortletExecutionEventBuilder(eventBuilder, new MockPortletWindowId("pw1"), "fname", 12345, Collections.EMPTY_MAP, WindowState.NORMAL, PortletMode.VIEW);
Thread.sleep(EVENT_DELAY);
events.add(new PortletActionExecutionEvent(portletExecutionEventBuilder));
Thread.sleep(EVENT_DELAY);
events.add(new PortletEventExecutionEvent(portletExecutionEventBuilder, new QName("http://www.jasig.org/foo", "event", "e")));
Thread.sleep(EVENT_DELAY);
events.add(new PortletRenderExecutionEvent(portletExecutionEventBuilder, true, false));
Thread.sleep(EVENT_DELAY);
events.add(new PortletResourceExecutionEvent(portletExecutionEventBuilder, "someImage.jpg", false, false));
Thread.sleep(EVENT_DELAY);
events.add(new LogoutEvent(eventBuilder));
return events;
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderPortletDelegationFnameSubscribeIdMinimizedRenderUrlGeneration.
@Test
public void testSingleFolderPortletDelegationFnameSubscribeIdMinimizedRenderUrlGeneration() 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.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&pCd_pw2=pw1&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 testLegacyPortletUrlParsingNoParams.
@Test
public void testLegacyPortletUrlParsingNoParams() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/portal");
request.setRequestURI("/render.userLayoutRootNode.uP");
request.setQueryString("?uP_fname=contact-information");
request.addParameter("uP_fname", "contact-information");
final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("u110l1n41");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, "contact-information")).thenReturn(this.portletWindow1);
when(this.portletWindow1.getPortletWindowId()).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.RENDER, portalRequestInfo.getUrlType());
final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
assertNotNull(portletRequestInfoMap);
assertEquals(1, portletRequestInfoMap.size());
final IPortletRequestInfo portletRequestInfo = portletRequestInfoMap.get(portletWindowId1);
assertNotNull(portletRequestInfo);
assertEquals(portletWindowId1, portletRequestInfo.getPortletWindowId());
assertEquals(Collections.emptyMap(), portletRequestInfo.getPortletParameters());
assertEquals(WindowState.MAXIMIZED, portletRequestInfo.getWindowState());
assertNull(portletRequestInfo.getDelegateParentWindowId());
}
use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderPortletFnameSubscribeIdMinimizedRenderUrlGeneration.
@Test
public void testSingleFolderPortletFnameSubscribeIdMinimizedRenderUrlGeneration() 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.RENDER);
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
portletUrlBuilder.setWindowState(WindowState.MINIMIZED);
portletUrlBuilder.setParameter("action", "dashboard");
final String url = portalUrlBuilder.getUrlString();
assertEquals("/uPortal/f/n2/normal/render.uP?pCt=fname.s3&pCs=minimized&pP_action=dashboard", url);
}
Aggregations