Exemplo n.º 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());
  }
  private void setStoryRelations() {
    story_11.setChildren(new ArrayList<Story>(Arrays.asList(story_21, story_22)));
    story_21.setParent(story_11);
    story_22.setParent(story_11);

    story_21.setChildren(new ArrayList<Story>(Arrays.asList(story_31, story_32)));
    story_31.setParent(story_21);
    story_32.setParent(story_21);

    story_31.setChildren(new ArrayList<Story>(Arrays.asList(story_41)));
    story_41.setParent(story_31);

    story_22.setChildren(new ArrayList<Story>(Arrays.asList(story_33)));
    story_33.setParent(story_22);

    story_23.setParent(story_11);
  }
  @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();
  }