use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class CommunicatorTestsBase method communicatorMoveToTrashTest.
@Test
public void communicatorMoveToTrashTest() 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();
try {
long recipient = getUserIdByEmail("admin@example.com");
long sender = getUserIdByEmail("student@example.com");
createCommunicatorMesssage("Test caption", "Test content.", sender, recipient);
navigate("/communicator#inbox", true);
waitAndClick("input[name=\"messageSelect\"]");
waitAndClick(".icon-delete");
assertGoesAway(".cm-message .cm-message-caption", 10l);
waitAndClick("a[href$=\"trash\"]");
waitForPresent(".cm-message-header-container .cm-message-caption");
assertText(".cm-message-header-container .cm-message-caption", "Test caption");
} finally {
deleteCommunicatorMessages();
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class CommunicatorTestsBase method communicatorDeleteLabelTest.
@Test
public void communicatorDeleteLabelTest() 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();
try {
long recipient = getUserIdByEmail("admin@example.com");
long sender = getUserIdByEmail("student@example.com");
createCommunicatorMesssage("Test caption", "Test content.", sender, recipient);
createCommunicatorUserLabel(admin.getId(), "test");
navigate("/communicator#inbox", true);
waitAndClick(".mf-label-functions");
waitAndClick(".mf-label-function-delete");
waitAndClick(".save-button span");
assertGoesAway(".cm-folder .cm-label-name a span", 5l);
} finally {
deleteCommunicatorUserLabels(admin.getId());
deleteCommunicatorMessages();
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class CourseAccessTestsBase method notLoggedInLoggedInCourseAccessTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void notLoggedInLoggedInCourseAccessTest() 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/workspace-management", workspace.getUrlName()), true);
waitAndClick(".additionalinfo-data div input[value=\"LOGGED_IN\"]");
waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
waitForElementToBePresent(By.cssSelector(".loading"));
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitForVisible(".additionalinfo-data div input");
sleep(1000);
assertChecked(".additionalinfo-data div input[value=\"LOGGED_IN\"]", true);
logout();
mockBuilder.clearLoginMock();
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
assertNotPresent(".workspace-header-wrapper .workspace-header-container h1.workspace-title");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class CourseAccessTestsBase method loggedInAnyoneCourseAccessTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void loggedInAnyoneCourseAccessTest() 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);
try {
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitAndClick(".additionalinfo-data div input[value=\"ANYONE\"]");
waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
waitForElementToBePresent(By.cssSelector(".loading"));
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitForVisible(".additionalinfo-data div input");
sleep(1000);
assertChecked(".additionalinfo-data div input[value=\"ANYONE\"]", true);
logout();
mockBuilder.mockLogin(student);
login();
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
assertPresent(".workspace-header-wrapper .workspace-header-container h1.workspace-title");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember 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();
}
}
Aggregations