@Test public void recruitersCanSeeJobseekersByJobAndDate() { setupRepositories(); setupActors(); JobPosting developerPosting = recruiter.post(developerJob).to(jobRepository); JobPosting architectPosting = recruiter.post(architectJob).to(jobRepository); TimeServer timeServerOne = Mockito.mock(TimeServer.class); TimeServer timeServerTwo = Mockito.mock(TimeServer.class); Date dayOne = null; Date dayTwo = null; try { dayOne = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse("2013-05-01 12:30:00"); dayTwo = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse("2013-07-04 12:30:00"); } catch (ParseException e) { fail(); } Mockito.when(timeServerOne.getCurrentTime()).thenReturn(dayOne); Mockito.when(timeServerTwo.getCurrentTime()).thenReturn(dayTwo); ApplicationProcessor appProcessorOne = new ApplicationProcessor(appRepo, timeServerOne); ApplicationProcessor appProcessorTwo = new ApplicationProcessor(appRepo, timeServerTwo); boolean applyStatus; applyStatus = jobseekerTom.applyFor(developerPosting).to(appProcessorOne); assertTrue(applyStatus); applyStatus = jobseekerHarry.applyFor(developerPosting).to(appProcessorOne); assertTrue(applyStatus); applyStatus = jobseekerTom.applyFor(architectPosting).to(appProcessorTwo); assertTrue(applyStatus); applyStatus = jobseekerDick.applyFor(architectPosting).to(appProcessorTwo); assertTrue(applyStatus); Applications appsOnDayOne = recruiter.getApplications().filterBy(dayOne).from(appRepo); ApplicationsDisplayer appsDisplayer = Mockito.mock(ApplicationsDisplayer.class); appsOnDayOne.displayTo(appsDisplayer); Mockito.verify(appsDisplayer) .displayApplications(Mockito.argThat(new SetOfTwoAppsWithDates(dayOne))); Applications appsOnDayTwoForArchitect = recruiter.getApplications().filterBy(architectPosting).filterBy(dayTwo).from(appRepo); appsDisplayer = Mockito.mock(ApplicationsDisplayer.class); appsOnDayTwoForArchitect.displayTo(appsDisplayer); Mockito.verify(appsDisplayer) .displayApplications( Mockito.argThat(new SetOfTwoAppsWithJobPostingsAndDates(dayTwo, architectPosting))); }
@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()); } }