use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method courseManagementButtonExistsTest.
@Test
public void courseManagementButtonExistsTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
try {
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(".icon-cogs");
assertPresent(".icon-cogs");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.
the class AnnouncerTestsBase method userGroupAnnouncementNotVisibleTest.
@Test
public void userGroupAnnouncementNotVisibleTest() throws JsonProcessingException, Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Builder mockBuilder = mocker();
try {
mockBuilder.addStaffMember(admin).addStudent(student).addStudentGroup(2l, "Test group", "Test group for users", 1l, false).addStaffMemberToStudentGroup(2l, admin).mockLogin(admin).build();
login();
try {
List<Long> userGroups = new ArrayList<>();
userGroups.add(2l);
createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), date(125, 10, 12), false, false, userGroups);
logout();
mockBuilder.mockLogin(student);
login();
waitForPresent("#announcements");
assertTrue("Element found even though it shouldn't be there", isElementPresent("#announcements ul>li>div>a") == false);
} finally {
deleteAnnouncements();
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.
the class AnnouncerTestsBase method userGroupAnnouncementVisibleTest.
@Test
public void userGroupAnnouncementVisibleTest() throws JsonProcessingException, Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Builder mockBuilder = mocker();
try {
mockBuilder.addStaffMember(admin).addStudent(student).addStudentGroup(2l, "Test group", "Test group for users", 1l, false).addStudentToStudentGroup(2l, student).addStaffMemberToStudentGroup(2l, admin).mockLogin(admin).build();
login();
try {
List<Long> userGroups = new ArrayList<>();
userGroups.add(2l);
createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), date(125, 10, 12), false, false, userGroups);
logout();
mockBuilder.mockLogin(student);
login();
waitForPresent("#announcements ul>li>div>a");
assertTextIgnoreCase("#announcements ul>li>div>a", "Test title");
} finally {
deleteAnnouncements();
deleteUserGroup(2l);
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.
the class AnnouncerTestsBase method myAnnnouncementsListTest.
@Test
public void myAnnnouncementsListTest() throws JsonProcessingException, Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
MockStaffMember another = new MockStaffMember(3l, 3l, "Another", "User", UserRole.ADMINISTRATOR, "121212-1234", "blaablaa@example.com", Sex.MALE);
Long courseId = 1l;
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStaffMember(another).addStudent(student).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
MockCourseStudent mcs = new MockCourseStudent(2l, courseId, student.getId());
mockBuilder.addCourseStudent(workspace.getId(), mcs).build();
createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), new java.util.Date(), false, true, null);
createAnnouncement(another.getId(), "Another test title", "Another announcer test announcement", date(115, 10, 12), new java.util.Date(), false, true, null);
try {
navigate("/announcer", true);
waitForPresent(".an-announcement-topic");
assertCount("div.an-announcement-topic>span", 2);
waitAndClick("li.an-category[data-folder-id~=\"mine\"]");
waitForPresent("li.an-category.selected[data-folder-id~=\"mine\"]");
waitForPresent("div.an-announcement-topic>span");
assertTextIgnoreCase("div.an-announcement-topic>span", "Test title");
assertCount("div.an-announcement-topic>span", 1);
} finally {
deleteAnnouncements();
deleteWorkspace(workspace.getId());
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.
the class AnnouncerTestsBase method pastAnnnouncementsListTest.
@Test
public void pastAnnnouncementsListTest() throws JsonProcessingException, Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Long courseId = 1l;
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
MockCourseStudent mcs = new MockCourseStudent(2l, courseId, student.getId());
mockBuilder.addCourseStudent(workspace.getId(), mcs).build();
createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), date(115, 10, 15), false, true, null);
try {
navigate("/announcer", true);
waitForPresent("div.mf-content-empty");
waitAndClick("li.an-category[data-folder-id~=\"past\"]");
waitForPresent("div.an-announcement-topic>span");
assertTextIgnoreCase("div.an-announcement-topic>span", "Test title");
navigate("/announcements", true);
waitForPresent("#announcements");
assertNotPresent(".announcement-article>header");
} finally {
deleteAnnouncements();
deleteWorkspace(workspace.getId());
mockBuilder.wiremockReset();
}
}
Aggregations