use of teammates.logic.core.FeedbackResponsesLogic in project teammates by TEAMMATES.
the class StudentsLogicTest method testAdjustFeedbackResponseForEnrollments.
private void testAdjustFeedbackResponseForEnrollments() throws Exception {
// the case below will not cause the response to be deleted
// because the studentEnrollDetails'email is not the same as giver or recipient
______TS("adjust feedback response: no change of team");
String course1Id = dataBundle.courses.get("typicalCourse1").getId();
StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
StudentAttributes student2InCourse1 = dataBundle.students.get("student2InCourse1");
ArrayList<StudentEnrollDetails> enrollmentList = new ArrayList<>();
StudentEnrollDetails studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, course1Id, student1InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
enrollmentList.add(studentDetails1);
FeedbackResponseAttributes feedbackResponse1InBundle = dataBundle.feedbackResponses.get("response1ForQ2S2C1");
FeedbackResponsesLogic frLogic = FeedbackResponsesLogic.inst();
FeedbackQuestionsLogic fqLogic = FeedbackQuestionsLogic.inst();
FeedbackQuestionAttributes feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
FeedbackResponseAttributes responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
FeedbackResponseAttributes responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
assertEquals(responseBefore.getId(), responseAfter.getId());
// the case below will not cause the response to be deleted
// because the studentEnrollDetails'email is not the same as giver or recipient
______TS("adjust feedback response: unmodified status");
enrollmentList = new ArrayList<>();
studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.UNMODIFIED, course1Id, student1InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
enrollmentList.add(studentDetails1);
feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
assertEquals(responseBefore.getId(), responseAfter.getId());
// the code below will cause the feedback to be deleted because
// recipient's e-mail is the same as the one in studentEnrollDetails
// and the question's recipient's type is own team members
______TS("adjust feedback response: delete after adjustment");
studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, course1Id, student2InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
enrollmentList = new ArrayList<>();
enrollmentList.add(studentDetails1);
feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
assertNull(responseAfter);
}
Aggregations