use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogicTest method testUpdateFeedbackResponsesForChangingTeam_deleteLastResponse_decreaseResponseRate.
private void testUpdateFeedbackResponsesForChangingTeam_deleteLastResponse_decreaseResponseRate() throws Exception {
FeedbackResponseAttributes responseToBeDeleted = getResponseFromDatastore(questionTypeBundle, "response1ForQ1ContribSession2Course2");
// make sure it's the last response by the student
assertEquals(1, numResponsesFromGiverInSession(responseToBeDeleted.giver, responseToBeDeleted.feedbackSessionName, responseToBeDeleted.courseId));
StudentAttributes student = questionTypeBundle.students.get("student2InCourse2");
StudentEnrollDetails enrollmentDetailsToTriggerDeletion = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, student.course, student.email, student.team, student.team + "tmp", student.section, student.section + "tmp");
int originalResponseRate = getResponseRate(responseToBeDeleted.feedbackSessionName, responseToBeDeleted.courseId);
assertTrue(frLogic.updateFeedbackResponseForChangingTeam(enrollmentDetailsToTriggerDeletion, responseToBeDeleted));
int responseRateAfterDeletion = getResponseRate(responseToBeDeleted.feedbackSessionName, responseToBeDeleted.courseId);
assertEquals(originalResponseRate - 1, responseRateAfterDeletion);
// restore DataStore so other tests are unaffected
restoreStudentFeedbackResponseToDatastore(responseToBeDeleted);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogicTest method testDeleteFeedbackResponsesForStudent.
private void testDeleteFeedbackResponsesForStudent() throws Exception {
______TS("standard delete");
StudentAttributes studentToDelete = dataBundle.students.get("student1InCourse1");
List<FeedbackResponseAttributes> responsesForStudent1 = frLogic.getFeedbackResponsesFromGiverForCourse(studentToDelete.course, studentToDelete.email);
responsesForStudent1.addAll(frLogic.getFeedbackResponsesForReceiverForCourse(studentToDelete.course, studentToDelete.email));
frLogic.deleteFeedbackResponsesForStudentAndCascade(studentToDelete.course, studentToDelete.email);
List<FeedbackResponseAttributes> remainingResponses = new ArrayList<>();
remainingResponses.addAll(frLogic.getFeedbackResponsesFromGiverForCourse(studentToDelete.course, studentToDelete.email));
remainingResponses.addAll(frLogic.getFeedbackResponsesForReceiverForCourse(studentToDelete.course, studentToDelete.email));
assertEquals(remainingResponses.size(), 0);
List<FeedbackResponseCommentAttributes> remainingComments = new ArrayList<>();
for (FeedbackResponseAttributes response : responsesForStudent1) {
remainingComments.addAll(frcLogic.getFeedbackResponseCommentForResponse(response.getId()));
}
assertEquals(remainingComments.size(), 0);
______TS("shift team then delete");
remainingResponses.clear();
studentToDelete = dataBundle.students.get("student2InCourse1");
studentToDelete.team = "Team 1.3";
StudentsLogic.inst().updateStudentCascadeWithoutDocument(studentToDelete.email, studentToDelete);
frLogic.deleteFeedbackResponsesForStudentAndCascade(studentToDelete.course, studentToDelete.email);
remainingResponses.addAll(frLogic.getFeedbackResponsesFromGiverForCourse(studentToDelete.course, studentToDelete.email));
remainingResponses.addAll(frLogic.getFeedbackResponsesForReceiverForCourse(studentToDelete.course, studentToDelete.email));
assertEquals(remainingResponses.size(), 0);
______TS("delete last person in team");
remainingResponses.clear();
studentToDelete = dataBundle.students.get("student5InCourse1");
frLogic.deleteFeedbackResponsesForStudentAndCascade(studentToDelete.course, studentToDelete.email);
remainingResponses.addAll(frLogic.getFeedbackResponsesFromGiverForCourse(studentToDelete.course, studentToDelete.email));
remainingResponses.addAll(frLogic.getFeedbackResponsesForReceiverForCourse(studentToDelete.course, studentToDelete.email));
// check that team responses are gone too. already checked giver as it is stored by giver email not team id.
remainingResponses.addAll(frLogic.getFeedbackResponsesForReceiverForCourse(studentToDelete.course, "Team 1.2"));
assertEquals(remainingResponses.size(), 0);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesDbTest method testUpdateFeedbackResponse.
@Test
public void testUpdateFeedbackResponse() throws Exception {
______TS("null params");
try {
frDb.updateFeedbackResponse(null);
signalFailureToDetectException();
} catch (AssertionError e) {
AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getLocalizedMessage());
}
______TS("invalid feedback response attributes");
FeedbackResponseAttributes invalidFra = getResponseAttributes("response3ForQ2S1C1");
invalidFra.setId(frDb.getFeedbackResponse(invalidFra.feedbackQuestionId, invalidFra.giver, invalidFra.recipient).getId());
invalidFra.courseId = "invalid course_";
try {
frDb.updateFeedbackResponse(invalidFra);
signalFailureToDetectException();
} catch (InvalidParametersException e) {
AssertHelper.assertContains(getPopulatedErrorMessage(FieldValidator.COURSE_ID_ERROR_MESSAGE, "invalid course_", FieldValidator.COURSE_ID_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.COURSE_ID_MAX_LENGTH), e.getLocalizedMessage());
}
______TS("feedback response does not exist");
FeedbackResponseAttributes nonexistantFr = getResponseAttributes("response3ForQ2S1C1");
nonexistantFr.setId("non-existent fr id");
try {
frDb.updateFeedbackResponse(nonexistantFr);
signalFailureToDetectException();
} catch (EntityDoesNotExistException e) {
AssertHelper.assertContains(FeedbackResponsesDb.ERROR_UPDATE_NON_EXISTENT, e.getLocalizedMessage());
}
______TS("standard success case");
FeedbackResponseAttributes modifiedResponse = getResponseAttributes("response3ForQ2S1C1");
modifiedResponse = frDb.getFeedbackResponse(modifiedResponse.feedbackQuestionId, modifiedResponse.giver, modifiedResponse.recipient);
FeedbackResponseDetails frd = modifiedResponse.getResponseDetails();
Map<String, String[]> requestParameters = new HashMap<>();
requestParameters.put("questiontype-1", new String[] { "TEXT" });
requestParameters.put("responsetext-1-0", new String[] { "New answer text!" });
String[] answer = { "New answer text!" };
frd = FeedbackResponseDetails.createResponseDetails(answer, FeedbackQuestionType.TEXT, null, requestParameters, 1, 0);
modifiedResponse.setResponseDetails(frd);
frDb.updateFeedbackResponse(modifiedResponse);
verifyPresentInDatastore(modifiedResponse);
modifiedResponse = frDb.getFeedbackResponse(modifiedResponse.feedbackQuestionId, modifiedResponse.giver, modifiedResponse.recipient);
assertEquals("New answer text!", modifiedResponse.getResponseDetails().getAnswerString());
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesDbTest method getNewFeedbackResponseAttributes.
private FeedbackResponseAttributes getNewFeedbackResponseAttributes() {
FeedbackResponseAttributes fra = new FeedbackResponseAttributes();
fra.feedbackSessionName = "fsTest1";
fra.courseId = "testCourse";
fra.feedbackQuestionType = FeedbackQuestionType.TEXT;
fra.giver = "giver@email.tmt";
fra.giverSection = "None";
fra.recipient = "recipient@email.tmt";
fra.recipientSection = "None";
fra.feedbackQuestionId = "testFeedbackQuestionId";
FeedbackResponseDetails responseDetails = new FeedbackTextResponseDetails("Text response");
fra.setResponseDetails(responseDetails);
return fra;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesDbTest method testCreateDeleteFeedbackResponse.
@Test
public void testCreateDeleteFeedbackResponse() throws Exception {
______TS("standard success case");
FeedbackResponseAttributes fra = getNewFeedbackResponseAttributes();
// remove possibly conflicting entity from the database
frDb.deleteEntity(fra);
frDb.createEntity(fra);
// sets the id for fra
verifyPresentInDatastore(fra);
______TS("duplicate - with same id.");
try {
frDb.createEntity(fra);
signalFailureToDetectException();
} catch (EntityAlreadyExistsException e) {
AssertHelper.assertContains(String.format(FeedbackResponsesDb.ERROR_CREATE_ENTITY_ALREADY_EXISTS, fra.getEntityTypeAsString()) + fra.getIdentificationString(), e.getMessage());
}
______TS("delete - with id specified");
frDb.deleteEntity(fra);
verifyAbsentInDatastore(fra);
______TS("null params");
try {
frDb.createEntity(null);
signalFailureToDetectException();
} catch (AssertionError e) {
AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getLocalizedMessage());
}
______TS("invalid params");
try {
fra.courseId = "invalid course id!";
frDb.createEntity(fra);
signalFailureToDetectException();
} catch (InvalidParametersException e) {
AssertHelper.assertContains(getPopulatedErrorMessage(FieldValidator.COURSE_ID_ERROR_MESSAGE, "invalid course id!", FieldValidator.COURSE_ID_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.COURSE_ID_MAX_LENGTH), e.getLocalizedMessage());
}
}
Aggregations