@Test
 @DirtiesContext
 public void testChangeBacklog_moveToAnotherProduct_noConflict() {
   replayAll();
   messages = testable.checkChangeBacklog(story_12, new Product());
   verifyAll();
   assertNumberOfMessages(messages, 0);
 }
  @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
  @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);
  }