[게시판생성관리][BBSAttributeManageDAO.insertBBSMasterInf] DAO 단위 테스트

main
이백행 1 year ago
parent 2fda5710b4
commit 1d69c2331c

@ -0,0 +1,67 @@
package egovframework.let.cop.bbs.service.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.egovframe.rte.fdl.idgnr.EgovIdGnrService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import egovframework.let.cop.bbs.service.BoardMaster;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* [][BBSAttributeManageDAO.insertBBSMasterInf] DAO
*
* @author
* @since 2024-09-20
*
*/
@SpringBootTest
@RequiredArgsConstructor
@Slf4j
class BBSAttributeManageDAOTestInsertBBSMasterInfTest {
/**
*
*/
@Autowired
private BBSAttributeManageDAO bbsAttributeManageDAO;
/**
*
*/
@Autowired
private EgovIdGnrService egovBBSMstrIdGnrService;
@Test
void test() throws Exception {
// given
final BoardMaster boardMaster = new BoardMaster();
boardMaster.setBbsId(egovBBSMstrIdGnrService.getNextStringId());
final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS"));
boardMaster.setBbsNm("test 이백행 게시판명 " + now);
boardMaster.setPosblAtchFileSize("0");
final int expected = 1;
// when
final int result = bbsAttributeManageDAO.insertBBSMasterInf(boardMaster);
// then
if (log.isDebugEnabled()) {
log.debug("result={}, {}", expected, result);
}
assertEquals(expected, result, "신규 게시판 속성정보를 등록한다.");
}
}

@ -0,0 +1,63 @@
package egovframework.let.cop.bbs.service.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import egovframework.let.cop.bbs.service.BoardMaster;
import egovframework.let.cop.bbs.service.BoardMasterVO;
import egovframework.let.cop.bbs.service.EgovBBSAttributeManageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* [][EgovBBSUseInfoManageServiceImpl.insertBBSMastetInf] ServiceImpl
*
*
* @author
* @since 2024-09-20
*
*/
@SpringBootTest
@RequiredArgsConstructor
@Slf4j
class EgovBBSUseInfoManageServiceImplTestInsertBBSMastetInfTest {
/**
*
*/
@Autowired
private EgovBBSAttributeManageService egovBBSAttributeManageService;
@Test
void test() throws Exception {
// given
final BoardMaster boardMaster = new BoardMaster();
final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS"));
boardMaster.setBbsNm("test 이백행 게시판명 " + now);
boardMaster.setPosblAtchFileSize("0");
// when
final String result = egovBBSAttributeManageService.insertBBSMastetInf(boardMaster);
// then
final BoardMasterVO resultBoardMasterVO = egovBBSAttributeManageService.selectBBSMasterInf(boardMaster);
if (log.isDebugEnabled()) {
log.debug("result={}", result);
log.debug("resultBoardMasterVO={}", resultBoardMasterVO);
log.debug("getBbsId={}", resultBoardMasterVO.getBbsId());
}
assertEquals(result, resultBoardMasterVO.getBbsId(), "신규 게시판 속성정보를 생성한다.");
}
}

@ -0,0 +1,88 @@
package egovframework.let.cop.bbs.web;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import egovframework.let.cop.bbs.service.BoardMaster;
import egovframework.let.cop.bbs.service.EgovBBSAttributeManageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* [][EgovBBSAttributeManageApiController.insertBBSMasterInf] Controller
*
*
* @author
* @since 2024-09-20
*
*/
@SpringBootTest
@AutoConfigureMockMvc(addFilters = false)
@RequiredArgsConstructor
@Slf4j
class EgovBBSAttributeManageApiControllerTestInsertBBSMasterInfTest {
/**
*
*/
@Autowired
private MockMvc mockMvc;
/**
*
*/
@Autowired
private EgovBBSAttributeManageService egovBBSAttributeManageService;
@Test
void test() throws Exception {
// testData
final BoardMaster boardMaster = new BoardMaster();
final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS"));
boardMaster.setBbsNm("test 이백행 게시판명 " + now);
boardMaster.setPosblAtchFileSize("0");
final String bbsId = egovBBSAttributeManageService.insertBBSMastetInf(boardMaster);
// given
// when
mockMvc.perform(
get("/bbsMaster")
.param("searchCnd", "0")
.param("searchWrd", boardMaster.getBbsNm())
)
.andDo(print())
.andExpect(status().isOk())
;
// then
if (log.isDebugEnabled()) {
log.debug("bbsId={}", bbsId);
}
assertEquals("", "", "게시판 마스터 목록을 조회한다.");
}
}
Loading…
Cancel
Save