예제 #1
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));
  }
예제 #2
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));
  }
예제 #3
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.
    }
  }