Example #1
0
  @Before
  public void before() {

    expectedCars = new ArrayList<>();
    expectedCars.add(new Car(1, "Moskvich"));

    carsExportMocked = mock(CarsExport.class);
    carsDaoMocked = mock(CarsDao.class);

    carService = new CarServiceImpl();
    carService.setCarsDao(carsDaoMocked);
    carService.setCarsExport(carsExportMocked);

    when(carsDaoMocked.getAllCars()).thenReturn(expectedCars);
  }
Example #2
0
 @Test
 public void testExport() throws Exception {
   carService.export();
   verify(carsDaoMocked).getAllCars();
   verify(carsExportMocked).export(expectedCars);
 }
Example #3
0
  @Test
  public void testGetCars() throws Exception {

    List<Car> actualCars = carService.getCars();
    assertEquals(expectedCars, actualCars);
  }