@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 moveFromIterationToIteration_inProject() {
    firstIteration.setParent(firstProject);
    secondIteration.setParent(firstProject);
    story.setBacklog(firstIteration);

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

    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 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 moveFromProductToProduct() {
   Product prod = new Product();
   prod.setId(313);
   story.setBacklog(firstProduct);
   expect(storyTreeIntegrityBusiness.canStoryBeMovedToBacklog(story, prod)).andReturn(true);
   storyDAO.store(story);
   backlogHistoryEntryBusiness.updateHistory(prod.getId());
   backlogHistoryEntryBusiness.updateHistory(firstProduct.getId());
   replayAll();
   storyBusiness.moveStoryToBacklog(story, prod);
   assertEquals(prod, story.getBacklog());
   verifyAll();
 }
예제 #5
0
  @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();
  }
예제 #6
0
  @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 moveFromProjectToProject() {
    story.setBacklog(secondProject);

    expect(storyTreeIntegrityBusiness.canStoryBeMovedToBacklog(story, firstProject))
        .andReturn(true);
    storyDAO.store(story);
    storyRankBusiness.removeRank(story, secondProject);
    storyRankBusiness.rankToBottom(story, firstProject);
    backlogHistoryEntryBusiness.updateHistory(secondProject.getId());
    backlogHistoryEntryBusiness.updateHistory(firstProject.getId());
    replayAll();

    storyBusiness.moveStoryToBacklog(story, firstProject);
    verifyAll();
    assertEquals(firstProject, story.getBacklog());
  }
예제 #8
0
  @Test
  public void testDeleteAndUpdateHistory() {
    expect(storyDAO.get(storyInIteration.getId())).andReturn(storyInIteration);
    //        storyRankBusiness.removeStoryRanks(storyInIteration);
    storyDAO.remove(storyInIteration);
    blheBusiness.updateHistory(storyInIteration.getBacklog().getId());
    iheBusiness.updateIterationHistory(storyInIteration.getIteration().getId());
    replayAll();

    storyBusiness.deleteAndUpdateHistory(storyInIteration.getId(), null, null, null, null);
    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());
  }
예제 #10
0
  @Test
  public void testStore_updateResponsibles() {
    this.store_createMockStoryBusiness();

    Backlog backlog = storyInIteration.getBacklog();
    User user1 = new User();
    User user2 = new User();
    Set<User> users = new HashSet<User>(Arrays.asList(user1, user2));

    expect(storyDAO.get(storyInIteration.getId())).andReturn(storyInIteration);
    expect(userDAO.get(123)).andReturn(user1);
    expect(userDAO.get(222)).andReturn(user2);
    storyDAO.store(EasyMock.isA(Story.class));

    Story dataItem = new Story();
    dataItem.setName("Foo item");
    dataItem.setDescription("Fubar");
    dataItem.setStoryPoints(333);
    dataItem.setState(StoryState.PENDING);

    blheBusiness.updateHistory(storyInIteration.getBacklog().getId());

    replayAll();
    Story actual =
        storyBusiness.store(
            storyInIteration.getId(),
            dataItem,
            null,
            new HashSet<Integer>(Arrays.asList(123, 222)),
            false);
    verifyAll();

    assertSame("The backlogs don't match", backlog, actual.getBacklog());
    assertEquals("The responsibles don't match", users, actual.getResponsibles());

    assertEquals(dataItem.getName(), actual.getName());
    assertEquals(dataItem.getDescription(), actual.getDescription());
    assertEquals(dataItem.getStoryPoints(), actual.getStoryPoints());
    assertEquals(dataItem.getState(), actual.getState());

    assertFalse(storyBacklogUpdated);
  }