Search in sources :

Example 16 with MockStudent

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();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 17 with MockStudent

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();
    }
}
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 18 with MockStudent

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();
    }
}
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 19 with MockStudent

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();
    }
}
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 20 with MockStudent

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();
    }
}
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)

Aggregations

MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)63 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)62 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)62 Test (org.junit.Test)62 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)61 Workspace (fi.otavanopisto.muikku.atests.Workspace)46 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)35 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)27 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)18 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)17 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)17 OffsetDateTime (java.time.OffsetDateTime)8 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)3 File (java.io.File)3 Date (java.sql.Date)3 ArrayList (java.util.ArrayList)3 WebhookStudentUpdatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStudentUpdatePayload)2 CourseAssessment (fi.otavanopisto.pyramus.rest.model.CourseAssessment)1