Пример #1
0
  /** 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 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 testHasParentStoryConflict_differentProduct() {
    Product product = new Product();
    Product targetProduct = new Product();
    Project project = new Project();
    Project targetProject = new Project();

    Story parentStory = new Story();
    Story story = new Story();

    targetProject.setParent(targetProduct);
    project.setParent(product);

    parentStory.setBacklog(project);
    story.setBacklog(project);
    story.setParent(parentStory);

    expect(this.backlogBusiness.getParentProduct(targetProject)).andReturn(targetProduct);
    expect(this.backlogBusiness.getParentProduct(project)).andReturn(product);

    replayAll();
    assertTrue(this.testable.hasParentStoryConflict(story, targetProject));
    verifyAll();
  }
Пример #4
0
 @Test(expected = IllegalArgumentException.class)
 public void testRankStory_underNull() {
   Backlog blog = new Iteration();
   Story story = new Story();
   story.setBacklog(blog);
   replayAll();
   storyBusiness.rankStoryUnder(story, null, null);
   verifyAll();
 }
Пример #5
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();
 }
Пример #6
0
 @Test
 public void testRetrieveStoryTO() {
   StoryTO storyTo = new StoryTO(story1);
   expect(storyDAO.get(story1.getId())).andReturn(story1);
   expect(transferObjectBusiness.constructStoryTO(story1)).andReturn(storyTo);
   expect(storyDAO.calculateMetrics(story1.getId())).andReturn(new StoryMetrics());
   expect(hourEntryDAO.calculateSumByStory(story1.getId())).andReturn(100l);
   replayAll();
   assertEquals(storyTo, storyBusiness.retrieveStoryWithMetrics(story1.getId()));
   verifyAll();
 }
Пример #7
0
 @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());
 }
Пример #8
0
 @Test
 public void testUpdateRanks_noChildren_HasRank() {
   Story story = new Story();
   Project backlog = new Project();
   story.setBacklog(backlog);
   StoryRank rank = new StoryRank();
   story.getStoryRanks().add(rank);
   replayAll();
   storyBusiness.updateStoryRanks(story);
   verifyAll();
 }
 /** {@inheritDoc} */
 public int getMaximumTreeRank(int productId) {
   Criteria rootFilter = getRootStoryCriteria(productId);
   rootFilter.addOrder(Order.desc("treeRank"));
   rootFilter.setMaxResults(1);
   Story story = (Story) uniqueResult(rootFilter);
   if (story == null) {
     return 0;
   } else {
     return story.getTreeRank();
   }
 }
Пример #10
0
 @Test
 public void checksThatStorysIterationMatches_rankOver() {
   Iteration ite = new Iteration();
   Story story = new Story();
   story.setIteration(ite);
   Story ref = new Story();
   ref.setIteration(ite);
   storyRankBusiness.rankAbove(story, ite, ref);
   replayAll();
   storyBusiness.rankStoryOver(story, ref, null);
   verifyAll();
 }
Пример #11
0
 @Test
 public void testRankStoryOver() {
   Backlog blog = new Project();
   Story story = new Story();
   story.setBacklog(blog);
   Story ref = new Story();
   ref.setBacklog(blog);
   storyRankBusiness.rankAbove(story, blog, ref);
   replayAll();
   storyBusiness.rankStoryOver(story, ref, blog);
   verifyAll();
 }
Пример #12
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();
  }
Пример #13
0
 @Test
 public void testDelete_taskChoice_move() {
   Task task = new Task();
   storyInIteration.getTasks().add(task);
   expect(taskBusiness.move(task, storyInIteration.getBacklog().getId(), null)).andReturn(task);
   //        storyRankBusiness.removeStoryRanks(storyInIteration);
   storyDAO.remove(storyInIteration);
   replayAll();
   storyBusiness.delete(storyInIteration, TaskHandlingChoice.MOVE, null, null, null);
   verifyAll();
   assertTrue(storyInIteration.getTasks().isEmpty());
 }
  @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());
  }
Пример #15
0
 @Test
 public void testDelete_taskChoice_delete() {
   Task task = new Task();
   storyInIteration.getTasks().add(task);
   hourEntryBusiness.moveToBacklog(task.getHourEntries(), storyInIteration.getBacklog());
   taskBusiness.delete(task.getId(), HourEntryHandlingChoice.MOVE);
   //        storyRankBusiness.removeStoryRanks(storyInIteration);
   storyDAO.remove(storyInIteration);
   replayAll();
   storyBusiness.delete(
       storyInIteration, TaskHandlingChoice.DELETE, null, HourEntryHandlingChoice.MOVE, null);
   verifyAll();
   assertNull(task.getStory());
   assertTrue(storyInIteration.getTasks().isEmpty());
 }
 @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();
 }
Пример #17
0
 @Test
 public void testGetTasksWithRankBetween_storyEmptyCollection() {
   story.setId(1);
   executeClassSql();
   Collection<Task> actual = taskDAO.getTasksWithRankBetween(2, 1, null, story);
   assertEquals(0, actual.size());
 }
Пример #18
0
 @Test
 public void testGetTasksWithRankBetween_storyBottom() {
   story.setId(3);
   executeClassSql();
   Collection<Task> actual = taskDAO.getTasksWithRankBetween(1, 5, null, story);
   assertEquals(1, actual.size());
 }
Пример #19
0
 @Test
 public void testGetLastTaskInRank_story() {
   story.setId(55);
   executeClassSql();
   Task actual = taskDAO.getLastTaskInRank(story, null);
   assertEquals(22, actual.getId());
   assertEquals(666, actual.getRank());
 }
Пример #20
0
 @Test
 public void testGetNextTaskInRank_story() {
   story.setId(55);
   executeClassSql();
   Task actual = taskDAO.getNextTaskInRank(0, null, story);
   assertEquals(1, actual.getRank());
   assertEquals(21, actual.getId());
 }
 private void setStoryBacklogs() {
   story_11.setBacklog(product);
   story_12.setBacklog(product);
   story_21.setBacklog(product);
   story_31.setBacklog(project1);
   story_41.setBacklog(iteration);
   story_22.setBacklog(project2);
   story_33.setBacklog(project2);
   story_23.setBacklog(product);
 }
  @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());
  }
Пример #23
0
  @Test
  public void testGetNextTaskInRank_story_largeCap() {
    story.setId(55);
    executeClassSql();
    Task actual = taskDAO.getNextTaskInRank(25, null, story);

    assertEquals(22, actual.getId());
    assertEquals(666, actual.getRank());
  }
  @SuppressWarnings("unchecked")
  @Transactional(readOnly = true)
  public List<StoryAccessCloudTO> calculateEditOccurences(
      DateTime start, DateTime end, User user, int numberOfItems) {
    Map<Integer, Long> data = this.storyHistoryDAO.calculateAccessCounts(start, end, user);

    Collection<Story> stories = this.storyBusiness.retrieveMultiple(data.keySet());

    List<StoryAccessCloudTO> res = new ArrayList<StoryAccessCloudTO>();
    for (Story story : stories) {
      res.add(new StoryAccessCloudTO(story, data.get(story.getId())));
    }
    Collections.sort(res, new PropertyComparator("count", true, false));
    if (res.size() > numberOfItems) {
      return res.subList(0, numberOfItems - 1);
    }
    return res;
  }
Пример #25
0
  @Test(expected = IllegalArgumentException.class)
  public void testRankStoryUnder_invalidbacklogs() {
    Project proj1 = new Project();
    Iteration iter = new Iteration();
    iter.setParent(proj1);

    Project proj2 = new Project();
    Iteration iter2 = new Iteration();
    iter2.setParent(proj2);

    Story story1 = new Story();
    story1.setBacklog(proj1);
    Story story2 = new Story();
    story2.setBacklog(proj2);

    replayAll();
    storyBusiness.rankStoryUnder(story1, story2, proj1);
    verifyAll();
  }
  @Test(expected = OperationNotPermittedException.class)
  @DirtiesContext
  public void moveFromProjectToProduct_integrityViolation() {
    story.setBacklog(firstProject);
    expect(storyTreeIntegrityBusiness.canStoryBeMovedToBacklog(story, firstProduct))
        .andReturn(false);
    replayAll();

    storyBusiness.moveStoryToBacklog(story, firstProduct);
    verifyAll();
  }
Пример #27
0
  @Before
  public void setUp() {
    backlog = new Product();
    iteration = new Iteration();
    iteration.setId(5834);
    story1 = new Story();
    story1.setId(666);
    story2 = new Story();

    storyPriorityUpdated = false;
    storyBacklogUpdated = false;
  }
  @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());
  }
Пример #29
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(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();
  }