use of fi.otavanopisto.pyramus.rest.model.StaffMember in project muikku by otavanopisto.
the class PyramusMocks method adminMock.
public static void adminMock() throws Exception {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Map<String, String> variables = null;
List<String> tags = null;
OffsetDateTime birthday = OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC);
Person staff3 = mockPerson((long) 4, birthday, "345345-3453", fi.otavanopisto.pyramus.rest.model.Sex.MALE, (long) 4);
Person[] personArray = { staff3 };
String personArrayJson = objectMapper.writeValueAsString(personArray);
stubFor(get(urlMatching("/1/persons/persons?filterArchived=.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(personArrayJson).withStatus(200)));
stubFor(get(urlEqualTo("/1/persons/persons")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(personArrayJson).withStatus(200)));
StaffMember staffMember3 = new StaffMember((long) 4, (long) 4, null, "Test", "Administrator", null, fi.otavanopisto.pyramus.rest.model.UserRole.ADMINISTRATOR, tags, variables);
String staffMemberJson = objectMapper.writeValueAsString(staffMember3);
stubFor(get(urlEqualTo("/1/staff/members/4")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffMemberJson).withStatus(200)));
StaffMember[] staffMember3Array = { staffMember3 };
String staffMemberArrayJson = objectMapper.writeValueAsString(staffMember3Array);
stubFor(get(urlEqualTo("/1/staff/members?email=admin@example.com")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffMemberArrayJson).withStatus(200)));
StaffMember[] staffArray = { staffMember3 };
String staffArrayJson = objectMapper.writeValueAsString(staffArray);
stubFor(get(urlEqualTo("/1/staff/members")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffArrayJson).withStatus(200)));
staffMemberJson = objectMapper.writeValueAsString(staffMember3);
stubFor(get(urlEqualTo("1/courses/courses/1/staffMembers/4")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staffMemberJson).withStatus(200)));
Email staff3Email = new Email((long) 4, (long) 1, true, "admin@example.com");
Email[] staff3Emails = { staff3Email };
String staff3EmailJson = objectMapper.writeValueAsString(staff3Emails);
stubFor(get(urlEqualTo("/1/staff/members/4/emails")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(staff3EmailJson).withStatus(200)));
CourseStaffMemberRole teacherRole = new CourseStaffMemberRole((long) 8, "Opettaja");
// CourseStaffMemberRole tutorRole = new CourseStaffMemberRole((long) 2, "Tutor");
// CourseStaffMemberRole vRole = new CourseStaffMemberRole((long) 3, "Vastuuhenkilö");
// CourseStaffMemberRole studentRole = new CourseStaffMemberRole((long) 9, "Opiskelija");
CourseStaffMemberRole[] cRoleArray = { teacherRole };
String cRoleJson = objectMapper.writeValueAsString(cRoleArray);
stubFor(get(urlEqualTo("/1/courses/staffMemberRoles")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(cRoleJson).withStatus(200)));
for (CourseStaffMemberRole role : cRoleArray) {
stubFor(get(urlEqualTo(String.format("/1/courses/staffMemberRoles/%d", role.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(role)).withStatus(200)));
}
mockContactTypes();
String payload = objectMapper.writeValueAsString(new WebhookStaffMemberCreatePayload((long) 4));
TestUtilities.webhookCall("http://dev.muikku.fi:" + System.getProperty("it.port.http") + "/pyramus/webhook", payload);
payload = objectMapper.writeValueAsString(new WebhookPersonCreatePayload((long) 4));
TestUtilities.webhookCall("http://dev.muikku.fi:" + System.getProperty("it.port.http") + "/pyramus/webhook", payload);
}
use of fi.otavanopisto.pyramus.rest.model.StaffMember 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;
}
use of fi.otavanopisto.pyramus.rest.model.StaffMember 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;
}
Aggregations