Search in sources :

Example 41 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.

the class ToRTestsBase method recordsWorkspaceEvaluationTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.PHANTOMJS })
public void recordsWorkspaceEvaluationTest() 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());
    OffsetDateTime date = OffsetDateTime.of(2016, 11, 10, 1, 1, 1, 1, ZoneOffset.UTC);
    Builder mockBuilder = mocker();
    try {
        mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
        Long courseId = 2l;
        login();
        Workspace workspace = createWorkspace("testcourses", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        OffsetDateTime created = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        OffsetDateTime begin = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        OffsetDateTime end = OffsetDateTime.of(2045, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        MockCourse mockCourse = new MockCourse(workspace.getId(), workspace.getName(), created, "test course", begin, end);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
        WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-nT0yyez23QwFXD3G0I8HzYeK&quot;,&quot;rightAnswers&quot;:[],&quot;columns&quot;:&quot;&quot;,&quot;hint&quot;:&quot;&quot;}\" /></object></p>", 1l, "EVALUATED");
        try {
            mockBuilder.mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, date).mockCompositeGradingScales().addCompositeCourseAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, date).mockCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).mockStaffCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, true, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).mockStaffCompositeCourseAssessmentRequests().mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello! I'd like to get assessment.", false, true, date).mockCourseAssessments(courseStudent, admin);
            logout();
            mockBuilder.mockLogin(student).build();
            login();
            navigate("/records/", true);
            waitForPresent("div.tr-study-programme-accomplishments .tr-item-header-name .tr-item-long");
            assertText("div.tr-study-programme-accomplishments .tr-item-header-name .tr-item-long", "testcourses (test extension)");
            waitAndClick("div.tr-study-programme-accomplishments .tr-item-header-name .tr-item-long");
            waitForPresent(".tr-evaluation-verbal .content");
            assertText(".tr-evaluation-verbal .content", "Test evaluation.");
            waitForPresent(".tr-item-details .tr-item-description-title .grade");
            assertText(".tr-item-details .tr-item-description-title .grade", "Excellent");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) OffsetDateTime(java.time.OffsetDateTime) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) MockCourse(fi.otavanopisto.muikku.mock.model.MockCourse) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 42 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.

the class AnnouncerTestsBase method archivedAnnouncementListTest.

@Test
public void archivedAnnouncementListTest() 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();
    try {
        try {
            login();
            maximizeWindow();
            navigate("/announcer", true);
            waitAndClick(".an-new-announcement");
            waitForPresent(".cke_wysiwyg_frame");
            waitForPresent("*[name='endDate']");
            clearElement("*[name='endDate']");
            sendKeys("*[name='endDate']", "21.12.2025");
            sendKeys(".mf-textfield-subject", "Test title");
            click(".mf-form-header");
            waitForPresent("#ui-datepicker-div");
            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);
            waitAndClick("li.an-category[data-folder-id~=\"archived\"]");
            waitForPresent("li.an-category.selected[data-folder-id~=\"archived\"]");
            waitForPresent("div.an-announcement-topic>span");
            assertTextIgnoreCase("div.an-announcement-topic>span", "Test title");
        } finally {
            deleteAnnouncements();
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 43 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.

the class AnnouncerTestsBase method announcementVisibleInFrontpageWidgetTest.

@Test
public void announcementVisibleInFrontpageWidgetTest() 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).mockLogin(admin).build();
        login();
        try {
            createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), date(125, 10, 12), false, true, null);
            logout();
            mockBuilder.mockLogin(student);
            login();
            waitForPresentAndVisible("#announcements ul>li>div>a");
            assertTextIgnoreCase("#announcements ul>li>div>a", "Test title");
        } finally {
            deleteAnnouncements();
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 44 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.

the class AnnouncerTestsBase method announcementListTest.

@Test
public void announcementListTest() 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).mockLogin(admin).build();
        login();
        try {
            createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), date(125, 10, 12), false, true, null);
            logout();
            mockBuilder.mockLogin(student);
            login();
            waitForPresentAndVisible("#announcements ul>li>div>a");
            assertTextIgnoreCase("#announcements ul>li>div>a", "Test title");
            navigate("/announcements", true);
            waitForPresent("#announcementContextNavigation .gc-navigation-item");
            assertTextIgnoreCase("#announcementContextNavigation .gc-navigation-item a", "Test title");
            click("#announcementContextNavigation .gc-navigation-item a");
            waitForPresent(".announcement-article h2");
            assertTextIgnoreCase(".announcement-article h2", "Test title");
            assertTextIgnoreCase(".announcement-article div.article-datetime", "12.11.2015");
            assertTextIgnoreCase(".announcement-article div.article-context", "announcer test announcement");
        } finally {
            deleteAnnouncements();
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 45 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.

the class CommunicatorTestsBase method communicatorSendMessageTest.

@Test
public void communicatorSendMessageTest() 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 {
        try {
            login();
            navigate("/communicator", true);
            waitAndClick(".mf-primary-function .mf-primary-function-content");
            waitForPresent("#recipientContent");
            sendKeys("#recipientContent", "Test");
            waitAndClick(".ui-autocomplete li.ui-menu-item");
            waitForPresent(".mf-textfield-subject");
            sendKeys(".mf-textfield-subject", "Test");
            waitAndClick("#cke_1_contents");
            addTextToCKEditor("Communicator test");
            waitAndClick("*[name='send']");
            waitForPresent(".mf-content-master");
            getWebDriver().get("about:blank");
            navigate("/communicator#sent", true);
            waitForPresent(".cm-message-header-content-secondary");
            assertText(".cm-message-header-content-secondary", "Test");
        } finally {
            deleteCommunicatorMessages();
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Aggregations

Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)87 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)87 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)87 Test (org.junit.Test)87 Workspace (fi.otavanopisto.muikku.atests.Workspace)67 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)61 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)43 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)34 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)24 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)24 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)18 OffsetDateTime (java.time.OffsetDateTime)11 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)6 Course (fi.otavanopisto.pyramus.rest.model.Course)3 File (java.io.File)3 Date (java.sql.Date)3 ArrayList (java.util.ArrayList)3 WebhookCourseCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookCourseCreatePayload)2