Search in sources :

Example 26 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.

the class AnnouncerTestsBase method deleteAnnouncementTest.

@Test
public void deleteAnnouncementTest() 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);
        } 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 27 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder 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();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) ArrayList(java.util.ArrayList) 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 28 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder 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();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) 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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 29 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder 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();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) 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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 30 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.

the class CoursePickerTestsBase method coursePickerSearchTest.

@Test
public void coursePickerSearchTest() 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 workspace1 = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
        Workspace workspace2 = createWorkspace("wiener course", "wiener course for testing", "2", Boolean.TRUE);
        Workspace workspace3 = createWorkspace("potato course", "potato course for testing", "3", Boolean.TRUE);
        try {
            navigate("/coursepicker", true);
            waitForPresent("#coursesList");
            waitAndSendKeys(".cp-search-field input.search", "pot");
            waitAndSendKeys(".cp-search-field input.search", "ato");
            waitUntilElementCount(".cp-course-details-container .cp-course-long-name", 1);
            sleep(1000);
            waitForPresentAndVisible(".cp-course-details-container .cp-course-long-name");
            assertTextIgnoreCase(".cp-course-details-container .cp-course-long-name", "potato course");
        } finally {
            deleteWorkspace(workspace1.getId());
            deleteWorkspace(workspace2.getId());
            deleteWorkspace(workspace3.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Aggregations

Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)88 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)88 Test (org.junit.Test)88 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)87 Workspace (fi.otavanopisto.muikku.atests.Workspace)67 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)62 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