Skip to content

Commit

Permalink
Hotel changes fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xsustek committed Oct 30, 2017
1 parent 092773f commit 1d48cee
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public void remove(Hotel hotel) {

@Override
public List<Hotel> findAll() {
return entityManager.createQuery("select h from Hotel h", Hotel.class).setMaxResults(1).getResultList();
return entityManager.createQuery("select h from Hotel h", Hotel.class).getResultList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void setAddress(String address) {

@Override
public int hashCode() {
return Objects.hash(getName(), getAddress(), getRooms());
return Objects.hash(getName(), getAddress());
}

@Override
Expand All @@ -133,8 +133,7 @@ public boolean equals(Object obj) {
Hotel other = (Hotel) obj;

boolean result = other.getName().equals(getName()) &&
other.getAddress().equals(getAddress()) &&
other.getRooms().equals(getRooms());
other.getAddress().equals(getAddress());

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class HotelDaoTest {
@Inject
private HotelDao hotelDao;


@PersistenceContext
EntityManager em;

Expand All @@ -42,12 +43,15 @@ public class HotelDaoTest {
public void create() throws Exception {
Hotel hilton = new Hotel();
hilton.setName("Hilton Hotel");
hilton.setAddress("Hilton street");

Hotel holidayInn = new Hotel();
holidayInn.setName("Holiday Inn");
holidayInn.setAddress("Holiday street");

Hotel bestWestern = new Hotel();
bestWestern.setName("Best Western");
bestWestern.setAddress("Western street");

hotelDao.create(hilton);
hotelDao.create(holidayInn);
Expand All @@ -63,6 +67,7 @@ public void create() throws Exception {
public void findById() throws Exception {
Hotel tatra = new Hotel();
tatra.setName("Hotel Tatra");
tatra.setAddress("Tatra street");
hotelDao.create(tatra);

em.persist(tatra);
Expand All @@ -83,6 +88,7 @@ public void update() throws Exception {

Hotel royal = new Hotel();
royal.setName("Hotel Royal");
royal.setAddress("Royal street");

Set<Room> rooms = new HashSet<Room>();
rooms.add(single);
Expand All @@ -104,12 +110,15 @@ public void update() throws Exception {
public void findAll() throws Exception {
Hotel hilton = new Hotel();
hilton.setName("Hilton Hotel");
hilton.setAddress("Hilton street");

Hotel holidayInn = new Hotel();
holidayInn.setName("Holiday Inn");
holidayInn.setAddress("Holiday street");

Hotel bestWestern = new Hotel();
bestWestern.setName("Best Western");
bestWestern.setAddress("Western street");

hotelDao.create(hilton);
hotelDao.create(holidayInn);
Expand All @@ -123,12 +132,15 @@ public void findAll() throws Exception {
public void remove() throws Exception {
Hotel hilton = new Hotel();
hilton.setName("Hilton Hotel");
hilton.setAddress("Hilton street");

Hotel holidayInn = new Hotel();
holidayInn.setName("Holiday Inn");
holidayInn.setAddress("Holiday street");

Hotel bestWestern = new Hotel();
bestWestern.setName("Best Western");
bestWestern.setAddress("Western street");

hotelDao.create(hilton);
hotelDao.create(holidayInn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public void findAll() throws Exception {
private Reservation getReservation(LocalDateTime from, LocalDateTime to) {
Hotel hotel = new Hotel();
hotel.setName("Hotel");
hotel.setAddress("Brno");

hotelDao.create(hotel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class RoomDaoTest {
public void create() throws Exception {
Hotel tmpHotel = new Hotel();
tmpHotel.setName("Hotel");
tmpHotel.setAddress("Brno");

hotelDao.create(tmpHotel);

Expand All @@ -53,7 +54,7 @@ public void create() throws Exception {
public void findById() throws Exception {
Hotel tmpHotel = new Hotel();
tmpHotel.setName("Hotel");

tmpHotel.setAddress("Brno");
hotelDao.create(tmpHotel);

Room tmpRoom1 = new Room();
Expand All @@ -79,7 +80,7 @@ public void update() throws Exception {

Hotel tmpHotel = new Hotel();
tmpHotel.setName("Hotel");

tmpHotel.setAddress("Brno");
hotelDao.create(tmpHotel);

Room tmpRoom = new Room();
Expand All @@ -101,6 +102,7 @@ public void update() throws Exception {
public void remove() throws Exception {
Hotel tmpHotel = new Hotel();
tmpHotel.setName("Hotel");
tmpHotel.setAddress("Brno");

hotelDao.create(tmpHotel);

Expand Down Expand Up @@ -128,6 +130,7 @@ public void remove() throws Exception {
public void findAll() throws Exception {
Hotel tmpHotel = new Hotel();
tmpHotel.setName("Hotel");
tmpHotel.setAddress("Brno");

hotelDao.create(tmpHotel);

Expand Down

0 comments on commit 1d48cee

Please sign in to comment.