use of fi.otavanopisto.pyramus.rest.model.StudentGroup in project muikku by otavanopisto.
the class PyramusUpdater method updateStudentGroup.
public void updateStudentGroup(Long pyramusId) {
StudentGroup studentGroup = pyramusClient.get().get(String.format("/students/studentGroups/%d", pyramusId), StudentGroup.class);
String identifier = identifierMapper.getStudentGroupIdentifier(pyramusId);
UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityByDataSourceAndIdentifier(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, identifier, true);
if (studentGroup == null) {
if (userGroupEntity != null)
fireUserGroupRemoved(identifier);
} else {
if (userGroupEntity == null) {
fireUserGroupDiscovered(identifier);
} else {
fireUserGroupUpdated(identifier);
}
}
}
use of fi.otavanopisto.pyramus.rest.model.StudentGroup in project muikku by otavanopisto.
the class PyramusMocks method studentGroupsMocks.
public static void studentGroupsMocks() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
OffsetDateTime created = OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC);
OffsetDateTime begin = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
OffsetDateTime lastmodified = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
StudentGroup studentGroupStudents = new StudentGroup((long) 1, "Opiskelijat", "Spring 2015 Students", begin, (long) 1, created, (long) 1, lastmodified, null, false, false);
StudentGroup studentGroupAnother = new StudentGroup((long) 2, "Opiskelijat 2", "Spring 2015 Students 2", begin, (long) 1, created, (long) 1, lastmodified, null, false, false);
StudentGroup[] studentGroupArray = { studentGroupStudents, studentGroupAnother };
String studentGroupsJson = objectMapper.writeValueAsString(studentGroupArray);
stubFor(get(urlMatching("/1/students/studentGroups")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(studentGroupsJson).withStatus(200)));
}
use of fi.otavanopisto.pyramus.rest.model.StudentGroup 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