Search in sources :

Example 46 with Builder

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

the class CommunicatorTestsBase method communicatorSendMessageTest.

@Test
public void communicatorSendMessageTest() 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 {
        try {
            login();
            navigate("/communicator", true);
            waitAndClick(".mf-primary-function .mf-primary-function-content");
            waitForPresent("#recipientContent");
            sendKeys("#recipientContent", "Test");
            waitAndClick(".ui-autocomplete li.ui-menu-item");
            waitForPresent(".mf-textfield-subject");
            sendKeys(".mf-textfield-subject", "Test");
            waitAndClick("#cke_1_contents");
            addTextToCKEditor("Communicator test");
            waitAndClick("*[name='send']");
            waitForPresent(".mf-content-master");
            getWebDriver().get("about:blank");
            navigate("/communicator#sent", true);
            waitForPresent(".cm-message-header-content-secondary");
            assertText(".cm-message-header-content-secondary", "Test");
        } finally {
            deleteCommunicatorMessages();
        }
    } 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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 47 with Builder

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

the class CommunicatorTestsBase method communicatorSentMessagesTest.

@Test
public void communicatorSentMessagesTest() 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 {
        try {
            login();
            navigate("/communicator", true);
            waitAndClick(".mf-primary-function .mf-primary-function-content");
            waitForPresent("#recipientContent");
            sendKeys("#recipientContent", "Test");
            waitAndClick(".ui-autocomplete li.ui-menu-item");
            waitForPresent(".mf-textfield-subject");
            sendKeys(".mf-textfield-subject", "Test");
            waitAndClick("#cke_1_contents");
            addTextToCKEditor("Communicator test");
            waitAndClick("*[name='send']");
            waitForPresent(".mf-content-master");
            getWebDriver().get("about:blank");
            navigate("/communicator#sent", true);
            waitForPresent(".cm-message-header-content-secondary");
            assertText(".cm-message-header-content-secondary", "Test");
        } finally {
            deleteCommunicatorMessages();
        }
    } 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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 48 with Builder

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

the class CommunicatorTestsBase method communicatorDeleteSentMessageTest.

@Test
public void communicatorDeleteSentMessageTest() 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).addStudent(student).mockLogin(admin).build();
        login();
        try {
            long sender = getUserIdByEmail("admin@example.com");
            long recipient = getUserIdByEmail("student@example.com");
            createCommunicatorMesssage("Test caption", "Test content.", sender, recipient);
            navigate("/communicator#sent", true);
            waitForPresent(".cm-message-select input[name=\"messageSelect\"]");
            click(".cm-message-select input[name=\"messageSelect\"]");
            waitForPresent(".icon-delete");
            click(".icon-delete");
            waitForPresent(".cm-messages-container");
            waitForPresent(".content");
            String currentUrl = getWebDriver().getCurrentUrl();
            assertTrue("Communicator does not stay in sent messages box.", currentUrl.equals("https://dev.muikku.fi:" + getPortHttps() + "/communicator#sent"));
            assertTrue("Element found even though it shouldn't be there", isElementPresent("div.cm-message-select input[type=\"checkbox\"]") == false);
        } finally {
            deleteCommunicatorMessages();
        }
    } 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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 49 with Builder

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

the class CommunicatorTestsBase method communicatorReadMessageTest.

@Test
public void communicatorReadMessageTest() 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).addStudent(student).mockLogin(admin).build();
        login();
        try {
            long sender = getUserIdByEmail("admin@example.com");
            long recipient = getUserIdByEmail("student@example.com");
            createCommunicatorMesssage("Test caption", "Test content.", sender, recipient);
            logout();
            mockBuilder.mockLogin(student).build();
            login();
            navigate("/communicator", true);
            waitAndClick("div.cm-message-header-content-secondary");
            waitForPresent(".cm-message-content-text");
            assertText("div.cm-message-content-text", "Test content.");
        } finally {
            deleteCommunicatorMessages();
        }
    } 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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 50 with Builder

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

the class CommunicatorTestsBase method communicatorEditLabelTest.

@Test
public void communicatorEditLabelTest() 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).addStudent(student).mockLogin(admin).build();
        login();
        try {
            long recipient = getUserIdByEmail("admin@example.com");
            long sender = getUserIdByEmail("student@example.com");
            createCommunicatorMesssage("Test caption", "Test content.", sender, recipient);
            createCommunicatorUserLabel(admin.getId(), "test");
            navigate("/communicator#inbox", true);
            waitAndClick(".mf-label-functions");
            waitAndClick(".mf-label-function-edit");
            waitForPresent(".mf-label-edit-dialog input[name=\"name\"]");
            clearElement(".mf-label-edit-dialog input[name=\"name\"]");
            waitAndSendKeys(".mf-label-edit-dialog input[name=\"name\"]", "edited");
            waitAndClick(".save-button span");
            assertText(".cm-folder .cm-label-name a span", "edited");
        } finally {
            deleteCommunicatorUserLabels(admin.getId());
            deleteCommunicatorMessages();
        }
    } 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) 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