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())));
}
Aggregations