use of com.worksmobile.Assignment.Domain.BoardHistoryDTO 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.BoardHistoryDTO 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.BoardHistoryDTO 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);
}
use of com.worksmobile.Assignment.Domain.BoardHistoryDTO in project Assignment by WMPeople.
the class VersionManagementService method createArticleAndHistory.
/**
* 충돌 영역! 게시판 DB 와 이력 DB 에 둘다 등록합니다.
* 게시판 id를 1증가 시켜 작성합니다.
* @param article 등록할 게시물의 제목, 내용, 첨부파일이 사용됩니다.
* @param version 새로운 게시물의 버전
* @param status 게시물 이력의 상태에 들어갈 내용
* @param compressedContent 압축된 내용
* @param parentNodePtr 게시물의 부모 노드 포인터
* @return 새롭게 생성된 게시글 이력 DTO
*/
private synchronized BoardHistoryDTO createArticleAndHistory(BoardDTO article, int version, final String status, final byte[] compressedContent, final NodePtrDTO parentNodePtr) {
int last_board_id = boardMapper.getMaxBoardId() + 1;
NodePtrDTO newNodePtrDTO = new NodePtrDTO(last_board_id, version);
if (parentNodePtr.getRoot_board_id() == 0) {
parentNodePtr.setRoot_board_id(last_board_id);
}
BoardHistoryDTO boardHistoryDTO;
if (version == 0) {
BoardHistoryDTO rootHistoryDTO = new BoardHistoryDTO(new BoardDTO(), newNodePtrDTO, BoardHistoryDTO.STATUS_ROOT);
int insertedRowCnt = boardHistoryMapper.createHistory(rootHistoryDTO);
if (insertedRowCnt != 1) {
String json = Utils.jsonStringIfExceptionToString(rootHistoryDTO);
throw new RuntimeException("createArticleAndHistory메소드에서 게시글 이력 추가 에러 insertedRowCnt : " + insertedRowCnt + "\ndeletePtrDTO : " + json);
}
boardHistoryDTO = new BoardHistoryDTO(article, newNodePtrDTO, status);
boardHistoryDTO.setVersion(1);
boardHistoryDTO.setHistory_content(compressedContent);
boardHistoryDTO.setParentNodePtrAndRoot(rootHistoryDTO);
boardHistoryDTO.setRoot_board_id(newNodePtrDTO.getBoard_id());
insertedRowCnt = boardHistoryMapper.createHistory(boardHistoryDTO);
if (insertedRowCnt != 1) {
String json = Utils.jsonStringIfExceptionToString(rootHistoryDTO);
throw new RuntimeException("createArticleAndHistory메소드에서 게시글 이력 추가 에러 insertedRowCnt : " + insertedRowCnt + "\ndeletePtrDTO : " + json);
}
} else {
boardHistoryDTO = new BoardHistoryDTO(article, newNodePtrDTO, status);
boardHistoryDTO.setHistory_content(compressedContent);
boardHistoryDTO.setParentNodePtrAndRoot(parentNodePtr);
int insertedRowCnt = boardHistoryMapper.createHistory(boardHistoryDTO);
if (insertedRowCnt == 0) {
throw new RuntimeException("createArticle메소드에서 createHistory error" + boardHistoryDTO);
}
}
NodePtrDTO nodePtr = boardHistoryDTO;
article.setNodePtrDTO(nodePtr);
article.setCreated(boardHistoryDTO.getCreated());
int insertedRowCnt = boardMapper.boardCreate(article);
if (insertedRowCnt == 0) {
throw new RuntimeException("createArticle메소드에서 boardCreate error" + boardHistoryDTO);
}
return boardHistoryDTO;
}
use of com.worksmobile.Assignment.Domain.BoardHistoryDTO in project Assignment by WMPeople.
the class VersionManagementService method getHistoryMap.
private Map<Map.Entry<Integer, Integer>, BoardHistoryDTO> getHistoryMap(int root_board_id) {
List<BoardHistoryDTO> historyList = boardHistoryMapper.getHistoryByRootBoardId(root_board_id);
Map<Map.Entry<Integer, Integer>, BoardHistoryDTO> historyMap = new HashMap<>();
for (BoardHistoryDTO ele : historyList) {
historyMap.put(ele.toBoardIdAndVersionEntry(), ele);
}
return historyMap;
}
Aggregations