Search in sources :

Example 26 with FeedbackResponseCommentAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.

the class FeedbackResponsesLogicTest method testUpdateFeedbackResponsesForChangingEmail.

private void testUpdateFeedbackResponsesForChangingEmail() throws Exception {
    ______TS("standard update email case");
    // Student 1 currently has 2 responses to him and 2 from himself.
    // Student 1 currently has 1 response comment for responses to him
    // and 1 response comment from responses from himself.
    StudentAttributes studentToUpdate = dataBundle.students.get("student1InCourse1");
    List<FeedbackResponseAttributes> responsesForReceiver = frLogic.getFeedbackResponsesForReceiverForCourse(studentToUpdate.course, studentToUpdate.email);
    List<FeedbackResponseAttributes> responsesFromGiver = frLogic.getFeedbackResponsesFromGiverForCourse(studentToUpdate.course, studentToUpdate.email);
    List<FeedbackResponseAttributes> responsesToAndFromStudent = new ArrayList<>();
    responsesToAndFromStudent.addAll(responsesForReceiver);
    responsesToAndFromStudent.addAll(responsesFromGiver);
    List<FeedbackResponseCommentAttributes> responseCommentsForStudent = getFeedbackResponseCommentsForResponsesFromDatastore(responsesToAndFromStudent);
    assertEquals(responsesForReceiver.size(), 2);
    assertEquals(responsesFromGiver.size(), 2);
    assertEquals(responseCommentsForStudent.size(), 2);
    frLogic.updateFeedbackResponsesForChangingEmail(studentToUpdate.course, studentToUpdate.email, "new@email.tmt");
    responsesForReceiver = frLogic.getFeedbackResponsesForReceiverForCourse(studentToUpdate.course, studentToUpdate.email);
    responsesFromGiver = frLogic.getFeedbackResponsesFromGiverForCourse(studentToUpdate.course, studentToUpdate.email);
    responsesToAndFromStudent = new ArrayList<>();
    responsesToAndFromStudent.addAll(responsesForReceiver);
    responsesToAndFromStudent.addAll(responsesFromGiver);
    responseCommentsForStudent = getFeedbackResponseCommentsForResponsesFromDatastore(responsesToAndFromStudent);
    assertEquals(responsesForReceiver.size(), 0);
    assertEquals(responsesFromGiver.size(), 0);
    assertEquals(responseCommentsForStudent.size(), 0);
    responsesForReceiver = frLogic.getFeedbackResponsesForReceiverForCourse(studentToUpdate.course, "new@email.tmt");
    responsesFromGiver = frLogic.getFeedbackResponsesFromGiverForCourse(studentToUpdate.course, "new@email.tmt");
    responsesToAndFromStudent = new ArrayList<>();
    responsesToAndFromStudent.addAll(responsesForReceiver);
    responsesToAndFromStudent.addAll(responsesFromGiver);
    responseCommentsForStudent = getFeedbackResponseCommentsForResponsesFromDatastore(responsesToAndFromStudent);
    assertEquals(responsesForReceiver.size(), 2);
    assertEquals(responsesFromGiver.size(), 2);
    assertEquals(responseCommentsForStudent.size(), 2);
    frLogic.updateFeedbackResponsesForChangingEmail(studentToUpdate.course, "new@email.tmt", studentToUpdate.email);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 27 with FeedbackResponseCommentAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes 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);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 28 with FeedbackResponseCommentAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.

the class FeedbackResponseCommentsDbTest method testGetFeedbackResponseCommentFromId.

private void testGetFeedbackResponseCommentFromId() {
    ______TS("null parameter");
    try {
        frcDb.getFeedbackResponseComment(null);
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
    ______TS("typical success case");
    FeedbackResponseCommentAttributes frcaExpected = frcDb.getFeedbackResponseComment(frcaData.courseId, frcaData.createdAt, frcaData.giverEmail);
    FeedbackResponseCommentAttributes frcaActual = frcDb.getFeedbackResponseComment(frcaExpected.getId());
    assertEquals(frcaExpected.toString(), frcaActual.toString());
    ______TS("non-existent comment");
    assertNull(frcDb.getFeedbackResponseComment(-1L));
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)

Example 29 with FeedbackResponseCommentAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.

the class FeedbackResponseCommentsDbTest method testUpdateFeedbackResponseCommentsGiverEmail.

private void testUpdateFeedbackResponseCommentsGiverEmail() throws InvalidParametersException, EntityAlreadyExistsException {
    FeedbackResponseCommentAttributes frcaDataOfNewGiver = dataBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q3S1C1");
    String giverEmail = "frcdb.newGiver@email.com";
    String courseId = "frcdb.giver.courseId";
    Instant createdAt = Instant.now();
    frcaDataOfNewGiver.createdAt = createdAt;
    frcaDataOfNewGiver.commentText = new Text("another comment for this response");
    frcaDataOfNewGiver.setId(null);
    frcaDataOfNewGiver.giverEmail = giverEmail;
    frcaDataOfNewGiver.courseId = courseId;
    frcDb.createEntity(frcaDataOfNewGiver);
    assertNotNull(frcDb.getFeedbackResponseComment(courseId, createdAt, giverEmail));
    ______TS("typical success case");
    String updatedEmail = "frcdb.updatedGiver@email.com";
    frcDb.updateGiverEmailOfFeedbackResponseComments(courseId, giverEmail, updatedEmail);
    assertNull(frcDb.getFeedbackResponseComment(courseId, createdAt, giverEmail));
    assertNotNull(frcDb.getFeedbackResponseComment(courseId, createdAt, updatedEmail));
    ______TS("Same email");
    FeedbackResponseCommentAttributes expectedFrca = frcDb.getFeedbackResponseComment(courseId, createdAt, updatedEmail);
    frcDb.updateGiverEmailOfFeedbackResponseComments(courseId, updatedEmail, updatedEmail);
    FeedbackResponseCommentAttributes actualFrca = frcDb.getFeedbackResponseComment(courseId, createdAt, updatedEmail);
    assertEquals(actualFrca.courseId, expectedFrca.courseId);
    assertEquals(actualFrca.createdAt, expectedFrca.createdAt);
    assertEquals(actualFrca.giverEmail, expectedFrca.giverEmail);
    ______TS("null parameter");
    try {
        frcDb.updateGiverEmailOfFeedbackResponseComments(null, giverEmail, updatedEmail);
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
    try {
        frcDb.updateGiverEmailOfFeedbackResponseComments(courseId, null, updatedEmail);
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
    try {
        frcDb.updateGiverEmailOfFeedbackResponseComments(courseId, giverEmail, null);
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) Instant(java.time.Instant) Text(com.google.appengine.api.datastore.Text)

Example 30 with FeedbackResponseCommentAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.

the class FeedbackResponseCommentsDbTest method testDeleteFeedbackResponseCommentsForResponse.

private void testDeleteFeedbackResponseCommentsForResponse() throws InvalidParametersException, EntityAlreadyExistsException {
    ______TS("typical success case");
    // get another frc from data bundle and use it to create another feedback response
    FeedbackResponseCommentAttributes tempFrcaData = dataBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q2S1C1");
    tempFrcaData.createdAt = Instant.now();
    tempFrcaData.commentText = new Text("another comment for this response");
    // for some reason, the id is 0 instead of null. so we explicitly set it to be null
    tempFrcaData.setId(null);
    // set this comment to have the same responseId as frcaData
    String responseId = "1%student1InCourse1@gmail.com%student1InCourse1@gmail.com";
    tempFrcaData.feedbackResponseId = responseId;
    frcDb.createEntity(tempFrcaData);
    frcDb.deleteFeedbackResponseCommentsForResponse(responseId);
    assertEquals(frcDb.getFeedbackResponseCommentsForResponse(responseId).size(), 0);
    ______TS("null parameter");
    try {
        frcDb.deleteFeedbackResponseCommentsForResponse(null);
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) Text(com.google.appengine.api.datastore.Text)

Aggregations

FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)46 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)15 Test (org.testng.annotations.Test)13 Text (com.google.appengine.api.datastore.Text)12 ArrayList (java.util.ArrayList)12 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)9 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)9 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)9 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)6 FeedbackResponseCommentsDb (teammates.storage.api.FeedbackResponseCommentsDb)6 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)5 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)5 InstructorFeedbackResponseCommentAjaxPageData (teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData)4 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)4 InvalidParametersException (teammates.common.exception.InvalidParametersException)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 FeedbackResponseCommentSearchResultBundle (teammates.common.datatransfer.FeedbackResponseCommentSearchResultBundle)2 FeedbackSessionResultsBundle (teammates.common.datatransfer.FeedbackSessionResultsBundle)2