@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()); } }