@Test
 public void testAddFindAndRemoveStudent() {
   assertTrue(controller.addStudent("testAddFindAndRemoveStudent"));
   Student s = (Student) controller.getStudents().toArray()[0];
   assertNotNull(s);
   assertTrue(controller.removeStudent(s));
   assertNull(controller.getMark(s));
 }
 @Test
 public void testAddMajor() {
   assertTrue(controller.addStudent("testAddMajor"));
   Iterator i = controller.getStudents().iterator();
   Student s = null;
   while (i.hasNext()) s = (Student) i.next();
   assertNotNull(s);
   assertTrue(controller.setMajor(s, new Major()));
   assertTrue(s.getMajor().getId() == 0);
 }
 @BeforeClass
 public static void init() {
   MainController.getInstance();
   controller = StudentController.getInstance();
   major = (MajorDao) DaoFactory.getMajorDao();
   major.create(new Major());
 }
예제 #4
0
  @Test
  public void enrollStudentTest() throws StudentException, ServiceException, PaymentException {

    Mockito.when(
            studentController.newStudent(
                "Ana Julia Costa",
                cpf,
                rg,
                date,
                email,
                address,
                phone1,
                phone2,
                "Maria Julia",
                "Julio Costa"))
        .thenReturn(studentMock);
    Mockito.when(serviceController.newService(studentMock, courses, packages, value))
        .thenReturn(serviceMock);
    Mockito.when(paymentController.newPayment(serviceMock, 1, 1, 1)).thenReturn(paymentMock);

    try {
      enrollController.enrollStudent(
          "Ana Julia Costa",
          cpf,
          rg,
          date,
          email,
          address,
          phone1,
          phone2,
          "Maria Julia",
          "Julio Costa",
          courses,
          packages,
          1,
          1,
          2,
          value);
    } catch (StudentException | ServiceException | PaymentException e) {
      fail("Should not throw this exception: " + e.getMessage());
    }
  }
  @Test
  public void testAddMark() {
    assertTrue(controller.addStudent("testAddMajor"));
    Iterator<Student> i = controller.getStudents().iterator();
    Student s = null;
    while (i.hasNext()) s = (Student) i.next();
    assertNotNull(s);

    assertTrue(controller.addMark(s, new LectureCourse(), 10));
    assertFalse(controller.addMark(s, new LectureCourse(), -1));
    assertFalse(controller.addMark(s, new LectureCourse(), 21));
    assertFalse(controller.addMark(null, new LectureCourse(), 10));
    assertFalse(controller.addMark(s, null, 10));

    // assertTrue(controller.getMark(student).contains(new Mark(student, new LectureCourse(),10)));
  }