@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 testChangeParent_moveToDifferentBranch() {
    // 41 -> 22

    replayAll();
    messages = testable.checkChangeParentStory(story_41, story_22);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_IN_WRONG_BRANCH,
        story_41,
        story_22);
  }
  @Test
  @DirtiesContext
  public void testChangeParent_moveUnderIterationStory() {
    // 32 -> 41

    replayAll();
    messages = testable.checkChangeParentStory(story_32, story_41);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_IN_ITERATION,
        story_32,
        story_41);
  }
  @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 testChangeParent_moveProductStoryUnderProjectStory() {
    // 23 -> 22
    // 34 vaihtaa branchia

    replayAll();
    messages = testable.checkChangeParentStory(story_23, story_22);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_DEEPER_IN_HIERARCHY,
        story_23,
        story_22);
  }
  @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);
  }
  @Test
  @DirtiesContext
  public void testChangeParent_moveBranchUnderAnother() {
    // 22 -> 31
    // 2 virhettä, 22->31, 33 -> 31

    replayAll();
    messages = testable.checkChangeParentStory(story_22, story_31);
    verifyAll();

    assertNumberOfMessages(messages, 2);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_IN_WRONG_BRANCH,
        story_22,
        story_31);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_IN_WRONG_BRANCH,
        story_22,
        story_33);
  }