@Test public void simulationStatusShouldBeSimulationFinishedAfter1Day() throws DateTimeParseException, FileNotFoundException, IOException { // given Mockito.doNothing().when(dataProvider).readDataFromFile(Mockito.anyString()); Mockito.when(dataProvider.getEarliestDate()).thenReturn(LocalDate.parse("2013-01-02")); Mockito.when(dataProvider.getLatestDate()).thenReturn(LocalDate.parse("2013-01-03")); stockExchange.initialise("Test"); // when stockExchange.nextDay(); // then assertEquals(SimulationStatus.SIMULATION_FINISHED, stockExchange.getSimulationStatus()); }
@Test public void nextDayShouldIncrementDateAndCallGetStockByDate() throws DateTimeParseException, FileNotFoundException, IOException { // given Mockito.doNothing().when(dataProvider).readDataFromFile(Mockito.anyString()); Mockito.when(dataProvider.getEarliestDate()).thenReturn(LocalDate.parse("2013-01-02")); Mockito.when(dataProvider.getLatestDate()).thenReturn(LocalDate.parse("2013-01-07")); Mockito.when(dataProvider.getStocksByDate(Mockito.any())) .thenReturn( Arrays.asList( new Stock("TPSA", LocalDate.parse("2013-01-03"), new BigDecimal("12.13")))); stockExchange.initialise("Test"); // when stockExchange.nextDay(); // then Mockito.verify(dataProvider).getStocksByDate(LocalDate.parse("2013-01-03")); assertEquals(SimulationStatus.SIMULATION_NOT_FINISHED, stockExchange.getSimulationStatus()); }