BoardServiceTests > SPRING_DATA_JPA

본문 바로가기

사이트 내 전체검색

뒤로가기 SPRING_DATA_JPA

BoardServiceTests

페이지 정보

작성자 관리자 작성일 24-06-18 11:38 조회 462 댓글 0

본문

package web.service;


import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.boot.test.context.SpringBootTest;


import lombok.extern.log4j.Log4j2;

import web.dto.BoardDTO;

import web.dto.PageRequestDTO;

import web.dto.PageResponseDTO;


@SpringBootTest

@Log4j2

public class BoardServiceTests {


@Autowired

private BoardService boardService;


//@Test

public void testRegister() { //등록

log.info(boardService.getClass().getName());

//boardService 변수가 가르키는 객체의 클래스명을 출력하는데

//BoardServiceImpl을 감싸서 만든 클래스 정보가 출력된다.


BoardDTO boardDTO = BoardDTO.builder()

.title("서비스 계층")

.content("이용해 보자")

.writer("홍길동")

.build();


Long bno = boardService.register(boardDTO);


log.info("bno : "+bno);

}


//@Test

public void testReadOne() { //조회

BoardDTO boardDTO = boardService.readOne(102L);


log.info(boardDTO.toString());

}


//@Test

public void testModify() { //수정

BoardDTO boardDTO = BoardDTO.builder()

.bno(102L)

.title("제목을 수정한다.")

.content("내용도 수정하자.")

.build();


boardService.modify(boardDTO);

}

//@Test

public void testRemove() { //삭제

boardService.remove(102L);

}


@Test

public void testList() {

PageRequestDTO pageRequestDTO = PageRequestDTO.builder()

.type("tcw")

.keyword("1")

.page(1)

.size(10)

.build();

PageResponseDTO<BoardDTO> responseDTO = boardService.list(pageRequestDTO);


log.info(responseDTO);

}

}


댓글목록 0

등록된 댓글이 없습니다.


Copyright © dancePKT. All rights reserved.
PC 버전으로 보기