BoardRepositoryTest ( 데이터 추가 )
페이지 정보
본문
package web.repository;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.test.annotation.Commit;
import jakarta.transaction.Transactional;
import lombok.extern.log4j.Log4j2;
import web.domain.Board;
import web.domain.BoardImage;
import web.dto.BoardListReplyCountDTO;
@SpringBootTest
@Log4j2
public class BoardRepositoryTest {
@Autowired
private BoardRepository boardRepository;
@Autowired
private ReplyRepository replyRepository;
@Test
public void testInsertAll() {
for(int i=1; i<=100; i++) {
Board board = Board.builder()
.title("제목..."+i)
.content("내용..."+i)
.writer("test"+i)
.build();
for(int j=1; j<3; j++) {
if(i%5 == 0) { //Board 5의 배수
continue;
}
board.addImage(UUID.randomUUID().toString(), i+"file"+j+".jpg");
}
boardRepository.save(board);
}
}
}
댓글목록
등록된 댓글이 없습니다.