use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.
the class CourseAnnouncerTestsBase method workspaceAnnouncementReadingForStudentTest.
@SuppressWarnings("deprecation")
@Test
public void workspaceAnnouncementReadingForStudentTest() 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();
Long announcementId = createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", new Date(115, 10, 12), new Date(125, 10, 12), false, true, null);
updateAnnouncementWorkspace(announcementId, workspace.getId());
logout();
mockBuilder.mockLogin(student).build();
try {
login();
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
waitForPresent(".workspace-announcement-title");
click(".workspace-announcement-title");
waitForPresent("#announcements .announcement-article h2");
assertTextIgnoreCase("#announcements .announcement-article h2", "Test title");
assertTextIgnoreCase("#announcements .announcement-article .article-datetime", "12.11.2015");
waitForPresent("#announcements .announcement-article .article-context");
assertTextIgnoreCase("#announcements .announcement-article .article-context", "announcer test announcement");
} finally {
deleteAnnouncements();
deleteWorkspace(workspace.getId());
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.
the class CourseAnnouncerTestsBase method deleteWorkspaceAnnouncementTest.
@Test
public void deleteWorkspaceAnnouncementTest() throws JsonProcessingException, Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
waitForPresent(".icon-cogs");
hoverOverElement(".icon-cogs");
waitAndClick(".icon-announcer");
waitAndClick(".an-new-announcement");
waitForPresent("*[name='endDate']");
clearElement("*[name='endDate']");
sendKeys("*[name='endDate']", "21.12.2025");
sendKeys(".mf-textfield-subject", "Test title");
click(".mf-form-header h3");
waitForNotVisible("#ui-datepicker-div");
addTextToCKEditor("Announcer test announcement");
waitAndClick(".mf-toolbar input[name='send']");
waitForPresent(".an-announcement-topic");
waitAndClick(".an-announcement-select input");
waitAndClick(".mf-items-toolbar .icon-delete");
waitAndClick(".mf-toolbar input[name='send']");
reloadCurrentPage();
assertTrue("Element found even though it shouldn't be there", isElementPresent(".an-announcement-topic>span") == false);
} finally {
deleteAnnouncements();
deleteWorkspace(workspace.getId());
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.
the class CourseJournalPageTestsBase method courseJournalNewEntryForStudent.
@Test
public void courseJournalNewEntryForStudent() 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();
try {
mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
Long courseId = NumberUtils.createLong(workspace.getIdentifier());
MockCourseStudent courseStudent = new MockCourseStudent(1l, courseId, student.getId());
mockBuilder.addCourseStudent(courseId, courseStudent).build();
logout();
mockBuilder.mockLogin(student).build();
login();
try {
navigate(String.format("/workspace/%s/journal", workspace.getUrlName()), true);
waitForPresent(".workspace-journal-content-wrapper");
assertVisible(".workspace-journal-new-entry-button");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.
the class CourseJournalPageTestsBase method courseJournalToolsForTeacher.
@Test
public void courseJournalToolsForTeacher() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
Builder mockBuilder = mocker();
try {
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
navigate(String.format("/workspace/%s/journal", workspace.getUrlName()), true);
waitForPresent(".workspace-journal-content-wrapper");
assertVisible(".workspace-journal-teacher-tools-container");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.
the class CourseJournalPageTestsBase method courseJournalEntryAdded.
@Test
public void courseJournalEntryAdded() 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();
try {
mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
Long courseId = NumberUtils.createLong(workspace.getIdentifier());
MockCourseStudent courseStudent = new MockCourseStudent(1l, courseId, student.getId());
mockBuilder.addCourseStudent(courseId, courseStudent).build();
logout();
mockBuilder.mockLogin(student).build();
login();
try {
navigate(String.format("/workspace/%s/journal", workspace.getUrlName()), true);
click(".workspace-journal-new-entry-button");
addTextToCKEditor("content");
sendKeys(".mf-textfield-subject", "title");
click("#socialNavigation.sn-container .jo-message-create .mf-toolbar input[name=\"send\"]");
waitForPresent("#content");
waitForPresent(".workspace-journal-title");
assertText(".workspace-journal-title", "title");
waitForPresent(".workspace-journal-content>p");
assertText(".workspace-journal-content>p", "content");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
Aggregations