Search in sources :

Example 1 with WebhookCourseUpdatePayload

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

the class CourseManagementTestsBase method changeWorkspaceTypeTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void changeWorkspaceTypeTest() 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();
        long courseId = 1l;
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        try {
            navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
            waitForPresent(".additionalinfo-data .workspace-type");
            scrollIntoView(".additionalinfo-data .workspace-type");
            selectOption(".additionalinfo-data .workspace-type", "PYRAMUS-2");
            waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
            waitForNotVisible(".loading");
            ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).setSerializationInclusion(Include.NON_NULL);
            OffsetDateTime created = OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC);
            OffsetDateTime begin = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
            OffsetDateTime end = OffsetDateTime.of(2050, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
            Course course = new Course(courseId, "testcourse", created, created, "<p>test course for testing</p>\n", false, 1, (long) 25, begin, end, "test extension", (double) 15, (double) 45, (double) 45, (double) 15, (double) 45, (double) 45, end, (long) 1, (long) 1, (long) 1, null, (double) 45, (long) 1, (long) 1, (long) 1, (long) 2, null, null);
            String courseJson = objectMapper.writeValueAsString(course);
            stubFor(put(urlEqualTo(String.format("/1/courses/courses/%d", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(courseJson).withStatus(200)));
            stubFor(get(urlEqualTo(String.format("/1/courses/courses/%d", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(courseJson).withStatus(200)));
            String payload = objectMapper.writeValueAsString(new WebhookCourseUpdatePayload(course.getId()));
            TestUtilities.webhookCall("http://dev.muikku.fi:" + System.getProperty("it.port.http") + "/pyramus/webhook", payload);
            navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
            waitForPresent(".workspace-meta-wrapper .workspace-meta-item-wrapper:nth-child(3) .workspace-meta-desc");
            assertTextIgnoreCase(".workspace-meta-wrapper .workspace-meta-item-wrapper:nth-child(3) .workspace-meta-desc", "Ryhmäkurssi");
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) Course(fi.otavanopisto.pyramus.rest.model.Course) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WebhookCourseUpdatePayload(fi.otavanopisto.pyramus.webhooks.WebhookCourseUpdatePayload) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)1 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)1 Workspace (fi.otavanopisto.muikku.atests.Workspace)1 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)1 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)1 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)1 Course (fi.otavanopisto.pyramus.rest.model.Course)1 WebhookCourseUpdatePayload (fi.otavanopisto.pyramus.webhooks.WebhookCourseUpdatePayload)1 OffsetDateTime (java.time.OffsetDateTime)1 Test (org.junit.Test)1