Search in sources :

Example 6 with Email

use of fi.otavanopisto.pyramus.rest.model.Email in project muikku by otavanopisto.

the class PyramusMocks method mockStaffMember.

@SuppressWarnings("unused")
private static StaffMember mockStaffMember(Long personId, Long staffMemberId, String firstName, String lastName, String email, UserRole role, List<String> tags, Map<String, String> variables, List<String> payloads) throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    StaffMember staffMember = new StaffMember(staffMemberId, personId, null, firstName, lastName, null, role, tags, variables);
    String staffMemberJson = objectMapper.writeValueAsString(staffMember);
    stubFor(get(urlEqualTo("/1/staff/members/" + staffMemberId)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffMemberJson).withStatus(200)));
    StaffMember[] staffMemberArray = { staffMember };
    String staffMemberArrayJson = objectMapper.writeValueAsString(staffMemberArray);
    stubFor(get(urlEqualTo("/1/staff/members?email=" + email)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffMemberArrayJson).withStatus(200)));
    Email staffEmail = new Email(staffMemberId, (long) 1, true, email);
    Email[] staffEmails = { staffEmail };
    String staffEmailJson = objectMapper.writeValueAsString(staffEmails);
    stubFor(get(urlEqualTo("/1/staff/members/" + staffMemberId + "/emails")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffEmailJson).withStatus(200)));
    return staffMember;
}
Also used : Email(fi.otavanopisto.pyramus.rest.model.Email) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) StaffMember(fi.otavanopisto.pyramus.rest.model.StaffMember) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 7 with Email

use of fi.otavanopisto.pyramus.rest.model.Email in project muikku by otavanopisto.

the class PyramusMocksRest method mockStaffMember.

private static StaffMember mockStaffMember(Long personId, Long staffMemberId, String firstName, String lastName, String email, UserRole role, List<String> tags, Map<String, String> variables, List<String> payloads) throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    StaffMember staffMember = new StaffMember(staffMemberId, personId, null, firstName, lastName, null, role, tags, variables);
    String staffMemberJson = objectMapper.writeValueAsString(staffMember);
    stubFor(get(urlEqualTo("/1/staff/members/" + staffMemberId)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffMemberJson).withStatus(200)));
    StaffMember[] staffMemberArray = { staffMember };
    String staffMemberArrayJson = objectMapper.writeValueAsString(staffMemberArray);
    stubFor(get(urlEqualTo("/1/staff/members?email=" + email)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffMemberArrayJson).withStatus(200)));
    Email staffEmail = new Email(staffMemberId, (long) 1, true, email);
    Email[] staffEmails = { staffEmail };
    String staffEmailJson = objectMapper.writeValueAsString(staffEmails);
    stubFor(get(urlEqualTo("/1/staff/members/" + staffMemberId + "/emails")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffEmailJson).withStatus(200)));
    addPayload(payloads, objectMapper.writeValueAsString(new WebhookStaffMemberCreatePayload(staffMember.getId())));
    return staffMember;
}
Also used : Email(fi.otavanopisto.pyramus.rest.model.Email) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) StaffMember(fi.otavanopisto.pyramus.rest.model.StaffMember) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WebhookStaffMemberCreatePayload(fi.otavanopisto.pyramus.webhooks.WebhookStaffMemberCreatePayload)

Aggregations

Email (fi.otavanopisto.pyramus.rest.model.Email)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)5 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)5 StaffMember (fi.otavanopisto.pyramus.rest.model.StaffMember)5 CourseStudent (fi.otavanopisto.pyramus.rest.model.CourseStudent)3 Student (fi.otavanopisto.pyramus.rest.model.Student)3 WebhookStaffMemberCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStaffMemberCreatePayload)3 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)2 ContactType (fi.otavanopisto.pyramus.rest.model.ContactType)2 CourseStaffMemberRole (fi.otavanopisto.pyramus.rest.model.CourseStaffMemberRole)2 Person (fi.otavanopisto.pyramus.rest.model.Person)2 StudentGroupStudent (fi.otavanopisto.pyramus.rest.model.StudentGroupStudent)2 WebhookPersonCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookPersonCreatePayload)2 WebhookStudentCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStudentCreatePayload)2 OffsetDateTime (java.time.OffsetDateTime)2 ArrayList (java.util.ArrayList)2 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)1 RoleSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier)1 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)1