@Test public void testDelete_deleteChoices_withChildren_deleteChildren() { Story child = new Story(); child.setBacklog(storyInIteration.getBacklog()); child.setIteration(iteration); child.setId(2333); child.setParent(storyInIteration); storyInIteration.getChildren().add(child); storyInIteration.setIteration(null); blheBusiness.updateHistory(child.getBacklog().getId()); iheBusiness.updateIterationHistory(iteration.getId()); hourEntryBusiness.deleteAll(child.getHourEntries()); hourEntryBusiness.deleteAll(storyInIteration.getHourEntries()); // storyRankBusiness.removeStoryRanks(child); // storyRankBusiness.removeStoryRanks(storyInIteration); // expect(storyDAO.get(2333)).andReturn(child); storyDAO.remove(child.getId()); storyDAO.remove(storyInIteration); replayAll(); storyBusiness.delete( storyInIteration, TaskHandlingChoice.DELETE, HourEntryHandlingChoice.DELETE, HourEntryHandlingChoice.DELETE, ChildHandlingChoice.DELETE); // assertNull(child.getParent()); assertTrue(storyInIteration.getChildren().isEmpty()); verifyAll(); }
@Test(expected = OperationNotPermittedException.class) @DirtiesContext public void testMoveStoryAndChildren_toIteration() { Story parent = new Story(); Story child1 = new Story(); Story child2 = new Story(); parent.getChildren().add(story); story.setParent(parent); story.getChildren().add(child1); child1.setParent(story); child1.getChildren().add(child2); child2.setParent(child1); parent.setBacklog(firstProject); story.setBacklog(firstProject); child1.setBacklog(firstProject); child2.setBacklog(firstIteration); firstIteration.setParent(firstProduct); expect(backlogBusiness.getParentProduct(firstProject)).andReturn(firstProduct); expect(backlogBusiness.getParentProduct(secondIteration)).andReturn(firstProduct); replayAll(); storyBusiness.moveStoryAndChildren(story, secondIteration); verifyAll(); }
@Test @DirtiesContext public void testMoveStoryAndChildren() { Story parent = new Story(); Story child1 = new Story(); Story child2 = new Story(); parent.getChildren().add(story); story.setParent(parent); story.getChildren().add(child1); child1.setParent(story); child1.getChildren().add(child2); child2.setParent(child1); parent.setBacklog(firstProject); story.setBacklog(firstProject); child1.setBacklog(firstProject); child2.setBacklog(firstIteration); firstIteration.setParent(firstProduct); expect(storyTreeIntegrityBusiness.hasParentStoryConflict(story, secondProject)).andReturn(true); storyHierarchyBusiness.updateChildrenTreeRanks(parent); expect(backlogBusiness.getParentProduct(firstProject)).andReturn(firstProduct).anyTimes(); expect(backlogBusiness.getParentProduct(secondProject)).andReturn(firstProduct).anyTimes(); storyDAO.store(child2); storyRankBusiness.removeRank(child2, firstIteration); storyRankBusiness.removeRank(child2, firstIteration.getParent()); storyRankBusiness.rankToBottom(child2, secondProject); storyDAO.store(child1); storyDAO.store(story); backlogHistoryEntryBusiness.updateHistory(firstIteration.getId()); backlogHistoryEntryBusiness.updateHistory(secondProject.getId()); iterationHistoryBusiness.updateIterationHistory(firstIteration.getId()); backlogHistoryEntryBusiness.updateHistory(firstProject.getId()); EasyMock.expectLastCall().times(2); backlogHistoryEntryBusiness.updateHistory(secondProject.getId()); EasyMock.expectLastCall().times(2); replayAll(); storyBusiness.moveStoryAndChildren(story, secondProject); verifyAll(); }
/** TEST FORCE DELETING */ @Test public void testForceDelete() { Story story = new Story(); story.setId(1); Story child = new Story(); child.setParent(story); story.setChildren(new ArrayList<Story>(Arrays.asList(child))); story.setTasks(new HashSet<Task>(Arrays.asList(new Task(), new Task()))); story.setHourEntries( new HashSet<StoryHourEntry>( Arrays.asList(new StoryHourEntry(), new StoryHourEntry(), new StoryHourEntry()))); taskBusiness.delete(EasyMock.isA(Task.class), EasyMock.same(HourEntryHandlingChoice.DELETE)); expectLastCall().times(2); hourEntryBusiness.deleteAll(story.getHourEntries()); storyDAO.remove(1); replayAll(); storyBusiness.forceDelete(story); verifyAll(); assertNull("Child story's parent not null", child.getParent()); assertEquals("Parent story's children not empty", 0, story.getChildren().size()); }
@Test @DirtiesContext public void moveSingleFromProjectToProjectNoViolation() { Story parent = new Story(); Story child = new Story(); story.setBacklog(secondProject); story.setParent(parent); story.getChildren().add(child); child.setParent(story); expect(backlogBusiness.getParentProduct(secondProject)).andReturn(firstProduct).anyTimes(); expect(backlogBusiness.getParentProduct(firstProject)).andReturn(firstProduct).anyTimes(); storyDAO.store(child); storyDAO.store(story); expect(storyTreeIntegrityBusiness.hasParentStoryConflict(story, firstProject)).andReturn(false); storyHierarchyBusiness.updateChildrenTreeRanks(parent); backlogHistoryEntryBusiness.updateHistory(secondProject.getId()); backlogHistoryEntryBusiness.updateHistory(firstProject.getId()); storyRankBusiness.removeRank(story, secondProject); storyRankBusiness.rankToBottom(story, firstProject); replayAll(); storyBusiness.moveSingleStoryToBacklog(story, firstProject); verifyAll(); assertEquals(firstProject, story.getBacklog()); assertEquals(parent, story.getParent()); assertEquals(parent, child.getParent()); }
@Test public void testDelete_onlyChildRemoved() { Story parent = new Story(); Story child = new Story(); Backlog backlog = new Project(); backlog.setId(1); parent.getChildren().add(child); child.setParent(parent); child.setBacklog(backlog); parent.setBacklog(backlog); storyRankBusiness.rankToBottom(parent, backlog); // storyRankBusiness.removeStoryRanks(child); storyHierarchyBusiness.updateChildrenTreeRanks(parent); storyDAO.remove(child); replayAll(); storyBusiness.delete(child, null, null, null, null); verifyAll(); assertTrue(parent.getChildren().isEmpty()); }
@Test public void testUpdateRanks_children_HasRank() { Story story = new Story(); Project backlog = new Project(); story.setBacklog(backlog); StoryRank rank = new StoryRank(); story.getStoryRanks().add(rank); Story child = new Story(); story.getChildren().add(child); storyRankBusiness.removeStoryRanks(story); replayAll(); storyBusiness.updateStoryRanks(story); verifyAll(); }
@Test public void testDelete_deleteChoices_withChildren() { Story child = new Story(); Story storyParent = new Story(); storyParent.setBacklog(new Product()); child.setParent(storyInIteration); storyInIteration.setParent(storyParent); storyInIteration.getChildren().add(child); storyHierarchyBusiness.updateChildrenTreeRanks(storyParent); hourEntryBusiness.deleteAll(storyInIteration.getHourEntries()); // storyRankBusiness.removeStoryRanks(storyInIteration); storyDAO.remove(storyInIteration); replayAll(); storyBusiness.delete( storyInIteration, TaskHandlingChoice.DELETE, HourEntryHandlingChoice.DELETE, HourEntryHandlingChoice.DELETE, ChildHandlingChoice.MOVE); assertEquals(storyParent, child.getParent()); assertTrue(storyInIteration.getChildren().isEmpty()); verifyAll(); }
@Test @DirtiesContext public void moveFromProjectToProject_hasChildren() { story.setBacklog(secondProject); Story child = new Story(); story.getChildren().add(child); expect(backlogBusiness.getParentProduct(secondProject)).andReturn(firstProduct); expect(backlogBusiness.getParentProduct(firstProject)).andReturn(firstProduct); expect(storyTreeIntegrityBusiness.canStoryBeMovedToBacklog(story, firstProject)) .andReturn(true); storyDAO.store(story); backlogHistoryEntryBusiness.updateHistory(secondProject.getId()); backlogHistoryEntryBusiness.updateHistory(firstProject.getId()); replayAll(); storyBusiness.moveStoryToBacklog(story, firstProject); verifyAll(); assertEquals(firstProject, story.getBacklog()); }