Search in sources :

Example 86 with StudentAttributes

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

the class StudentAttributesTest method testIsEnrollInfoSameAs.

@Test
public void testIsEnrollInfoSameAs() {
    StudentAttributes student = StudentAttributes.valueOf(generateTypicalStudentObject());
    StudentAttributes other = StudentAttributes.valueOf(generateTypicalStudentObject());
    ______TS("Typical case: Same enroll info");
    assertTrue(student.isEnrollInfoSameAs(other));
    ______TS("Typical case: Compare to null");
    assertFalse(student.isEnrollInfoSameAs(null));
    ______TS("Typical case: Different in email");
    other.email = "other@email.com";
    assertFalse(student.isEnrollInfoSameAs(other));
    ______TS("Typical case: Different in name");
    other = StudentAttributes.valueOf(generateTypicalStudentObject());
    other.name = "otherName";
    assertFalse(student.isEnrollInfoSameAs(other));
    ______TS("Typical case: Different in course id");
    other = StudentAttributes.valueOf(generateTypicalStudentObject());
    other.course = "otherCourse";
    assertFalse(student.isEnrollInfoSameAs(other));
    ______TS("Typical case: Different in comment");
    other = StudentAttributes.valueOf(generateTypicalStudentObject());
    other.comments = "otherComments";
    assertFalse(student.isEnrollInfoSameAs(other));
    ______TS("Typical case: Different in team");
    other = StudentAttributes.valueOf(generateTypicalStudentObject());
    other.team = "otherTeam";
    assertFalse(student.isEnrollInfoSameAs(other));
    ______TS("Typical case: Different in section");
    other = StudentAttributes.valueOf(generateStudentWithoutSectionObject());
    assertFalse(student.isEnrollInfoSameAs(other));
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 87 with StudentAttributes

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

the class StudentAttributesTest method generateTypicalStudentAttributesList.

private List<StudentAttributes> generateTypicalStudentAttributesList() {
    StudentAttributes studentAttributes1 = StudentAttributes.builder("courseId", "name 1", "email 1").withSection("sect 2").withComments("comment 1").withTeam("team 2").build();
    StudentAttributes studentAttributes2 = StudentAttributes.builder("courseId", "name 2", "email 2").withSection("sect 1").withComments("comment 2").withTeam("team 3").build();
    StudentAttributes studentAttributes3 = StudentAttributes.builder("courseId", "name 2", "email 3").withSection("sect 3").withComments("comment 3").withTeam("team 1").build();
    StudentAttributes studentAttributes4 = StudentAttributes.builder("courseId", "name 4", "email 4").withSection("sect 2").withComments("comment 4").withTeam("team 2").build();
    return Arrays.asList(studentAttributes1, studentAttributes4, studentAttributes3, studentAttributes2);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 88 with StudentAttributes

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

the class AccountsLogicTest method testDeleteAccountCascade.

@Test
public void testDeleteAccountCascade() throws Exception {
    ______TS("typical success case");
    InstructorAttributes instructor = dataBundle.instructors.get("instructor5");
    AccountAttributes account = dataBundle.accounts.get("instructor5");
    // Make instructor account id a student too.
    StudentAttributes student = StudentAttributes.builder(instructor.courseId, instructor.name, "email@com").withSection("section").withTeam("team").withComments("").withGoogleId(instructor.googleId).build();
    studentsLogic.createStudentCascadeWithoutDocument(student);
    verifyPresentInDatastore(account);
    verifyPresentInDatastore(instructor);
    verifyPresentInDatastore(student);
    accountsLogic.deleteAccountCascade(instructor.googleId);
    verifyAbsentInDatastore(account);
    verifyAbsentInDatastore(instructor);
    verifyAbsentInDatastore(student);
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 89 with StudentAttributes

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

the class StudentsDbTest method testDeleteStudent.

@SuppressWarnings("deprecation")
@Test
public void testDeleteStudent() throws InvalidParametersException, EntityDoesNotExistException {
    StudentAttributes s = createNewStudent();
    s.googleId = "validGoogleId";
    studentsDb.updateStudentWithoutSearchability(s.course, s.email, s.name, s.team, s.section, s.email, s.googleId, s.comments);
    // Delete
    studentsDb.deleteStudentWithoutDocument(s.course, s.email);
    StudentAttributes deleted = studentsDb.getStudentForEmail(s.course, s.email);
    assertNull(deleted);
    studentsDb.deleteStudentsForGoogleIdWithoutDocument(s.googleId);
    assertNull(studentsDb.getStudentForGoogleId(s.course, s.googleId));
    int currentStudentNum = studentsDb.getAllStudents().size();
    s = createNewStudent();
    createNewStudent("secondStudent@mail.com");
    assertEquals(2 + currentStudentNum, studentsDb.getAllStudents().size());
    studentsDb.deleteStudentsForCourseWithoutDocument(s.course);
    assertEquals(currentStudentNum, studentsDb.getAllStudents().size());
    // delete again - should fail silently
    studentsDb.deleteStudentWithoutDocument(s.course, s.email);
    // Null params check:
    try {
        studentsDb.deleteStudentWithoutDocument(null, s.email);
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
    try {
        studentsDb.deleteStudentWithoutDocument(s.course, null);
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
    studentsDb.deleteStudent(s.course, s.email);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 90 with StudentAttributes

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

the class BackDoorTest method testDeletion.

@Test
public void testDeletion() {
    // ----------deleting Instructor entities-------------------------
    InstructorAttributes instructor1OfCourse1 = dataBundle.instructors.get("instructor2OfCourse2");
    verifyPresentInDatastore(instructor1OfCourse1);
    String status = BackDoor.deleteInstructor(instructor1OfCourse1.courseId, instructor1OfCourse1.email);
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(instructor1OfCourse1);
    // try to delete again: should indicate as success because delete fails silently.
    status = BackDoor.deleteInstructor(instructor1OfCourse1.email, instructor1OfCourse1.courseId);
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    // ----------deleting Feedback Response entities-------------------------
    FeedbackQuestionAttributes fq = dataBundle.feedbackQuestions.get("qn2InSession1InCourse1");
    FeedbackResponseAttributes fr = dataBundle.feedbackResponses.get("response1ForQ2S1C1");
    fq = BackDoor.getFeedbackQuestion(fq.courseId, fq.feedbackSessionName, fq.questionNumber);
    fr = BackDoor.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    verifyPresentInDatastore(fr);
    status = BackDoor.deleteFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(fr);
    // ----------deleting Feedback Question entities-------------------------
    fq = dataBundle.feedbackQuestions.get("qn5InSession1InCourse1");
    verifyPresentInDatastore(fq);
    status = BackDoor.deleteFeedbackQuestion(fq.getId());
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(fq);
    // ----------deleting Course entities-------------------------
    // #COURSE 2
    CourseAttributes course2 = dataBundle.courses.get("typicalCourse2");
    verifyPresentInDatastore(course2);
    status = BackDoor.deleteCourse(course2.getId());
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(course2);
    // check if related student entities are also deleted
    StudentAttributes student2InCourse2 = dataBundle.students.get("student2InCourse2");
    verifyAbsentInDatastore(student2InCourse2);
    // #COURSE 1
    CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
    verifyPresentInDatastore(course1);
    status = BackDoor.deleteCourse(course1.getId());
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(course1);
    // check if related student entities are also deleted
    StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
    verifyAbsentInDatastore(student1InCourse1);
    // #COURSE NO EVALS
    CourseAttributes courseNoEvals = dataBundle.courses.get("courseNoEvals");
    verifyPresentInDatastore(courseNoEvals);
    status = BackDoor.deleteCourse(courseNoEvals.getId());
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(courseNoEvals);
// ----------deleting Feedback Session entities-------------------------
// TODO: do proper deletion test
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Aggregations

StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)241 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)85 Test (org.testng.annotations.Test)80 ArrayList (java.util.ArrayList)55 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)33 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)33 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)22 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)17 ShowPageResult (teammates.ui.controller.ShowPageResult)15 HashMap (java.util.HashMap)14 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)14 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 EmailWrapper (teammates.common.util.EmailWrapper)13 RedirectResult (teammates.ui.controller.RedirectResult)12 List (java.util.List)11 StatusMessage (teammates.common.util.StatusMessage)10 HashSet (java.util.HashSet)9 StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9