portletUrlSyntaxProvider.setPortalRequestUtils(portalRequestUtils);
final IPortletEntityId portletEntityId1 = new MockPortletEntityId("eId1");
final IPortletWindowId portletWindowId1 = new MockPortletWindowId("wId1");
final IPortletWindow portletWindow1 = new MockPortletWindow(portletWindowId1, portletEntityId1, "portletAppA", "portletNameA");
final IPortletEntityId portletEntityId2 = new MockPortletEntityId("eId2");
final IPortletWindowId portletWindowId2 = new MockPortletWindowId("wId2");
final MockPortletWindow portletWindow2 = new MockPortletWindow(portletWindowId2, portletEntityId2, "portletAppB", "portletNameB");
final IPortletEntityId portletEntityId3 = new MockPortletEntityId("eId3");
final IPortletWindowId portletWindowId3 = new MockPortletWindowId("wId3");
final MockPortletWindow portletWindow3 = new MockPortletWindow(portletWindowId3, portletEntityId3, "portletAppC", "portletNameC");
final ChannelRuntimeData channelRuntimeData = new ChannelRuntimeData();
channelRuntimeData.setBaseActionURL("base/action.url");
request.setAttribute(IPortletAdaptor.ATTRIBUTE__RUNTIME_DATA, channelRuntimeData);
final MockPortletEntity portletEntity1 = new MockPortletEntity();
portletEntity1.setPortletEntityId(portletEntityId1);
portletEntity1.setChannelSubscribeId(portletEntityId1.getStringId());
final MockPortletEntity portletEntity2 = new MockPortletEntity();
portletEntity2.setPortletEntityId(portletEntityId2);
portletEntity2.setChannelSubscribeId(portletEntityId2.getStringId());
final MockPortletEntity portletEntity3 = new MockPortletEntity();
portletEntity3.setPortletEntityId(portletEntityId3);
portletEntity3.setChannelSubscribeId(portletEntityId3.getStringId());
final IPortletWindowRegistry portletWindowRegistry = createMock(IPortletWindowRegistry.class);
expect(portletWindowRegistry.getParentPortletEntity(request, portletWindowId1))
.andReturn(portletEntity1)
.anyTimes();
expect(portletWindowRegistry.getParentPortletEntity(request, portletWindowId2))
.andReturn(portletEntity2)
.anyTimes();
expect(portletWindowRegistry.getParentPortletEntity(request, portletWindowId3))
.andReturn(portletEntity3)
.anyTimes();
expect(portletWindowRegistry.isTransient(request, portletWindowId3))
.andReturn(true)
.anyTimes();
expect(portletWindowRegistry.isTransient(request, portletWindowId2))
.andReturn(true)
.anyTimes();
expect(portletWindowRegistry.isTransient(request, portletWindowId1))
.andReturn(false)
.anyTimes();
expect(portletWindowRegistry.getDefaultPortletWindowId(portletEntityId1))
.andReturn(portletWindowId1)
.anyTimes();
expect(portletWindowRegistry.getPortletWindow(request, portletWindowId1))
.andReturn(portletWindow1)
.anyTimes();
expect(portletWindowRegistry.getPortletWindow(request, portletWindowId2))
.andReturn(portletWindow2)
.anyTimes();
final IPortletDelegationManager portletDelegationManager = createMock(IPortletDelegationManager.class);
final PortletUrl portletUrl1 = new PortletUrl(portletWindowId1);
final Map<String, List<String>> urlParameters1 = new LinkedHashMap<String, List<String>>();
urlParameters1.put("newKey1", Arrays.asList(new String[] { "newValue1.1", "newValue1.2" }) );
urlParameters1.put("newKey2", Arrays.asList(new String[] { "newValue2.1" }) );
urlParameters1.put("newKey3", Arrays.asList(new String[] { "" }) );
portletUrl1.setParameters(urlParameters1);
expect(portletDelegationManager.getParentPortletUrl(request, portletWindowId1))
.andReturn(portletUrl1);
final PortletUrl portletUrl2 = new PortletUrl(portletWindowId2);
final Map<String, List<String>> urlParameters2 = new LinkedHashMap<String, List<String>>();
urlParameters2.put("newKeyA", Arrays.asList(new String[] { "newValueA.A", "newValueA.B" }) );
urlParameters2.put("newKeyB", Arrays.asList(new String[] { "newValueB.A" }) );
portletUrl2.setParameters(urlParameters2);
portletUrl2.setPortletMode(PortletMode.VIEW);
expect(portletDelegationManager.getParentPortletUrl(request, portletWindowId2))
.andReturn(portletUrl2);
replay(portletDelegationManager, portalRequestUtils, portletWindowRegistry);
portletUrlSyntaxProvider.setPortletWindowRegistry(portletWindowRegistry);
portletUrlSyntaxProvider.setPortletDelegationManager(portletDelegationManager);
//Setup portlet window 1
portletWindow1.setWindowState(WindowState.MAXIMIZED);
portletWindow1.setPortletMode(PortletMode.VIEW);
final Map<String, List<String>> parameters1 = new LinkedHashMap<String, List<String>>();
parameters1.put("key1", Arrays.asList(new String[] { "value1.1", "value1.2" }) );
parameters1.put("key2", Arrays.asList(new String[] { "value2.1" }) );
parameters1.put("key3", Arrays.asList(new String[] { "" }) );
portletWindow1.setRequestParameters(parameters1);
//Setup delegation (wId1 delegates to wId2)
portletWindow2.setDelegationParent(portletWindowId1);
portletWindow2.setWindowState(WindowState.MAXIMIZED);
portletWindow2.setPortletMode(IPortletAdaptor.CONFIG);
final Map<String, List<String>> parameters2 = new LinkedHashMap<String, List<String>>();
parameters2.put("keyA", Arrays.asList(new String[] { "valueA.A", "valueA.B" }) );
parameters2.put("keyB", Arrays.asList(new String[] { "valueB.A" }) );
portletWindow2.setRequestParameters(parameters2);
//Setup delegation (wId2 delegates to wId3)
portletWindow3.setDelegationParent(portletWindowId2);
final PortletUrl portletUrl = new PortletUrl(portletWindowId1);
final Map<String, List<String>> parameters3 = new LinkedHashMap<String, List<String>>();
parameters3.put("key3", Arrays.asList(new String[] { "value3.1", "value3.2" }) );