Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. @RunWith(SpringRunner.class)
  2. @SpringBootTest(classes = TudKserockiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  3. public class CarControllerIntegrationTests {
  4.  
  5.     private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  6.     private DBHandler dbHandler = new DBHandler();
  7.  
  8.     @Autowired
  9.     CarService carService;
  10.  
  11.     @Test
  12.     public void testGetCarById() throws SQLException {
  13.         Car car = carService.getCarById(0, dbHandler);
  14.         System.out.println(car.getId());
  15.         assertNotNull(car);
  16.     }
  17.  
  18.     @Test
  19.     public void testCreateCar() throws SQLException {
  20.         Car car = new Car();
  21.         car.setCar_brand("Ford");
  22.         car.setReg_number("CG5291A");
  23.         car.setState(5);
  24.         car.setLast_used(dateFormat.format(new Date()));
  25.         String result = carService.addCar(car, dbHandler);
  26.         assertNotEquals(result, "error");
  27.     }
  28.  
  29.     @Test
  30.     public void testGetAllCars() throws SQLException {
  31.         List<Car> carList = carService.getAllCars(dbHandler);
  32.         assertNotNull(carList);
  33.     }
  34.  
  35.     @Test
  36.     public void testUpdateCar() throws SQLException, ParseException {
  37.         Car car = carService.getCarById(2, dbHandler);
  38.         assertNotNull(car);
  39.         car.setReg_number("CG12345");
  40.         String result = carService.editCar(car, dbHandler);
  41.         assertNotEquals(result, "error");
  42.     }
  43.  
  44.     @Test
  45.     public void testDeleteCar() throws SQLException {
  46.         Car car = carService.getCarById(0, dbHandler);
  47.         assertNotNull(car);
  48.         String result = carService.deleteCar(0, dbHandler);
  49.         assertNotEquals(result, "error");
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement