@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 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 @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 @DirtiesContext public void testChangeBacklog_moveToAnotherProduct_withConflict() { Product another = new Product(); expect(backlogBusiness.getParentProduct(story_23.getBacklog())).andReturn(product); expect(backlogBusiness.getParentProduct(another)).andReturn(another); replayAll(); messages = testable.checkChangeBacklog(story_23, another); verifyAll(); assertNumberOfMessages(messages, 1); }
@Test @DirtiesContext public void testChangeBacklog_moveToDifferentBranch() { expect(backlogBusiness.getParentProduct(story_33.getBacklog())).andReturn(product); expect(backlogBusiness.getParentProduct(project1)).andReturn(product); replayAll(); messages = testable.checkChangeBacklog(story_33, project1); verifyAll(); assertNumberOfMessages(messages, 1); assertMessagesContain( messages, StoryHierarchyIntegrityViolationType.PARENT_IN_WRONG_BRANCH, story_33, story_22); }
@Test public void testStore_updateBacklogAndClearResponsibles() { this.store_createMockStoryBusiness(); Backlog newBacklog = new Project(); newBacklog.setId(123); Set<User> users = new HashSet<User>(Arrays.asList(new User(), new User())); storyInIteration.setResponsibles(users); expect(storyDAO.get(storyInIteration.getId())).andReturn(storyInIteration); expect(backlogBusiness.retrieve(newBacklog.getId())).andReturn(newBacklog); storyDAO.store(EasyMock.isA(Story.class)); blheBusiness.updateHistory(storyInIteration.getBacklog().getId()); replayAll(); Story actual = storyBusiness.store( storyInIteration.getId(), new Story(), newBacklog.getId(), new HashSet<Integer>(), false); verifyAll(); assertEquals(0, actual.getResponsibles().size()); assertTrue(storyBacklogUpdated); }
@Test @DirtiesContext public void testChangeBacklog_moveToProduct_parentInProject() { expect(backlogBusiness.getParentProduct(story_41.getBacklog())).andReturn(product); expect(backlogBusiness.getParentProduct(product)).andReturn(product); replayAll(); messages = testable.checkChangeBacklog(story_41, product); verifyAll(); assertNumberOfMessages(messages, 1); assertMessagesContain( messages, StoryHierarchyIntegrityViolationType.PARENT_DEEPER_IN_HIERARCHY, story_41, story_31); }
@Test @DirtiesContext public void testChangeBacklog_hasChildren_movingToIteration() { expect(backlogBusiness.getParentProduct(story_31.getBacklog())).andReturn(product); expect(backlogBusiness.getParentProduct(iteration)).andReturn(product); replayAll(); messages = testable.checkChangeBacklog(story_31, iteration); verifyAll(); assertNumberOfMessages(messages, 1); assertMessagesContain( messages, StoryHierarchyIntegrityViolationType.MOVE_TO_ITERATION_HAS_CHILDREN, story_31, null); }
@Test @DirtiesContext public void testChangeBacklog_hasChildren_notUnderTargetBacklog() { expect(backlogBusiness.getParentProduct(story_21.getBacklog())).andReturn(product); expect(backlogBusiness.getParentProduct(project2)).andReturn(product); replayAll(); messages = testable.checkChangeBacklog(story_21, project2); verifyAll(); assertNumberOfMessages(messages, 3); assertMessagesContain( messages, StoryHierarchyIntegrityViolationType.CHILD_IN_WRONG_BRANCH, story_21, story_31); assertMessagesContain( messages, StoryHierarchyIntegrityViolationType.CHILD_IN_WRONG_BRANCH, story_31, story_41); assertMessagesContain( messages, StoryHierarchyIntegrityViolationType.CHILD_IN_WRONG_BRANCH, story_21, story_32); }
@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()); }
@Test(expected = OperationNotPermittedException.class) @DirtiesContext public void moveWithChildrenToAnotherProduct() { Product oldParent = new Product(); Backlog oldBacklog = new Project(); oldBacklog.setId(8482); oldBacklog.setParent(oldParent); Product newBacklog = new Product(); newBacklog.setId(1904); Story movable = new Story(); movable.setBacklog(oldBacklog); movable.setChildren(Arrays.asList(new Story(), new Story())); expect(backlogBusiness.getParentProduct(oldBacklog)).andReturn(oldParent); expect(backlogBusiness.getParentProduct(newBacklog)).andReturn(newBacklog); replayAll(); storyBusiness.moveStoryToBacklog(movable, newBacklog); verifyAll(); }