@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 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 public void testDelete_hourEntryChoice_delete() { storyInIteration.getHourEntries().add(new StoryHourEntry()); hourEntryBusiness.deleteAll(storyInIteration.getHourEntries()); // storyRankBusiness.removeStoryRanks(storyInIteration); storyDAO.remove(storyInIteration); replayAll(); storyBusiness.delete(storyInIteration, null, HourEntryHandlingChoice.DELETE, null, null); verifyAll(); assertTrue(storyInIteration.getHourEntries().isEmpty()); }
@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(); }