Search in sources :

Example 16 with BoardDTO

use of com.worksmobile.Assignment.Domain.BoardDTO in project Assignment by WMPeople.

the class VersionManagementService method createTempArticleOverwrite.

// TODO : 임시 게시글 만들기.
@Transactional
public BoardDTO createTempArticleOverwrite(BoardDTO tempArticle) throws IOException {
    // getHistoryByRootId에서 검색이 가능하도록
    tempArticle.setRoot_board_id(tempArticle.getBoard_id());
    BoardDTO dbTempArticle = boardMapper.viewDetail(tempArticle.toMap());
    if (dbTempArticle != null) {
        int articleDeletedCnt = boardMapper.boardDelete(tempArticle.toMap());
        if (articleDeletedCnt != 1) {
            String json = Utils.jsonStringIfExceptionToString(tempArticle);
            throw new RuntimeException("createTempArticleOverwrite메소드에서 임시 게시글 삭제 에러 tempArticle : " + json + "\n" + "articleDeletedCnt : " + articleDeletedCnt);
        }
    }
    tempArticle.setCreated("CURTIMESTAMP 를 넣어야;;;");
    int createdCnt = boardMapper.boardCreate(tempArticle);
    if (createdCnt != 1) {
        String json = Utils.jsonStringIfExceptionToString(tempArticle);
        throw new RuntimeException("createTempArticle에서 게시글 생성 실패 : " + json);
    }
    return null;
}
Also used : BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with BoardDTO

use of com.worksmobile.Assignment.Domain.BoardDTO in project Assignment by WMPeople.

the class BoardHistoryMapperTest method testCreateHistory.

@Test
public void testCreateHistory() throws IOException {
    BoardDTO article = new BoardDTO();
    article.setBoard_id(defaultNodePtrDTO.getBoard_id());
    article.setSubject("testInsert");
    article.setContent("testContent");
    BoardHistoryDTO createdHistoryDTO = new BoardHistoryDTO(article, defaultNodePtrDTO, BoardHistoryDTO.STATUS_CREATED);
    createdHistoryDTO.setHistory_content(Compress.compressArticleContent(article));
    BoardHistoryDTO check = boardHistoryMapper.getHistory(defaultNodePtrDTO);
    if (check != null) {
        boardHistoryMapper.deleteHistory(defaultNodePtrDTO);
    }
    int createdCnt = boardHistoryMapper.createHistory(createdHistoryDTO);
    assertEquals(1, createdCnt);
    BoardHistoryDTO insertedDTO = null;
    insertedDTO = boardHistoryMapper.getHistory(createdHistoryDTO);
    Utils.assertConvertToJsonObject(createdHistoryDTO, insertedDTO);
}
Also used : BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) BoardHistoryDTO(com.worksmobile.Assignment.Domain.BoardHistoryDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 18 with BoardDTO

use of com.worksmobile.Assignment.Domain.BoardDTO in project Assignment by WMPeople.

the class BoardTempMapperTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    BoardDTO beforeVO = new BoardDTO();
    beforeVO.setBoard_id(defaultNodePtr.getBoard_id());
    beforeVO.setVersion(defaultNodePtr.getVersion());
    beforeVO.setSubject("test1111");
    beforeVO.setContent("beforeVal");
    if (null != boardMapper.viewDetail(beforeVO.toMap())) {
        boardMapper.boardDelete(beforeVO.toMap());
    }
    boardMapper.boardCreate(beforeVO);
    BoardDTO afterVO = new BoardDTO();
    afterVO.setBoard_id(defaultNodePtr.getBoard_id());
    afterVO.setVersion(defaultNodePtr.getVersion());
    afterVO.setSubject("after sub");
    afterVO.setContent("after con");
    boardMapper.boardUpdate(afterVO);
    BoardDTO updatedVO = null;
    updatedVO = boardMapper.viewDetail(afterVO.toMap());
    assertEquals(afterVO, updatedVO);
}
Also used : BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) Test(org.junit.Test)

Example 19 with BoardDTO

use of com.worksmobile.Assignment.Domain.BoardDTO in project Assignment by WMPeople.

the class BoardTempMapperTest method testSelect.

@Test
public void testSelect() {
    BoardDTO vo = null;
    vo = boardMapper.viewDetail(defaultNodePtr.toMap());
    assertNotNull(vo);
    assertEquals(defaultNodePtr, vo);
}
Also used : BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) Test(org.junit.Test)

Example 20 with BoardDTO

use of com.worksmobile.Assignment.Domain.BoardDTO in project Assignment by WMPeople.

the class BoardTempMapperTest method testDelete.

@Test
public void testDelete() throws Exception {
    BoardDTO vo = new BoardDTO();
    vo.setBoard_id(defaultNodePtr.getBoard_id());
    vo.setVersion(defaultNodePtr.getVersion());
    vo.setSubject("delete sub");
    vo.setContent("delete con");
    boardMapper.boardCreate(vo);
    boardMapper.boardDelete(vo.toMap());
    BoardDTO deletedVO = null;
    deletedVO = boardMapper.viewDetail(vo.toMap());
    assertNull(deletedVO);
}
Also used : BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) Test(org.junit.Test)

Aggregations

BoardDTO (com.worksmobile.Assignment.Domain.BoardDTO)28 NodePtrDTO (com.worksmobile.Assignment.Domain.NodePtrDTO)13 Test (org.junit.Test)13 BoardHistoryDTO (com.worksmobile.Assignment.Domain.BoardHistoryDTO)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 HashMap (java.util.HashMap)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 Before (org.junit.Before)3 Transactional (org.springframework.transaction.annotation.Transactional)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 FileDTO (com.worksmobile.Assignment.Domain.FileDTO)2 Paging (com.worksmobile.Assignment.Service.Paging)1