Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. package repository;
  2.  
  3. import model.Rental;
  4. import model.validators.RentalValidator;
  5. import org.junit.jupiter.api.Test;
  6.  
  7. public class RentalDBRepositoryTest
  8. {
  9. @Test
  10. public void all() {
  11. Repository<Long, Rental> repo = new RentalDBRepository(new RentalValidator());
  12.  
  13. long id = 998;
  14.  
  15. Rental rental = new Rental();
  16. rental.setId(id);
  17. rental.setMovieID((long)1);
  18. rental.setClientID((long)2);
  19. rental.setRentedDate("10/10/2000");
  20. rental.setDueDate("10/11/2001");
  21. rental.setReturnedDate("10/12/2002");
  22.  
  23. repo.save(rental);
  24.  
  25. assert(repo.findOne(id).get().getRentedDate().equals("10/10/2000"));
  26. assert(!repo.findOne((long) 2).isPresent());
  27.  
  28. rental.setRentedDate("10/12/2000");
  29. repo.update(rental);
  30.  
  31. assert(repo.findOne(id).get().getRentedDate().equals("10/12/2000"));
  32.  
  33. assert(repo.delete(id).isPresent());
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement