PortletHungEvent(PortalEventBuilder eventBuilder, IPortletExecutionWorker<?> worker) { super(eventBuilder); this.worker = worker; this.fname = worker.getPortletFname(); }
@Test public void verifyOutputFormat() throws Exception { final String sessionId = "1234567890123_system_AAAAAAAAAAA"; final PortalEvent.PortalEventBuilder eventBuilder = new PortalEvent.PortalEventBuilder( this, "example.com", sessionId, SystemPerson.INSTANCE, null); final PortletExecutionEvent.PortletExecutionEventBuilder portletExecutionEventBuilder = new PortletExecutionEvent.PortletExecutionEventBuilder( eventBuilder, new MockPortletWindowId("pw1"), "fname", 12345, Collections.EMPTY_MAP, WindowState.NORMAL, PortletMode.VIEW); PortalEvent event; // TODO: Will uncomment once we add in attribute swapper event processing. /*event = new AttributeSwapEvent(eventBuilder, Collections.EMPTY_MAP); assertEventJsonEquals("{\"@c\":\".AttributeSwapEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"swappedAttributes\":{}}", event); event = new AttributeSwapResetEvent(eventBuilder); assertEventJsonEquals("{\"@c\":\".AttributeSwapResetEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\"}", event); event = new IdentitySwapStartEvent(eventBuilder, "originalUserName", "originalEventSessionId"); assertEventJsonEquals("{\"@c\":\".IdentitySwapStartEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"originalUserName\":\"originalUserName\",\"originalEventSessionId\":\"originalEventSessionId\"}", event); event = new IdentitySwapStopEvent(eventBuilder, "targetUserName"); assertEventJsonEquals("{\"@c\":\".IdentitySwapStopEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"targetUserName\":\"targetUserName\"}", event); */ event = new FolderAddedToLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "newFolderId"); assertEventJsonEquals( "{\"@c\":\".FolderAddedToLayoutPortalEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"layoutId\":1,\"layoutOwner\":\"system\",\"newFolderId\":\"newFolderId\"}", event); event = new FolderDeletedFromLayoutPortalEvent( eventBuilder, SystemPerson.INSTANCE, 1, "oldParentFolderId", "deletedFolderId", "deletedFolderName"); assertEventJsonEquals( "{\"@c\":\".FolderDeletedFromLayoutPortalEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"layoutId\":1,\"layoutOwner\":\"system\",\"oldParentFolderId\":\"oldParentFolderId\",\"deletedFolderId\":\"deletedFolderId\",\"deletedFolderName\":\"deletedFolderName\"}", event); event = new FolderMovedInLayoutPortalEvent( eventBuilder, SystemPerson.INSTANCE, 1, "oldParentFolderId", "movedFolderId"); assertEventJsonEquals( "{\"@c\":\".FolderMovedInLayoutPortalEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"layoutId\":1,\"layoutOwner\":\"system\",\"oldParentFolderId\":\"oldParentFolderId\",\"movedFolderId\":\"movedFolderId\"}", event); event = new PortletAddedToLayoutPortalEvent( eventBuilder, SystemPerson.INSTANCE, 1, "parentFolderId", "fname"); assertEventJsonEquals( "{\"@c\":\".PortletAddedToLayoutPortalEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"layoutId\":1,\"layoutOwner\":\"system\",\"fname\":\"fname\",\"parentFolderId\":\"parentFolderId\"}", event); event = new PortletDeletedFromLayoutPortalEvent( eventBuilder, SystemPerson.INSTANCE, 1, "oldParentFolderId", "fname"); assertEventJsonEquals( "{\"@c\":\".PortletDeletedFromLayoutPortalEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"layoutId\":1,\"layoutOwner\":\"system\",\"fname\":\"fname\",\"oldParentFolderId\":\"oldParentFolderId\"}", event); event = new PortletMovedInLayoutPortalEvent( eventBuilder, SystemPerson.INSTANCE, 1, "oldParentFolderId", "newParentFolderId", "fname"); assertEventJsonEquals( "{\"@c\":\".PortletMovedInLayoutPortalEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"layoutId\":1,\"layoutOwner\":\"system\",\"fname\":\"fname\",\"oldParentFolderId\":\"oldParentFolderId\",\"newParentFolderId\":\"newParentFolderId\"}", event); event = new LoginEvent(eventBuilder, Collections.EMPTY_SET, Collections.EMPTY_MAP); assertEventJsonEquals( "{\"@c\":\".LoginEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"groups\":[],\"attributes\":{}}", event); event = new LogoutEvent(eventBuilder); assertEventJsonEquals( "{\"@c\":\".LogoutEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\"}", event); event = new PortalRenderEvent( eventBuilder, "requestPathInfo", 12345, UrlState.NORMAL, UrlType.RENDER, Collections.EMPTY_MAP, "targetedLayoutNodeId"); assertEventJsonEquals( "{\"@c\":\".PortalRenderEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"requestPathInfo\":\"requestPathInfo\",\"urlState\":\"NORMAL\",\"urlType\":\"RENDER\",\"parameters\":{},\"targetedLayoutNodeId\":\"targetedLayoutNodeId\",\"executionTimeNano\":12345}", event); event = new PortletActionExecutionEvent(portletExecutionEventBuilder); assertEventJsonEquals( "{\"@c\":\".PortletActionExecutionEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"fname\":\"fname\",\"windowState\":\"normal\",\"portletMode\":\"view\",\"executionTimeNano\":12345,\"parameters\":{}}", event); event = new PortletEventExecutionEvent( portletExecutionEventBuilder, new QName("http://example.com/uri", "EventName")); assertEventJsonEquals( "{\"@c\":\".PortletEventExecutionEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"fname\":\"fname\",\"windowState\":\"normal\",\"portletMode\":\"view\",\"executionTimeNano\":12345,\"parameters\":{},\"eventName\":\"{http://example.com/uri}EventName\"}", event); event = new PortletRenderExecutionEvent(portletExecutionEventBuilder, true, false); assertEventJsonEquals( "{\"@c\":\".PortletRenderExecutionEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"fname\":\"fname\",\"windowState\":\"normal\",\"portletMode\":\"view\",\"executionTimeNano\":12345,\"parameters\":{},\"targeted\":true,\"usedPortalCache\":false}", event); event = new PortletRenderHeaderExecutionEvent(portletExecutionEventBuilder, true, false); assertEventJsonEquals( "{\"@c\":\".PortletRenderHeaderExecutionEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"fname\":\"fname\",\"windowState\":\"normal\",\"portletMode\":\"view\",\"executionTimeNano\":12345,\"parameters\":{},\"targeted\":true,\"cached\":false}", event); event = new PortletResourceExecutionEvent(portletExecutionEventBuilder, "resourceId", false, false); assertEventJsonEquals( "{\"@c\":\".PortletResourceExecutionEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"fname\":\"fname\",\"windowState\":\"normal\",\"portletMode\":\"view\",\"executionTimeNano\":12345,\"parameters\":{},\"resourceId\":\"resourceId\",\"usedBrowserCache\":false,\"usedPortalCache\":false}", event); final IPortletExecutionWorker hungWorker = mock(IPortletExecutionWorker.class); when(hungWorker.getPortletFname()).thenReturn("fname"); event = new PortletHungCompleteEvent(eventBuilder, hungWorker); assertEventJsonEquals( "{\"@c\":\".PortletHungCompleteEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"fname\":\"fname\"}", event); event = new PortletHungEvent(eventBuilder, hungWorker); assertEventJsonEquals( "{\"@c\":\".PortletHungEvent\",\"timestamp\":1371745598080,\"serverId\":\"example.com\",\"eventSessionId\":\"1234567890123_system_AAAAAAAAAAA\",\"userName\":\"system\",\"fname\":\"fname\"}", event); }