use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class DailyStatisticUpdateManagerTest method checkStatistics.
private void checkStatistics(ICourse course, CourseNode node, String date) {
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
StatisticResult updatedResult = dailyStatisticManager.generateStatisticResult(new SyntheticUserRequest(null, Locale.ENGLISH), course, re.getKey());
Map<String, Integer> updatedRootStats = updatedResult.getStatistics(node);
Integer updated_stats_inMemory = getInMemoryStatistics(re, node, date);
Integer updated_stats_today = updatedRootStats.get(date);
Assert.assertEquals(updated_stats_inMemory, updated_stats_today);
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class HourOfDayStatisticUpdateManagerTest method checkStatistics.
private void checkStatistics(ICourse course, CourseNode node, String date) {
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
StatisticResult updatedResult = hourOfDayStatisticManager.generateStatisticResult(new SyntheticUserRequest(null, Locale.ENGLISH), course, re.getKey());
Map<String, Integer> updatedRootStats = updatedResult.getStatistics(node);
Integer updated_stats_inMemory = getInMemoryStatistics(re, node, date);
Integer updated_stats_today = updatedRootStats.get(date);
Assert.assertEquals(updated_stats_inMemory, updated_stats_today);
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class HourOfDayStatisticUpdateManagerTest method statistics_hourOfDay.
@Test
public void statistics_hourOfDay() {
Assert.assertNotNull(statisticUpdateManager);
statisticUpdateManager.setEnabled(true);
Assert.assertTrue(statisticUpdateManager.isEnabled());
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("log-3");
RepositoryEntry re1 = JunitTestHelper.deployBasicCourse(id);
ICourse course1 = CourseFactory.loadCourse(re1);
CourseNode rootNode1 = course1.getRunStructure().getRootNode();
CourseNode firstNode1 = (CourseNode) course1.getRunStructure().getRootNode().getChildAt(0);
RepositoryEntry re2 = JunitTestHelper.deployBasicCourse(id);
ICourse course2 = CourseFactory.loadCourse(re2);
CourseNode rootNode2 = course2.getRunStructure().getRootNode();
CourseNode firstNode2 = (CourseNode) course2.getRunStructure().getRootNode().getChildAt(0);
Calendar ref = Calendar.getInstance();
String date1 = null;
String date2 = null;
cleanUpLog();
for (int i = 0; i < 12; i++) {
addLogEntry(re1, rootNode1, ref, 0, getSecuredNowRef(ref, 1, i + 1), 1, i + 1);
addLogEntry(re2, firstNode2, ref, 0, getSecuredNowRef(ref, 1, i + 1), 1, i + 1);
}
for (int i = 0; i < 7; i++) {
addLogEntry(re1, rootNode1, ref, 1, 3 + i, 1, 1);
date2 = addLogEntry(re2, rootNode2, ref, 1, 3 + i, 1, 1);
}
for (int i = 0; i < 9; i++) {
date1 = addLogEntry(re1, firstNode1, ref, 2, 3 + i, 13, 1);
}
setLastUpdate(ref, 12);
dbInstance.commitAndCloseSession();
updateStatistics();
// first log analyze
String date = getHourOfDay(ref);
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
// add log the same day
Calendar now = Calendar.getInstance();
addLogEntry(re1, rootNode1, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 1);
addLogEntry(re1, rootNode1, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 2);
addLogEntry(re2, firstNode2, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 2);
dbInstance.commitAndCloseSession();
sleep(5000);
// update stats incremental
updateStatistics();
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
checkStatistics(course2, firstNode2, date);
// update all stats, must be the same results
updateAllStatistics();
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
checkStatistics(course2, firstNode2, date);
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class BGAreaManagerTest method findBusinessGroupsOfAreaAttendedBy.
@Test
public void findBusinessGroupsOfAreaAttendedBy() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("attendee-1-" + UUID.randomUUID().toString());
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("attendee-2-" + UUID.randomUUID().toString());
Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("attendee-3-" + UUID.randomUUID().toString());
// create a resource, an area, a group
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
String areaName = UUID.randomUUID().toString();
BGArea area1 = areaManager.createAndPersistBGArea("area-1-" + areaName, "description:" + areaName, resource.getOlatResource());
BGArea area2 = areaManager.createAndPersistBGArea("area-2-" + areaName, "description:" + areaName, resource.getOlatResource());
// create 2 groups
BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "area-1-group", "area-group-desc", 0, -1, false, false, resource);
BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "area-2-group", "area-group-desc", 0, -1, false, false, resource);
BusinessGroup group3 = businessGroupService.createBusinessGroup(null, "area-3-group", "area-group-desc", 0, -1, false, false, resource);
dbInstance.commitAndCloseSession();
// add the relations
areaManager.addBGToBGArea(group1, area1);
areaManager.addBGToBGArea(group2, area1);
areaManager.addBGToBGArea(group2, area2);
areaManager.addBGToBGArea(group3, area1);
dbInstance.commitAndCloseSession();
// add attendee
businessGroupRelationDao.addRole(id1, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(id2, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(id2, group3, GroupRoles.participant.name());
businessGroupRelationDao.addRole(id3, group3, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// find with resource
List<BusinessGroup> groupId1 = areaManager.findBusinessGroupsOfAreaAttendedBy(id1, null, resource.getOlatResource());
Assert.assertNotNull(groupId1);
Assert.assertEquals(1, groupId1.size());
Assert.assertTrue(groupId1.contains(group1));
// find nothing with name and resource
List<Long> area2Keys = Collections.singletonList(area2.getKey());
List<BusinessGroup> groupId1Area2 = areaManager.findBusinessGroupsOfAreaAttendedBy(id1, area2Keys, resource.getOlatResource());
Assert.assertNotNull(groupId1Area2);
Assert.assertEquals(0, groupId1Area2.size());
// find groups id 2 with name and resource
List<Long> area1Keys = Collections.singletonList(area1.getKey());
List<BusinessGroup> groupId2Area1 = areaManager.findBusinessGroupsOfAreaAttendedBy(id2, area1Keys, resource.getOlatResource());
Assert.assertNotNull(groupId2Area1);
Assert.assertEquals(2, groupId2Area1.size());
Assert.assertTrue(groupId2Area1.contains(group2));
Assert.assertTrue(groupId2Area1.contains(group3));
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class BGAreaManagerTest method addFindAndDeleteRelation.
@Test
public void addFindAndDeleteRelation() {
// create a resource, an area, a group
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
String areaName = UUID.randomUUID().toString();
BGArea area1 = areaManager.createAndPersistBGArea("area-1-" + areaName, "description:" + areaName, resource.getOlatResource());
// create 2 groups
BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "area-1-group", "area-group-desc", 0, -1, false, false, resource);
BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "area-2-group", "area-group-desc", 0, -1, false, false, resource);
dbInstance.commitAndCloseSession();
// add the relations
areaManager.addBGToBGArea(group1, area1);
areaManager.addBGToBGArea(group2, area1);
dbInstance.commitAndCloseSession();
// check find groups
List<BusinessGroup> groups = areaManager.findBusinessGroupsOfArea(area1);
Assert.assertNotNull(groups);
Assert.assertEquals(2, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
dbInstance.commitAndCloseSession();
// remove relation to group1
areaManager.removeBGFromArea(group2, area1);
dbInstance.commitAndCloseSession();
// check find groups
List<BusinessGroup> diminushedGroups = areaManager.findBusinessGroupsOfArea(area1);
Assert.assertNotNull(diminushedGroups);
Assert.assertEquals(1, diminushedGroups.size());
Assert.assertTrue(diminushedGroups.contains(group1));
}
Aggregations