Search in sources :

Example 26 with JSR310Module

use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.

the class AbstractUITest method createAnnouncement.

protected Long createAnnouncement(Long publisherUserEntityId, String caption, String content, Date startDate, Date endDate, Boolean archived, Boolean publiclyVisible, List<Long> userGroupIds) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Announcement payload = new Announcement(null, publisherUserEntityId, userGroupIds, caption, content, new Date(), startDate, endDate, archived, publiclyVisible);
    Response response = asAdmin().contentType("application/json").body(payload).post("/test/announcements");
    response.then().statusCode(200);
    Long result = objectMapper.readValue(response.asString(), Long.class);
    return result;
}
Also used : Response(com.jayway.restassured.response.Response) Announcement(fi.otavanopisto.muikku.atests.Announcement) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Date(java.util.Date)

Example 27 with JSR310Module

use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.

the class AbstractUITest method createWorkspaceDiscussionThread.

protected DiscussionThread createWorkspaceDiscussionThread(Long workspaceEntityId, Long groupId, Long discussionId, String title, String message, Boolean sticky, Boolean locked) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    DiscussionThread payload = new DiscussionThread(null, title, message, sticky, locked);
    Response response = asAdmin().contentType("application/json").body(payload).post("/test/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}/threads", workspaceEntityId, groupId, discussionId);
    response.then().statusCode(200);
    DiscussionThread workspaceDiscussionThread = objectMapper.readValue(response.asString(), DiscussionThread.class);
    assertNotNull(workspaceDiscussionThread);
    assertNotNull(workspaceDiscussionThread.getId());
    return workspaceDiscussionThread;
}
Also used : Response(com.jayway.restassured.response.Response) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DiscussionThread(fi.otavanopisto.muikku.atests.DiscussionThread)

Example 28 with JSR310Module

use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.

the class AbstractUITest method createDiscussionThread.

protected DiscussionThread createDiscussionThread(Long groupId, Long discussionId, String title, String message, Boolean sticky, Boolean locked) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    DiscussionThread payload = new DiscussionThread(null, title, message, sticky, locked);
    Response response = asAdmin().contentType("application/json").body(payload).post("/test/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}/threads", groupId, discussionId);
    response.then().statusCode(200);
    DiscussionThread discussionThread = objectMapper.readValue(response.asString(), DiscussionThread.class);
    assertNotNull(discussionThread);
    assertNotNull(discussionThread.getId());
    return discussionThread;
}
Also used : Response(com.jayway.restassured.response.Response) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DiscussionThread(fi.otavanopisto.muikku.atests.DiscussionThread)

Example 29 with JSR310Module

use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.

the class AbstractUITest method loginStudent1.

protected void loginStudent1() throws JsonProcessingException, Exception {
    PyramusMocks.student1LoginMock();
    PyramusMocks.personsPyramusMocks();
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    String payload = objectMapper.writeValueAsString(new WebhookStudentCreatePayload((long) 1));
    TestUtilities.webhookCall("http://dev.muikku.fi:" + getPortHttp() + "/pyramus/webhook", payload);
    payload = objectMapper.writeValueAsString(new WebhookPersonCreatePayload((long) 1));
    TestUtilities.webhookCall("http://dev.muikku.fi:" + getPortHttp() + "/pyramus/webhook", payload);
    navigate("/login?authSourceId=1", true);
    waitForPresent(".index");
}
Also used : WebhookStudentCreatePayload(fi.otavanopisto.pyramus.webhooks.WebhookStudentCreatePayload) WebhookPersonCreatePayload(fi.otavanopisto.pyramus.webhooks.WebhookPersonCreatePayload) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 30 with JSR310Module

use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.

the class AbstractUITest method createCommunicatorMesssage.

protected void createCommunicatorMesssage(String caption, String content, Long sender, Long recipient) throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Date created = new Date();
    Set<String> tags = new HashSet<>();
    List<Long> recipientIds = new ArrayList<>();
    recipientIds.add(recipient);
    CommunicatorMessage payload = new CommunicatorMessage(null, null, sender, "test", caption, content, created, tags, recipientIds, new ArrayList<Long>(), new ArrayList<Long>(), new ArrayList<Long>());
    Response response = asAdmin().contentType("application/json").body(payload).post("test/communicator/messages");
    response.then().statusCode(200);
    CommunicatorMessage result = objectMapper.readValue(response.asString(), CommunicatorMessage.class);
    assertNotNull(result);
    assertNotNull(result.getId());
}
Also used : Response(com.jayway.restassured.response.Response) CommunicatorMessage(fi.otavanopisto.muikku.atests.CommunicatorMessage) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ArrayList(java.util.ArrayList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Date(java.util.Date) HashSet(java.util.HashSet)

Aggregations

JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)55 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)54 Response (com.jayway.restassured.response.Response)13 OffsetDateTime (java.time.OffsetDateTime)13 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)9 ArrayList (java.util.ArrayList)9 Workspace (fi.otavanopisto.muikku.atests.Workspace)7 Test (org.junit.Test)7 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)6 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)6 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)6 StaffMember (fi.otavanopisto.pyramus.rest.model.StaffMember)6 Course (fi.otavanopisto.pyramus.rest.model.Course)5 Email (fi.otavanopisto.pyramus.rest.model.Email)5 WebhookPersonCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookPersonCreatePayload)5 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)4 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)4 CourseStudent (fi.otavanopisto.pyramus.rest.model.CourseStudent)4 Person (fi.otavanopisto.pyramus.rest.model.Person)4 Student (fi.otavanopisto.pyramus.rest.model.Student)4