Search in sources :

Example 1 with WebhookStudentUpdatePayload

use of fi.otavanopisto.pyramus.webhooks.WebhookStudentUpdatePayload in project muikku by otavanopisto.

the class CourseUsersTestsBase method courseUnarchiveStudentTest.

@Test
public void courseUnarchiveStudentTest() 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).mockLogin(admin).build();
        login();
        Long courseId = 1l;
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addStudent(student).addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        try {
            navigate(String.format("/workspace/%s/users", workspace.getUrlName()), true);
            waitForPresent(".workspace-students-listing-wrapper .workspace-users-name");
            waitAndClick("div[data-user-id='PYRAMUS-STUDENT-2']>div.workspace-users-archive");
            waitAndClick(".archive-button");
            waitForClickable(".workspace-students-inactive");
            waitAndClick(".workspace-students-inactive");
            waitAndClick("div[data-user-id='PYRAMUS-STUDENT-2']>div.workspace-users-unarchive");
            waitAndClick(".unarchive-button");
            waitForPresentAndVisible(".workspace-students-listing-wrapper");
            ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
            String payload = objectMapper.writeValueAsString(new WebhookStudentUpdatePayload(2l));
            TestUtilities.webhookCall("http://dev.muikku.fi:" + getPortHttp() + "/pyramus/webhook", payload);
            reloadCurrentPage();
            waitForPresent(".workspace-students-list");
            waitAndClick(".workspace-students-active");
            waitForPresent(".workspace-students-list");
            assertPresent("div[data-user-id='PYRAMUS-STUDENT-2']");
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
        mockBuilder.resetBuilder();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Workspace(fi.otavanopisto.muikku.atests.Workspace) WebhookStudentUpdatePayload(fi.otavanopisto.pyramus.webhooks.WebhookStudentUpdatePayload) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 2 with WebhookStudentUpdatePayload

use of fi.otavanopisto.pyramus.webhooks.WebhookStudentUpdatePayload in project muikku by otavanopisto.

the class CourseUsersTestsBase method courseArchiveStudentTest.

@Test
public void courseArchiveStudentTest() 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).mockLogin(admin).build();
        login();
        Long courseId = 1l;
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addStudent(student).addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        try {
            navigate(String.format("/workspace/%s/users", workspace.getUrlName()), true);
            waitForPresent(".workspace-students-listing-wrapper .workspace-users-name");
            waitAndClick("div[data-user-id='PYRAMUS-STUDENT-2']>div.workspace-users-archive");
            waitAndClick(".archive-button");
            waitForPresentAndVisible(".workspace-students-listing-wrapper");
            ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
            String payload = objectMapper.writeValueAsString(new WebhookStudentUpdatePayload(2l));
            TestUtilities.webhookCall("http://dev.muikku.fi:" + getPortHttp() + "/pyramus/webhook", payload);
            reloadCurrentPage();
            waitForPresent(".workspace-students-list");
            assertNotPresent("div[data-user-id='PYRAMUS-STUDENT-2']");
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
        mockBuilder.resetBuilder();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Workspace(fi.otavanopisto.muikku.atests.Workspace) WebhookStudentUpdatePayload(fi.otavanopisto.pyramus.webhooks.WebhookStudentUpdatePayload) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)2 Workspace (fi.otavanopisto.muikku.atests.Workspace)2 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)2 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)2 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)2 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)2 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)2 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)2 WebhookStudentUpdatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStudentUpdatePayload)2 Test (org.junit.Test)2