use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project service-proxy by membrane.
the class OAuth2AnswerParameters method getObjectMapper.
private static ObjectMapper getObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JSR310Module());
return mapper;
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class AbstractPyramusMocks method mockPersonStaffMembers.
protected static void mockPersonStaffMembers(StaffMember[] staffMembers) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Map<Long, List<StaffMember>> personStaffMembers = new HashMap<>();
for (StaffMember staffMember : staffMembers) {
if (!personStaffMembers.containsKey(staffMember.getPersonId())) {
personStaffMembers.put(staffMember.getPersonId(), new ArrayList<StaffMember>());
}
personStaffMembers.get(staffMember.getPersonId()).add(staffMember);
}
for (Long personId : personStaffMembers.keySet()) {
stubFor(get(urlMatching(String.format("/1/persons/persons/%d/staffMembers", personId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(personStaffMembers.get(personId))).withStatus(200)));
}
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class AbstractPyramusMocks method mockPersonStudens.
protected static void mockPersonStudens(Student[] students) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Map<Long, List<Student>> personStudents = new HashMap<>();
for (Student student : students) {
if (!personStudents.containsKey(student.getPersonId())) {
personStudents.put(student.getPersonId(), new ArrayList<Student>());
}
personStudents.get(student.getPersonId()).add(student);
}
for (Long personId : personStudents.keySet()) {
stubFor(get(urlMatching(String.format("/1/persons/persons/%d/students", personId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(personStudents.get(personId))).withStatus(200)));
}
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class PyramusMocksRest method mockWorkspaceUsers.
public static void mockWorkspaceUsers(List<String> payloads) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Long courseId = 1l;
Long teacherRoleId = 7l;
CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, 4l, teacherRoleId);
CourseStaffMember[] courseStaffMembers = { courseStaffMember };
stubFor(get(urlEqualTo(String.format("/1/courses/courses/%d/staffMembers", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(courseStaffMembers)).withStatus(200)));
stubFor(get(urlEqualTo(String.format("/1/courses/courses/%d/staffMembers/%d", courseId, courseStaffMember.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(courseStaffMember)).withStatus(200)));
addPayload(payloads, objectMapper.writeValueAsString(new WebhookCourseStaffMemberCreatePayload(courseStaffMember.getId(), courseId, courseStaffMember.getStaffMemberId())));
OffsetDateTime enrolmentTime = OffsetDateTime.of(1999, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
CourseStudent courseStudent = new CourseStudent(2l, courseId, 1l, enrolmentTime, false, null, null, false, null, null);
CourseStudent[] students = { courseStudent };
stubFor(get(urlEqualTo(String.format("/1/courses/courses/%d/students", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(students)).withStatus(200)));
stubFor(get(urlEqualTo(String.format("/1/courses/courses/%d/students/%d", courseId, courseStudent.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(courseStudent)).withStatus(200)));
addPayload(payloads, objectMapper.writeValueAsString(new WebhookCourseStudentCreatePayload(courseStudent.getId(), courseId, courseStudent.getStudentId())));
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class PyramusMocksRest method addPayload.
private static void addPayload(List<String> payloads, Object obj) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
addPayload(payloads, objectMapper.writeValueAsString(obj));
}
Aggregations