@Test public void testFindByNullRoomType() { RoomRepo repo = mock(RoomRepo.class); RoomServiceImpl service = new RoomServiceImpl(repo, roomTypes); verify(repo, times(0)).findRoomsByRoomType(any()); RoomServiceException e = assertThrows(RoomServiceException.class, () -> service.findRoomsByType(null)); assertEquals("Room type: null not found!", e.getMessage()); }
@Override public List<Room> findRoomsByType(String type) { if (roomTypes.contains(type)) { return roomRepo.findRoomsByRoomType(type); } else { throw new RoomServiceException("Room type: " + type + " not found!"); } }
RoomServiceImpl implements RoomService { @Override public List<Room> findRoomsByType(String type) { if (roomTypes.contains(type)) { return roomRepo.findRoomsByRoomType(type); } else { throw new RoomServiceException("Room type: " + type + " not found!"); } } }
RoomServiceImpl implements RoomService { @Override public List<Room> findRoomsByType(String type) { if (roomTypes.contains(type)) { return roomRepo.findRoomsByRoomType(type); } else { throw new RoomServiceException("Room type: " + type + " not found!"); } } RoomServiceImpl(RoomRepo roomRepo, List<String> roomTypes); }
RoomServiceImpl implements RoomService { @Override public List<Room> findRoomsByType(String type) { if (roomTypes.contains(type)) { return roomRepo.findRoomsByRoomType(type); } else { throw new RoomServiceException("Room type: " + type + " not found!"); } } RoomServiceImpl(RoomRepo roomRepo, List<String> roomTypes); @Override List<Room> findRoomsByType(String type); @Override List<Room> findRoomsByFloor(String floor); Room addRoom(Room room); }
RoomServiceImpl implements RoomService { @Override public List<Room> findRoomsByType(String type) { if (roomTypes.contains(type)) { return roomRepo.findRoomsByRoomType(type); } else { throw new RoomServiceException("Room type: " + type + " not found!"); } } RoomServiceImpl(RoomRepo roomRepo, List<String> roomTypes); @Override List<Room> findRoomsByType(String type); @Override List<Room> findRoomsByFloor(String floor); Room addRoom(Room room);  }