use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean in project entando-core by entando.
the class TestActivityStream method testLogAddPage.
public void testLogAddPage() throws Throwable {
String pageCode = "activity_stream_test_test";
try {
this.addPage(pageCode);
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.size());
ActionLogRecord record = this._actionLoggerManager.getActionRecord(ids.get(0));
assertEquals("/do/Page", record.getNamespace());
assertEquals("save", record.getActionName());
ActivityStreamInfo asi = record.getActivityStreamInfo();
assertNotNull(asi);
assertEquals(1, asi.getActionType());
assertEquals("edit", asi.getLinkActionName());
assertEquals("/do/Page", asi.getLinkNamespace());
Properties parameters = asi.getLinkParameters();
assertEquals(1, parameters.size());
assertEquals(pageCode, parameters.getProperty("selectedNode"));
} catch (Throwable t) {
throw t;
} finally {
this._pageManager.deletePage(pageCode);
}
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean in project entando-core by entando.
the class TestActivityStreamAction method testActivityStreamSearchBean.
public void testActivityStreamSearchBean() throws Throwable {
// "coach" group
Content content = this._contentManager.loadContent("EVN41", false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
content.setId(null);
String contentId = null;
Date dateBeforeSave = new Date();
Thread.sleep(1000);
try {
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
Date firstDate = new Date();
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.size());
ActionLogRecord firstRecord = this._actionLoggerManager.getActionRecord(ids.get(0));
ActivityStreamSeachBean activityStreamSeachBean = new ActivityStreamSeachBean();
activityStreamSeachBean.setEndUpdate(firstDate);
List<Integer> activityStreamEndDate = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
assertEquals(1, activityStreamEndDate.size());
Thread.sleep(1000);
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
activityStreamSeachBean = new ActivityStreamSeachBean();
activityStreamSeachBean.setEndUpdate(new Date());
List<Integer> activityStreamBetweenSave2 = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
assertEquals(2, activityStreamBetweenSave2.size());
String firstDateString = DateConverter.getFormattedDate(firstDate, ApsAdminSystemConstants.CALENDAR_TIMESTAMP_PATTERN);
this.initActivityStreamAction("/do/ActivityStream", "update", firstDateString);
this.setUserOnSession("admin");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
ActivityStreamAction activityStreamAction = (ActivityStreamAction) this.getAction();
List<Integer> update = activityStreamAction.getActionRecordIds();
assertEquals(1, update.size());
ActionLogRecord updateRecord = this._actionLoggerManager.getActionRecord(update.get(0));
String actionRecordDate = DateConverter.getFormattedDate(updateRecord.getActionDate(), ApsAdminSystemConstants.CALENDAR_TIMESTAMP_PATTERN);
this.initActivityStreamAction("/do/ActivityStream", "viewMore", actionRecordDate);
this.setUserOnSession("admin");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
activityStreamAction = (ActivityStreamAction) this.getAction();
List<Integer> viewMore = activityStreamAction.getActionRecordIds();
assertEquals(1, viewMore.size());
assertEquals(firstRecord.getId(), viewMore.get(0).intValue());
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(content);
assertNull(this._contentManager.loadContent(contentId, false));
}
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean in project entando-core by entando.
the class TestActionLogDAO method testGetActionRecords.
public void testGetActionRecords() {
IActionLogRecordSearchBean bean = null;
List<Integer> ids = this._actionLoggerDAO.getActionRecords(bean);
// this.compareIds(new Integer[]{}, ids);
ActionLogRecord record1 = this._helper.createActionRecord(1, "username1", "actionName1", "namespace1", DateConverter.parseDate("01/01/2009 00:00", "dd/MM/yyyy HH:mm"), "params1");
ActionLogRecord record2 = this._helper.createActionRecord(2, "username2", "actionName2", "namespace2", DateConverter.parseDate("01/01/2009 10:00", "dd/MM/yyyy HH:mm"), "params2");
ActionLogRecord record3 = this._helper.createActionRecord(3, "username123", "actionName123", "namespace123", DateConverter.parseDate("02/01/2009 12:00", "dd/MM/yyyy HH:mm"), "params123");
this._helper.addActionRecord(record1);
this._helper.addActionRecord(record2);
this._helper.addActionRecord(record3);
//
// ids = this._actionLoggerDAO.getActionRecords(bean);
// this.compareIds(new Integer[]{1, 2, 3}, ids);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("name", "Name", "space", "arams", null, null);
ids = this._actionLoggerDAO.getActionRecords(searchBean);
this.compareIds(new Integer[] { 1, 2, 3 }, ids);
searchBean = this._helper.createSearchBean("name", "Name", "space", "arams", DateConverter.parseDate("01/01/2009 10:01", "dd/MM/yyyy HH:mm"), null);
ids = this._actionLoggerDAO.getActionRecords(searchBean);
this.compareIds(new Integer[] { 3 }, ids);
searchBean = this._helper.createSearchBean(null, null, null, null, null, DateConverter.parseDate("01/01/2009 10:01", "dd/MM/yyyy HH:mm"));
ids = this._actionLoggerDAO.getActionRecords(searchBean);
this.compareIds(new Integer[] { 1, 2 }, ids);
searchBean = this._helper.createSearchBean(null, "Name", null, null, DateConverter.parseDate("01/01/2009 09:01", "dd/MM/yyyy HH:mm"), DateConverter.parseDate("01/01/2009 10:01", "dd/MM/yyyy HH:mm"));
ids = this._actionLoggerDAO.getActionRecords(searchBean);
this.compareIds(new Integer[] { 2 }, ids);
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean in project entando-core by entando.
the class TestActionLogManager method testGetActionRecords.
public void testGetActionRecords() throws Throwable {
List<Integer> ids = this._actionLoggerManager.getActionRecords(null);
this.compareIds(new Integer[] {}, ids);
ActionLogRecord record1 = this._helper.createActionRecord(1, "username1", "actionName1", "namespace1", DateConverter.parseDate("01/01/2009 00:00", "dd/MM/yyyy HH:mm"), "params1");
ActionLogRecord record2 = this._helper.createActionRecord(2, "username2", "actionName2", "namespace2", DateConverter.parseDate("01/01/2009 10:00", "dd/MM/yyyy HH:mm"), "params2");
ActionLogRecord record3 = this._helper.createActionRecord(3, "username123", "actionName123", "namespace123", DateConverter.parseDate("02/01/2009 12:00", "dd/MM/yyyy HH:mm"), "params123");
this._helper.addActionRecord(record1);
this._helper.addActionRecord(record2);
this._helper.addActionRecord(record3);
ids = this._actionLoggerManager.getActionRecords(null);
this.compareIds(new Integer[] { 1, 2, 3 }, ids);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("name", "Name", "space", "arams", null, null);
ids = this._actionLoggerManager.getActionRecords(searchBean);
this.compareIds(new Integer[] { 1, 2, 3 }, ids);
searchBean = this._helper.createSearchBean("name", "Name", "space", "arams", DateConverter.parseDate("01/01/2009 10:01", "dd/MM/yyyy HH:mm"), null);
ids = this._actionLoggerManager.getActionRecords(searchBean);
this.compareIds(new Integer[] { 3 }, ids);
searchBean = this._helper.createSearchBean(null, null, null, null, null, DateConverter.parseDate("01/01/2009 10:01", "dd/MM/yyyy HH:mm"));
ids = this._actionLoggerManager.getActionRecords(searchBean);
this.compareIds(new Integer[] { 1, 2 }, ids);
searchBean = this._helper.createSearchBean(null, "Name", null, null, DateConverter.parseDate("01/01/2009 09:01", "dd/MM/yyyy HH:mm"), DateConverter.parseDate("01/01/2009 10:01", "dd/MM/yyyy HH:mm"));
ids = this._actionLoggerManager.getActionRecords(searchBean);
this.compareIds(new Integer[] { 2 }, ids);
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean in project entando-core by entando.
the class TestActivityStream method testSaveNewContent_2.
public void testSaveNewContent_2() throws Throwable {
// "coach" group
Content content = this._contentManager.loadContent("EVN41", false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
content.setId(null);
String contentId = null;
try {
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.size());
UserDetails editorCustomers = super.getUser("editorCustomers");
List<Integer> activityStreamCustomerUser = this._actionLoggerManager.getActivityStream(editorCustomers);
assertEquals(0, activityStreamCustomerUser.size());
UserDetails editorCoach = super.getUser("editorCoach");
List<Integer> activityStreamCoachUser = this._actionLoggerManager.getActivityStream(editorCoach);
assertEquals(1, activityStreamCoachUser.size());
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(content);
assertNull(this._contentManager.loadContent(contentId, false));
}
}
Aggregations