BookQueryRepository { public List<BookPageDto> getBookPage (int bookNo, int pageNo) { return queryFactory .select(Projections.fields(BookPageDto.class, book.name, Expressions.asNumber(pageNo).as("pageNo"), Expressions.asNumber(bookNo).as(book.bookNo) )) .from(book) .where(book.bookNo.eq(bookNo)) .offset(pageNo) .limit(10) .fetch(); }  @Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) Book getBookById(Long bookId); @Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) String getBookNameById(Long bookId); @Transactional(readOnly = true) Boolean exist(Long bookId); List<BookPageDto> getBookPage(int bookNo, int pageNo);  }
@Test void 상수값을_사용한다() throws Exception { int bookNo = 1; for (int i = 1; i <= 10; i++) { bookRepository.save(Book.builder() .name("a"+i) .bookNo(bookNo) .build()); } List<BookPageDto> bookPages = bookQueryRepository.getBookPage(bookNo, 0); assertThat(bookPages).hasSize(10); assertThat(bookPages.get(0).getPageNo()).isEqualTo(0); assertThat(bookPages.get(0).getBookNo()).isEqualTo(bookNo); }