Search in sources :

Example 6 with BoardHistoryDTO

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

the class VersionManagementServiceMultiThreadTest method testCreateArticle.

@Test
public void testCreateArticle() throws InterruptedException, ExecutionException, JsonProcessingException {
    for (int i = 0; i < THREAD_COUNT; i++) {
        Thread thread = new Thread(() -> {
            try {
                BoardDTO copyedBoardDTO = new BoardDTO();
                copyedBoardDTO.setSubject(defaultBoardDTO.getSubject());
                copyedBoardDTO.setContent(defaultBoardDTO.getContent());
                BoardHistoryDTO createdHistoryDTO = versionManagementService.createArticle(copyedBoardDTO);
                NodePtrDTO nodePtr = createdHistoryDTO;
                BoardHistoryDTO dbHistoryDTO = boardHistoryMapper.getHistory(nodePtr);
                Utils.assertConvertToJsonObject(createdHistoryDTO, dbHistoryDTO);
                copyedBoardDTO.setNodePtrDTO(nodePtr);
                copyedBoardDTO.setCreated(dbHistoryDTO.getCreated());
                BoardDTO dbBoardDTO = boardMapper.viewDetail(nodePtr.toMap());
                assertEquals(copyedBoardDTO, dbBoardDTO);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        });
        threadList.add(thread);
    }
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) BoardHistoryDTO(com.worksmobile.Assignment.Domain.BoardHistoryDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with BoardHistoryDTO

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

the class RestController method history.

/**
 * 이력 상세보기 입니다.
 * @param board_id 상세 조회 할 게시물의 board_id
 * @param version 상세 조회 할 게시물의 version
 * @return modelAndView 이력의 상세 내용, board-boardHistory 구분자 , file 데이터 , viewName을 리턴합니다.
 */
@RequestMapping(value = "/history/{board_id}/{version}", method = RequestMethod.GET)
@ResponseBody
public ModelAndView history(@PathVariable(value = "board_id") int board_id, @PathVariable(value = "version") int version) {
    NodePtrDTO node = new NodePtrDTO(board_id, version);
    BoardHistoryDTO boardHistory = boardHistoryMapper.getHistory(node);
    BoardDTO board = new BoardDTO(boardHistory);
    FileDTO file = fileMapper.getFile(board.getFile_id());
    String deCompreesedContent = "";
    try {
        deCompreesedContent = Compress.deCompress(boardHistory.getHistory_content());
    } catch (IOException e) {
        e.printStackTrace();
        deCompreesedContent = "압축 해제 실패";
        throw new RuntimeException(e);
    }
    board.setContent(deCompreesedContent);
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("board", board);
    modelAndView.addObject("isHistory", 1);
    modelAndView.addObject("file", file);
    modelAndView.setViewName("boardDetail");
    return modelAndView;
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) FileDTO(com.worksmobile.Assignment.Domain.FileDTO) BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) ModelAndView(org.springframework.web.servlet.ModelAndView) IOException(java.io.IOException) BoardHistoryDTO(com.worksmobile.Assignment.Domain.BoardHistoryDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with BoardHistoryDTO

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

the class VersionManagementTest method testRecoverVersion.

@Test
public void testRecoverVersion() throws InterruptedException, ExecutionException, JsonProcessingException {
    BoardHistoryDTO createdHistoryDTO = versionManagementService.createArticle(defaultBoardDTO);
    NodePtrDTO prevPtrDTO = createdHistoryDTO;
    BoardDTO prevLeapDTO = boardMapper.viewDetail(prevPtrDTO.toMap());
    NodePtrDTO newLeapPtrDTO = versionManagementService.recoverVersion(prevPtrDTO, prevPtrDTO);
    BoardHistoryDTO recoveredHistoryDTO = boardHistoryMapper.getHistory(newLeapPtrDTO);
    BoardDTO newLeapDTO = boardMapper.viewDetail(newLeapPtrDTO.toMap());
    prevLeapDTO.setNodePtrDTO(newLeapPtrDTO);
    assertNotNull(recoveredHistoryDTO);
    Utils.assertConvertToJsonObject(newLeapDTO, prevLeapDTO);
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) BoardDTO(com.worksmobile.Assignment.Domain.BoardDTO) BoardHistoryDTO(com.worksmobile.Assignment.Domain.BoardHistoryDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with BoardHistoryDTO

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

the class VersionManagementTest method testDeleteHasChildrenNode.

@Test
public void testDeleteHasChildrenNode() throws JsonProcessingException {
    NodePtrDTO rootPtrDTO = defaultCreatedDTO;
    NodePtrDTO middlePtrDTO = makeChild(rootPtrDTO);
    int childrenCnt = 10;
    List<NodePtrDTO> childrenList = new ArrayList<>(childrenCnt);
    for (int i = 0; i < childrenCnt; i++) {
        childrenList.add(makeChild(middlePtrDTO));
    }
    versionManagementService.deleteVersion(middlePtrDTO);
    for (NodePtrDTO child : childrenList) {
        BoardHistoryDTO historyDTO = boardHistoryMapper.getHistory(child);
        NodePtrDTO parentPtrDTO = historyDTO.getParentPtrAndRoot();
        assertEquals(rootPtrDTO, parentPtrDTO);
    }
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) ArrayList(java.util.ArrayList) BoardHistoryDTO(com.worksmobile.Assignment.Domain.BoardHistoryDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with BoardHistoryDTO

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

the class VersionManagementTest method testGetRelatedHistory.

@Test
public void testGetRelatedHistory() throws JsonProcessingException, NotLeafNodeException {
    int childrenCnt = 2;
    int allCnt = 1 + 1 + childrenCnt + 1;
    // childrenList에서 1개만 사용
    int relatedCnt = allCnt - (childrenCnt - 1);
    List<NodePtrDTO> nodePtrList = new ArrayList<>(allCnt);
    NodePtrDTO rootPtrDTO = defaultCreatedDTO;
    nodePtrList.add(rootPtrDTO);
    NodePtrDTO hasChildrenPtrDTO = makeChild(rootPtrDTO);
    nodePtrList.add(hasChildrenPtrDTO);
    List<NodePtrDTO> childrenList = new ArrayList<>(childrenCnt);
    for (int i = 0; i < childrenCnt; i++) {
        childrenList.add(makeChild(hasChildrenPtrDTO));
    }
    nodePtrList.addAll(childrenList);
    NodePtrDTO hasChildPtrDTO = childrenList.get(childrenCnt - 1);
    NodePtrDTO leapPtrDTO = makeChild(hasChildPtrDTO);
    nodePtrList.add(leapPtrDTO);
    NodePtrDTO leapPtrDTOWithoutRootBoardId = new NodePtrDTO(leapPtrDTO.getBoard_id(), leapPtrDTO.getVersion());
    List<BoardHistoryDTO> relatedHistoryList = versionManagementService.getRelatedHistory(leapPtrDTOWithoutRootBoardId);
    assertEquals(relatedHistoryList.size(), relatedCnt);
    assertNotNull(relatedHistoryList);
    for (BoardHistoryDTO eleHistoryDTO : relatedHistoryList) {
        assertNotNull(eleHistoryDTO);
        NodePtrDTO eleNodePtr = eleHistoryDTO;
        assertTrue(nodePtrList.contains(eleNodePtr));
    }
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) ArrayList(java.util.ArrayList) BoardHistoryDTO(com.worksmobile.Assignment.Domain.BoardHistoryDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

BoardHistoryDTO (com.worksmobile.Assignment.Domain.BoardHistoryDTO)27 Test (org.junit.Test)17 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)17 NodePtrDTO (com.worksmobile.Assignment.Domain.NodePtrDTO)16 BoardDTO (com.worksmobile.Assignment.Domain.BoardDTO)12 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)4 HashMap (java.util.HashMap)3 Transactional (org.springframework.transaction.annotation.Transactional)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 FileDTO (com.worksmobile.Assignment.Domain.FileDTO)1