@Test
  public void testAddNewOutcomeEvaluationForAssignmentFeedback() {
    Student student = studentDao.getStudentById(1000000L);
    AssignmentRecord r = student.getRecord().getSbgGrades().get(0);
    AssignmentFeedback f = r.getFeedback().get(0);
    Assert.assertEquals(2, f.getGrades().size());

    OutcomeEvaluation grade = new OutcomeEvaluation();
    Outcome o = new Outcome();
    o.setId(100002L); // Should be 'Pipeline outputs between various programs'
    grade.setOutcome(o);
    grade.setComment("Woops");
    f.getGrades().add(grade);

    studentDao.createOrUpdateStudent(student);
    Student student2 = studentDao.getStudentById(1000000L);
    AssignmentRecord r2 = student2.getRecord().getSbgGrades().get(0);
    AssignmentFeedback f2 = r2.getFeedback().get(0);
    Assert.assertEquals(3, f2.getGrades().size());
    OutcomeEvaluation eval = f2.getGrades().get(0);
    Assert.assertEquals("Woops", eval.getComment());
    Assert.assertEquals(
        "Pipeline outputs between various programs", eval.getOutcome().getDescription());
    Assert.assertEquals(Long.valueOf(100002L), eval.getOutcome().getId());
  }
 /*
  * Tests for SBG Student records
  */
 @Test
 public void testCheckStudentSBGGradeRecord() {
   Student student = studentDao.getStudentById(1000000L);
   Assert.assertEquals(1, student.getRecord().getSbgGrades().size());
   AssignmentRecord r = student.getRecord().getSbgGrades().get(0);
   Assert.assertEquals(Long.valueOf(100001L), r.getId());
   Assert.assertEquals(1, r.getFeedback().size());
   AssignmentFeedback f = r.getFeedback().get(0);
   Assert.assertEquals(Long.valueOf(100001L), f.getAssignment().getId());
   Assert.assertEquals(2, f.getGrades().size());
   Assert.assertEquals("Good job!", f.getGrades().get(0).getComment());
   Assert.assertEquals("Needs work...", f.getGrades().get(1).getComment());
 }
  @Test
  public void testCreateOrUpdateStudentGrades() {
    // Build the grade list.
    List<GPA> grades = new ArrayList<GPA>();

    // We leave the correctness of the GET to other unit tests.
    GPA gpa = new GPA();
    gpa.setTerm(Term.SPRING);
    gpa.setYear(2017);
    gpa.setGpa(2.75);
    grades.add(gpa);

    gpa = new GPA();
    gpa.setTerm(Term.SUMMER);
    gpa.setYear(2015);
    gpa.setGpa(2.0);
    grades.add(gpa);

    Student student = studentDao.getStudentById(1000000L);
    student.getRecord().setGrades(grades);
    studentDao.createOrUpdateStudent(student);

    // We check that the grades were indeed saved.
    grades = studentDao.getStudentById(1000000L).getRecord().getGrades();
    Assert.assertEquals(2, grades.size());
    Assert.assertEquals(Term.SUMMER, grades.get(0).getTerm());
    Assert.assertEquals(2015, grades.get(0).getYear());
    Assert.assertEquals(2.0, grades.get(0).getGpa(), 0.0);

    Assert.assertEquals(Term.SPRING, grades.get(1).getTerm());
    Assert.assertEquals(2017, grades.get(1).getYear());
    Assert.assertEquals(2.75, grades.get(1).getGpa(), 0.0);
  }
  @Test
  public void testGetStudentById() {
    // Grab a test fixture student.
    Student student = studentDao.getStudentById(1000000L);
    Assert.assertEquals(Long.valueOf(1000000L), student.getId());
    Assert.assertEquals("Berners-Lee", student.getLastName());
    Assert.assertEquals("Tim", student.getFirstName());
    Assert.assertTrue(student.isActive());
    Assert.assertEquals(Integer.valueOf(2016), student.getExpectedGraduationYear());

    // The text fixture data has some empty values.
    Assert.assertNull(student.getMiddleName());
    Assert.assertNull(student.getEntryYear());
    Assert.assertEquals(0, student.getMajors().size());
    Assert.assertEquals(0, student.getMinors().size());
    Assert.assertEquals(0, student.getRecord().getGrades().size());

    // Grant and event data do not come along for the ride.
    try {
      student.getGrants().size();
      // If this doesn't bork, something is wrong.
      Assert.fail("getGrants should not succeed, but did.");
    } catch (LazyInitializationException lazyInitializationException) {
      // This is what should happen; carry on.
    }

    try {
      student.getAttendance().size();
      // If this doesn't bork, something is wrong.
      Assert.fail("getAttendance should not succeed, but did.");
    } catch (LazyInitializationException lazyInitializationException) {
      // This is what should happen; carry on.
    }
  }
  @Test
  public void testUpdatingAssignmentFeedback() {
    Student student = studentDao.getStudentById(1000000L);
    Assert.assertEquals(1, student.getRecord().getSbgGrades().size());
    AssignmentRecord r = student.getRecord().getSbgGrades().get(0);
    AssignmentFeedback f = r.getFeedback().get(0);
    OutcomeEvaluation eval = f.getGrades().get(0);
    Assert.assertEquals("Good job!", eval.getComment());
    Assert.assertEquals(Long.valueOf(100001L), eval.getId());
    eval.setComment("Bad job!");

    studentDao.createOrUpdateStudent(student);
    Student student2 = studentDao.getStudentById(1000000L);
    AssignmentRecord r2 = student2.getRecord().getSbgGrades().get(0);
    AssignmentFeedback f2 = r2.getFeedback().get(0);
    OutcomeEvaluation eval2 = f2.getGrades().get(0);
    Assert.assertEquals("Bad job!", eval2.getComment());
    Assert.assertEquals(Long.valueOf(100001L), eval2.getId());
  }