@Test public void getRoom() { assertNull(manager.getRoom(1l)); Room room = newRoom(RoomType.bungalow, 4); manager.createRoom(room); Long roomId = room.getId(); Room result = manager.getRoom(roomId); assertEquals(room, result); assertRoomDeepEquals(room, result); }
@Test public void deleteRoom() { Room g1 = newRoom(RoomType.bungalow, 4); Room g2 = newRoom(RoomType.apartment, 2); manager.createRoom(g1); manager.createRoom(g2); assertNotNull(manager.getRoom(g1.getId())); assertNotNull(manager.getRoom(g2.getId())); manager.deleteRoom(g1); assertNull(manager.getRoom(g1.getId())); assertNotNull(manager.getRoom(g2.getId())); }
@Test(expected = IllegalArgumentException.class) public void deleteRoomNullId() { Room room = newRoom(RoomType.bungalow, 4); manager.createRoom(room); Long roomId = room.getId(); room = manager.getRoom(roomId); room.setId(null); manager.deleteRoom(room); }
@Test(expected = IllegalArgumentException.class) public void updateRoomNegativeCapacity() { Room room = newRoom(RoomType.bungalow, 4); manager.createRoom(room); Long roomId = room.getId(); room = manager.getRoom(roomId); room.setCapacity(-1); manager.updateRoom(room); }
@Test public void updateRoom() { Room room = newRoom(RoomType.bungalow, 4); Room g2 = newRoom(RoomType.apartment, 2); manager.createRoom(room); manager.createRoom(g2); Long roomId = room.getId(); room.setType(RoomType.apartment); manager.updateRoom(room); room = manager.getRoom(roomId); assertEquals(RoomType.apartment, room.getType()); assertEquals(4, room.getCapacity()); room.setCapacity(2); manager.updateRoom(room); room = manager.getRoom(roomId); assertEquals(RoomType.apartment, room.getType()); assertEquals(2, room.getCapacity()); // Check if updates didn't affected other records assertRoomDeepEquals(g2, manager.getRoom(g2.getId())); }