Search in sources :

Example 1 with WebhookStudentGroupStaffMemberCreatePayload

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

the class PyramusMocksRest method mockUserGroups.

public static void mockUserGroups(List<String> payloads) throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    OffsetDateTime begin = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
    Long creatorId = 1l;
    Long groupId = 2l;
    StudentGroup studentGroup = new StudentGroup(groupId, "Group1", "", begin, creatorId, begin, creatorId, begin, null, false, false);
    StudentGroup[] studentGroups = new StudentGroup[] { studentGroup };
    stubFor(get(urlEqualTo("/1/students/studentGroups")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(studentGroups)).withStatus(200)));
    stubFor(get(urlEqualTo(String.format("/1/students/studentGroups/%d", groupId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(studentGroup)).withStatus(200)));
    addPayload(payloads, objectMapper.writeValueAsString(new WebhookStudentGroupCreatePayload(groupId)));
    StudentGroupUser studentGroupStaffMember = new StudentGroupUser(1l, 4l);
    StudentGroupUser[] studentGroupStaffMembers = { studentGroupStaffMember };
    stubFor(get(urlEqualTo(String.format("/1/students/studentGroups/%d/staffmembers", groupId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(studentGroupStaffMembers)).withStatus(200)));
    stubFor(get(urlEqualTo(String.format("/1/students/studentGroups/%d/staffmembers/%d", groupId, studentGroupStaffMember.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(studentGroupStaffMember)).withStatus(200)));
    addPayload(payloads, objectMapper.writeValueAsString(new WebhookStudentGroupStaffMemberCreatePayload(studentGroupStaffMember.getId(), groupId, studentGroupStaffMember.getStaffMemberId())));
    StudentGroupStudent studentGroupStudent = new StudentGroupStudent(2l, 1l);
    StudentGroupStudent[] studentGroupStudents = { studentGroupStudent };
    stubFor(get(urlEqualTo(String.format("/1/students/studentGroups/%d/students", groupId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(studentGroupStudents)).withStatus(200)));
    stubFor(get(urlEqualTo(String.format("/1/students/studentGroups/%d/students/%d", groupId, studentGroupStudent.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(studentGroupStudent)).withStatus(200)));
    addPayload(payloads, objectMapper.writeValueAsString(new WebhookStudentGroupStudentCreatePayload(studentGroupStudent.getId(), groupId, studentGroupStudent.getStudentId())));
}
Also used : WebhookStudentGroupCreatePayload(fi.otavanopisto.pyramus.webhooks.WebhookStudentGroupCreatePayload) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) WebhookStudentGroupStudentCreatePayload(fi.otavanopisto.pyramus.webhooks.WebhookStudentGroupStudentCreatePayload) StudentGroupStudent(fi.otavanopisto.pyramus.rest.model.StudentGroupStudent) OffsetDateTime(java.time.OffsetDateTime) StudentGroupUser(fi.otavanopisto.pyramus.rest.model.StudentGroupUser) WebhookStudentGroupStaffMemberCreatePayload(fi.otavanopisto.pyramus.webhooks.WebhookStudentGroupStaffMemberCreatePayload) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StudentGroup(fi.otavanopisto.pyramus.rest.model.StudentGroup)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)1 StudentGroup (fi.otavanopisto.pyramus.rest.model.StudentGroup)1 StudentGroupStudent (fi.otavanopisto.pyramus.rest.model.StudentGroupStudent)1 StudentGroupUser (fi.otavanopisto.pyramus.rest.model.StudentGroupUser)1 WebhookStudentGroupCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStudentGroupCreatePayload)1 WebhookStudentGroupStaffMemberCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStudentGroupStaffMemberCreatePayload)1 WebhookStudentGroupStudentCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStudentGroupStudentCreatePayload)1 OffsetDateTime (java.time.OffsetDateTime)1