コード例 #1
0
  @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);
  }
コード例 #2
0
  @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());
  }
コード例 #3
0
 /*
  * 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());
 }
コード例 #4
0
  @Test
  public void testCreateOrUpdateStudentAddMajorsAndMinors() {
    // Grab a test fixture student.
    Student student = studentDao.getStudentById(1000001L);

    // Add a major and some minors.
    Major major = new Major();
    major.setCollegeOrSchool("Science");
    major.setDegree("BS");
    major.setDiscipline("Biology");

    student.getMajors().add(major);
    student.getMinors().add("Physics");
    student.getMinors().add("Chemistry");

    studentDao.createOrUpdateStudent(student);

    // Now re-grab and check.
    student = studentDao.getStudentById(1000001L);
    Assert.assertEquals(1, student.getMajors().size());
    Assert.assertEquals(2, student.getMinors().size());

    Assert.assertEquals("Biology", student.getMajors().get(0).getDiscipline());
    Assert.assertEquals("Physics", student.getMinors().get(0));
    Assert.assertEquals("Chemistry", student.getMinors().get(1));
  }
コード例 #5
0
  @Test
  public void testCreatOrUpdateStudentFoodPreference() {
    Student student = studentDao.getStudentById(1000000L);
    List<String> foodPreference = new ArrayList<String>();
    foodPreference.add("vegetarian");
    foodPreference.add("glutenfree");
    student.setFoodPreference(foodPreference);
    studentDao.createOrUpdateStudent(student);

    student = studentDao.getStudentById(1000000L);

    Assert.assertEquals(foodPreference.get(0), student.getFoodPreference().get(0));
    Assert.assertEquals(foodPreference.get(1), student.getFoodPreference().get(1));
  }
コード例 #6
0
  @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());
  }
コード例 #7
0
  @Test
  public void testGetStudentByIdMajorsAndMinors() {
    // One of the test fixture students has majors and minors.
    Student student = studentDao.getStudentById(1000002L);
    Assert.assertEquals(2, student.getMajors().size());
    Assert.assertEquals(1, student.getMinors().size());

    // Majors and minors are manually ordered.
    Assert.assertEquals("Computer Science", student.getMajors().get(0).getDiscipline());
    Assert.assertEquals("Mathematics", student.getMajors().get(1).getDiscipline());
    Assert.assertEquals("Music", student.getMinors().get(0));
  }
コード例 #8
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.
    }
  }