use of org.apereo.portal.events.PortalEvent in project uPortal by Jasig.
the class PortalRawEventsAggregatorImplTest method aggregateRawEventsIncompleteByReturn.
@Test
public void aggregateRawEventsIncompleteByReturn() throws Exception {
when(transactionOperations.execute(any(TransactionCallback.class))).then(new Answer<EventProcessingResult>() {
@Override
public EventProcessingResult answer(InvocationOnMock invocation) throws Throwable {
final TransactionStatus status = mock(TransactionStatus.class);
return ((TransactionCallback<EventProcessingResult>) invocation.getArguments()[0]).doInTransaction(status);
}
});
when(clusterLockService.isLockOwner(PortalRawEventsAggregator.AGGREGATION_LOCK_NAME)).thenReturn(true);
when(portalEventDimensionPopulator.isCheckedDimensions()).thenReturn(true);
when(eventAggregationManagementDao.getEventAggregatorStatus(ProcessingType.AGGREGATION, true)).thenReturn(eventAggregatorStatus);
when(portalInfoProvider.getUniqueServerName()).thenReturn("serverName_abcd");
when(eventAggregatorStatus.getLastEventDate()).thenReturn(new DateTime(1325881376117l));
when(portalEventDao.aggregatePortalEvents(any(DateTime.class), any(DateTime.class), (int) any(Integer.TYPE), (Function<PortalEvent, Boolean>) any(Function.class))).then(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
return false;
}
});
final EventProcessingResult result = portalEventAggregator.doAggregateRawEvents();
assertNotNull(result);
assertEquals(0, result.getProcessed());
assertEquals(false, result.isComplete());
}
use of org.apereo.portal.events.PortalEvent in project uPortal by Jasig.
the class PortalRawEventsAggregatorImplTest method aggregateRawEventsIncompleteByProcessCount.
@Test
public void aggregateRawEventsIncompleteByProcessCount() throws Exception {
when(transactionOperations.execute(any(TransactionCallback.class))).then(new Answer<EventProcessingResult>() {
@Override
public EventProcessingResult answer(InvocationOnMock invocation) throws Throwable {
final TransactionStatus status = mock(TransactionStatus.class);
return ((TransactionCallback<EventProcessingResult>) invocation.getArguments()[0]).doInTransaction(status);
}
});
when(clusterLockService.isLockOwner(PortalRawEventsAggregator.AGGREGATION_LOCK_NAME)).thenReturn(true);
when(portalEventDimensionPopulator.isCheckedDimensions()).thenReturn(true);
when(eventAggregationManagementDao.getEventAggregatorStatus(ProcessingType.AGGREGATION, true)).thenReturn(eventAggregatorStatus);
when(portalInfoProvider.getUniqueServerName()).thenReturn("serverName_abcd");
when(eventAggregatorStatus.getLastEventDate()).thenReturn(new DateTime(1325881376117l));
when(portalEventDao.aggregatePortalEvents(any(DateTime.class), any(DateTime.class), (int) any(Integer.TYPE), (Function<PortalEvent, Boolean>) any(Function.class))).then(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
((Function<PortalEvent, Boolean>) invocation.getArguments()[3]).apply(new MockPortalEvent(this, "serverName", "eventSessionId", person));
return false;
}
});
when(eventSessionDao.getEventSession(any(PortalEvent.class))).thenReturn(eventSession);
this.portalEventAggregator.setEventAggregationBatchSize(1);
final EventProcessingResult result = portalEventAggregator.doAggregateRawEvents();
assertNotNull(result);
assertEquals(1, result.getProcessed());
assertEquals(false, result.isComplete());
this.portalEventAggregator.setEventAggregationBatchSize(1000);
}
use of org.apereo.portal.events.PortalEvent in project uPortal by Jasig.
the class AnalyticsIncorporationComponent method serializePortletRenderExecutionEvents.
protected String serializePortletRenderExecutionEvents(final Set<PortalEvent> portalEvents) {
//Filter to include just portlet render events
final Map<String, PortletRenderExecutionEvent> renderEvents = new HashMap<String, PortletRenderExecutionEvent>();
for (final PortalEvent portalEvent : portalEvents) {
if (portalEvent instanceof PortletRenderExecutionEvent) {
final PortletRenderExecutionEvent portletRenderEvent = (PortletRenderExecutionEvent) portalEvent;
//Don't write out info for minimized portlets
if (!WindowState.MINIMIZED.equals(portletRenderEvent.getWindowState())) {
final IPortletWindowId portletWindowId = portletRenderEvent.getPortletWindowId();
final String eventKey = portletWindowId != null ? portletWindowId.getStringId() : portletRenderEvent.getFname();
renderEvents.put(eventKey, portletRenderEvent);
}
}
}
try {
return portletEventWriter.writeValueAsString(renderEvents);
} catch (JsonParseException e) {
logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
} catch (JsonMappingException e) {
logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
} catch (IOException e) {
logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
}
return "{}";
}
use of org.apereo.portal.events.PortalEvent in project uPortal by Jasig.
the class UserFilteringPortalEventHandler method supports.
@Override
public boolean supports(E event) {
if (!(event instanceof PortalEvent)) {
return false;
}
//Guest support check
final IPerson person = event.getPerson();
if (person != null && !this.supportGuest && person.isGuest()) {
return false;
}
//userName check
final String userName = event.getUserName();
if (this.supportedUserNames != null && this.supportedUserNames.contains(userName)) {
return true;
}
//ignored userName check
if (this.ignoredUserNames != null && this.ignoredUserNames.contains(userName)) {
return false;
}
//ignored userName pattern check
if (this.ignoredUserNamePatterns != null) {
for (final Pattern ignoredUserNamePattern : this.ignoredUserNamePatterns) {
if (ignoredUserNamePattern.matcher(userName).matches()) {
return false;
}
}
}
return this.supportedUserNames == null || this.supportedUserNames.isEmpty();
}
use of org.apereo.portal.events.PortalEvent in project uPortal by Jasig.
the class PortalRawEventsAggregatorImplTest method aggregateRawEventsComplete.
@Test
public void aggregateRawEventsComplete() throws Exception {
when(transactionOperations.execute(any(TransactionCallback.class))).then(new Answer<EventProcessingResult>() {
@Override
public EventProcessingResult answer(InvocationOnMock invocation) throws Throwable {
final TransactionStatus status = mock(TransactionStatus.class);
return ((TransactionCallback<EventProcessingResult>) invocation.getArguments()[0]).doInTransaction(status);
}
});
when(clusterLockService.isLockOwner(PortalRawEventsAggregator.AGGREGATION_LOCK_NAME)).thenReturn(true);
when(portalEventDimensionPopulator.isCheckedDimensions()).thenReturn(true);
when(eventAggregationManagementDao.getEventAggregatorStatus(ProcessingType.AGGREGATION, true)).thenReturn(eventAggregatorStatus);
when(portalInfoProvider.getUniqueServerName()).thenReturn("serverName_abcd");
when(eventAggregatorStatus.getLastEventDate()).thenReturn(new DateTime(1325881376117l));
when(portalEventDao.aggregatePortalEvents(any(DateTime.class), any(DateTime.class), (int) any(Integer.TYPE), (Function<PortalEvent, Boolean>) any(Function.class))).then(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
return true;
}
});
final EventProcessingResult result = portalEventAggregator.doAggregateRawEvents();
assertNotNull(result);
assertEquals(0, result.getProcessed());
assertEquals(true, result.isComplete());
}
Aggregations