@Test
  @DirtiesContext
  public void moveFromIterationToIteration() {
    firstIteration.setParent(firstProject);
    secondIteration.setParent(secondProject);
    story.setBacklog(firstIteration);

    expect(storyTreeIntegrityBusiness.canStoryBeMovedToBacklog(story, secondIteration))
        .andReturn(true);
    storyDAO.store(story);
    storyRankBusiness.removeRank(story, firstIteration);
    storyRankBusiness.rankToBottom(story, secondIteration);
    storyRankBusiness.removeRank(story, firstProject);
    storyRankBusiness.rankToBottom(story, secondProject);

    backlogHistoryEntryBusiness.updateHistory(firstIteration.getId());
    backlogHistoryEntryBusiness.updateHistory(secondIteration.getId());

    iterationHistoryBusiness.updateIterationHistory(firstIteration.getId());
    iterationHistoryBusiness.updateIterationHistory(secondIteration.getId());
    replayAll();
    storyBusiness.moveStoryToBacklog(story, secondIteration);
    verifyAll();
    assertEquals(secondIteration, story.getBacklog());
  }
  @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());
  }
Ejemplo n.º 3
0
 @Test
 public void testRankStoryToBottom() {
   Story story = new Story();
   storyRankBusiness.rankToBottom(story, backlog);
   replayAll();
   Story actual = storyBusiness.rankStoryToBottom(story, backlog);
   verifyAll();
   assertSame(actual, story);
 }
Ejemplo n.º 4
0
 @Test
 public void testUpdateRanks_noChildren_NoRank() {
   Story story = new Story();
   Project backlog = new Project();
   story.setBacklog(backlog);
   storyRankBusiness.rankToBottom(story, backlog);
   replayAll();
   storyBusiness.updateStoryRanks(story);
   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
  @DirtiesContext
  public void moveFromProductToProject() {
    story.setBacklog(firstProduct);

    expect(storyTreeIntegrityBusiness.canStoryBeMovedToBacklog(story, firstProject))
        .andReturn(true);
    storyDAO.store(story);
    storyRankBusiness.rankToBottom(story, firstProject);

    backlogHistoryEntryBusiness.updateHistory(firstProduct.getId());
    backlogHistoryEntryBusiness.updateHistory(firstProject.getId());

    replayAll();
    storyBusiness.moveStoryToBacklog(story, firstProject);
    verifyAll();
    assertEquals(firstProject, story.getBacklog());
  }
Ejemplo n.º 7
0
  @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());
  }