Search in sources :

Example 11 with NodePtrDTO

use of com.worksmobile.Assignment.Domain.NodePtrDTO 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 12 with NodePtrDTO

use of com.worksmobile.Assignment.Domain.NodePtrDTO 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)

Example 13 with NodePtrDTO

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

the class VersionManagementTest method testDeleteWhenHasChildNode.

@Test
public void testDeleteWhenHasChildNode() throws JsonProcessingException {
    NodePtrDTO rootPtrDTO = defaultCreatedDTO;
    NodePtrDTO middlePtrDTO = makeChild(rootPtrDTO);
    NodePtrDTO childPtrDTO = makeChild(middlePtrDTO);
    versionManagementService.deleteVersion(middlePtrDTO);
    BoardHistoryDTO childHistoryDTO = boardHistoryMapper.getHistory(childPtrDTO);
    NodePtrDTO childParentPtrDTO = childHistoryDTO.getParentPtrAndRoot();
    assertEquals(rootPtrDTO, childParentPtrDTO);
}
Also used : NodePtrDTO(com.worksmobile.Assignment.Domain.NodePtrDTO) BoardHistoryDTO(com.worksmobile.Assignment.Domain.BoardHistoryDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with NodePtrDTO

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

the class VersionManagementTest method testGetRelatedHistoryWhenDifferentBoardId.

@Test
public void testGetRelatedHistoryWhenDifferentBoardId() throws JsonProcessingException, NotLeafNodeException {
    List<NodePtrDTO> leafToRoot = new ArrayList<>();
    NodePtrDTO rootPtrDTO = defaultCreatedDTO;
    leafToRoot.add(rootPtrDTO);
    @SuppressWarnings("unused") NodePtrDTO middle1 = makeChild(rootPtrDTO);
    NodePtrDTO middle2 = makeChild(rootPtrDTO);
    leafToRoot.add(middle2);
    NodePtrDTO child = makeChild(middle2);
    leafToRoot.add(child);
    List<BoardHistoryDTO> relatedHistoryList = versionManagementService.getRelatedHistory(child);
    assertEquals(relatedHistoryList.size(), leafToRoot.size());
    leafToRoot.sort(compareNodePtrDTO);
    relatedHistoryList.sort(compareNodePtrDTO);
    for (int i = 0; i < relatedHistoryList.size(); i++) {
        NodePtrDTO relatedEle = relatedHistoryList.get(i);
        NodePtrDTO addedEle = leafToRoot.get(i);
        assertEquals(relatedEle, addedEle);
    }
}
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 15 with NodePtrDTO

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

the class VersionManagementTest method testCreateSevenHundredThousandTextContentArticle.

@Test
public void testCreateSevenHundredThousandTextContentArticle() throws JsonProcessingException, InterruptedException, ExecutionException {
    StringBuilder sevenHundredContent = new StringBuilder();
    for (int i = 0; i < 700000; i++) {
        sevenHundredContent.append(i % 10);
    }
    defaultBoardDTO = new BoardDTO();
    defaultBoardDTO.setSubject("칠십만자가 들어가있습니다");
    defaultBoardDTO.setContent(sevenHundredContent.toString());
    defaultCreatedDTO = versionManagementService.createArticle(defaultBoardDTO);
    NodePtrDTO nodePtr = defaultCreatedDTO;
    BoardHistoryDTO dbHistoryDTO = boardHistoryMapper.getHistory(nodePtr);
    Utils.assertConvertToJsonObject(defaultCreatedDTO, dbHistoryDTO);
    defaultBoardDTO.setNodePtrDTO(nodePtr);
    defaultBoardDTO.setCreated(dbHistoryDTO.getCreated());
    BoardDTO dbBoardDTO = boardMapper.viewDetail(nodePtr.toMap());
    Utils.assertConvertToJsonObject(defaultBoardDTO, dbBoardDTO);
}
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)

Aggregations

NodePtrDTO (com.worksmobile.Assignment.Domain.NodePtrDTO)29 BoardHistoryDTO (com.worksmobile.Assignment.Domain.BoardHistoryDTO)16 Test (org.junit.Test)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 BoardDTO (com.worksmobile.Assignment.Domain.BoardDTO)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 ModelAndView (org.springframework.web.servlet.ModelAndView)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 FileDTO (com.worksmobile.Assignment.Domain.FileDTO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 MultipartFile (org.springframework.web.multipart.MultipartFile)1