public void testReorderFrom() throws Exception {
Product product = this.productForTest();
Release release = this.releaseForTest(product);
BacklogItem backlogItem1 = this.backlogItem1ForTest(product);
BacklogItem backlogItem2 = this.backlogItem2ForTest(product);
BacklogItem backlogItem3 = this.backlogItem3ForTest(product);
expectedEvents(5);
expectedEvent(ProductCreated.class, 1);
expectedEvent(ProductReleaseScheduled.class, 1);
expectedEvent(ProductBacklogItemPlanned.class, 3);
release.schedule(backlogItem1);
release.schedule(backlogItem2);
release.schedule(backlogItem3);
ScheduledBacklogItem scheduledBacklogItem1 = null;
ScheduledBacklogItem scheduledBacklogItem2 = null;
ScheduledBacklogItem scheduledBacklogItem3 = null;
for (ScheduledBacklogItem scheduledBacklogItem : release.allScheduledBacklogItems()) {
if (scheduledBacklogItem.ordering() == 1) {
scheduledBacklogItem1 = scheduledBacklogItem;
}
if (scheduledBacklogItem.ordering() == 2) {
scheduledBacklogItem2 = scheduledBacklogItem;
}
if (scheduledBacklogItem.ordering() == 3) {
scheduledBacklogItem3 = scheduledBacklogItem;
}
}
release.reorderFrom(backlogItem3.backlogItemId(), 1);
assertEquals(1, scheduledBacklogItem3.ordering());
assertEquals(2, scheduledBacklogItem1.ordering());
assertEquals(3, scheduledBacklogItem2.ordering());
}