Search in sources :

Example 31 with JSR310Module

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

the class AbstractUITest method createDiscussion.

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

Example 32 with JSR310Module

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

the class AbstractUITest method createFlag.

protected Long createFlag(String name, String color, String description) throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Flag flag = new Flag(null, name, color, description, "STAFF-1/PYRAMUS");
    Response response = asAdmin().contentType("application/json").body(flag).post("/test/flags");
    response.then().statusCode(200);
    Flag result = objectMapper.readValue(response.asString(), Flag.class);
    return result.getId();
}
Also used : Response(com.jayway.restassured.response.Response) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) StudentFlag(fi.otavanopisto.muikku.atests.StudentFlag) Flag(fi.otavanopisto.muikku.atests.Flag) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 33 with JSR310Module

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

the class AbstractUITest method createWorkspaceDiscussionGroup.

protected DiscussionGroup createWorkspaceDiscussionGroup(Long workspaceEntityId, String name) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    DiscussionGroup payload = new DiscussionGroup(null, name);
    Response response = asAdmin().contentType("application/json").body(payload).post("/test/workspaces/{WORKSPACEENTITYID}/discussiongroups", workspaceEntityId);
    response.then().statusCode(200);
    DiscussionGroup workspaceDiscussionGroup = objectMapper.readValue(response.asString(), DiscussionGroup.class);
    assertNotNull(workspaceDiscussionGroup);
    assertNotNull(workspaceDiscussionGroup.getId());
    return workspaceDiscussionGroup;
}
Also used : Response(com.jayway.restassured.response.Response) DiscussionGroup(fi.otavanopisto.muikku.atests.DiscussionGroup) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 34 with JSR310Module

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

the class AbstractUITest method flagStudent.

protected Long flagStudent(Long studentId, Long flagId) throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Response response = asAdmin().contentType("application/json").post("/test/students/{ID}/flags/{FLAGID}", studentId, flagId);
    response.then().statusCode(200);
    StudentFlag result = objectMapper.readValue(response.asString(), StudentFlag.class);
    return result.getId();
}
Also used : Response(com.jayway.restassured.response.Response) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StudentFlag(fi.otavanopisto.muikku.atests.StudentFlag)

Example 35 with JSR310Module

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

the class AbstractUITest method createWorkspace.

protected Workspace createWorkspace(String name, String description, String identifier, Boolean published) throws Exception {
    PyramusMocks.workspacePyramusMock(NumberUtils.createLong(identifier), name, description);
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Workspace payload = new Workspace(null, name, null, "PYRAMUS", identifier, published);
    Response response = asAdmin().contentType("application/json").body(payload).post("/test/workspaces");
    response.then().statusCode(200);
    Workspace workspace = objectMapper.readValue(response.asString(), Workspace.class);
    assertNotNull(workspace);
    assertNotNull(workspace.getId());
    return workspace;
}
Also used : Response(com.jayway.restassured.response.Response) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Workspace(fi.otavanopisto.muikku.atests.Workspace)

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