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);
}
}
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));
}
}
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);
}
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);
}
}
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);
}
Aggregations