@Test public void testFindByValidRoomType() { RoomRepo repo = mock(RoomRepo.class); RoomServiceImpl service = new RoomServiceImpl(repo, roomTypes); when(repo.findRoomsByRoomType("Single")).thenReturn(Arrays.asList( new Room(1L, "100", "Single", new BigDecimal(145.99)))); List<Room> rooms = service.findRoomsByType("Single"); assertEquals(1, rooms.size()); }
@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);  }