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