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