/**
* Same as testMoveUp, but moving down. See it for more information.
*/
@Test
public void testMoveDown() {
FavoritesEditor editor = new FavoritesEditor();
Assert.assertTrue(editor.getFavoriteTasks().isEmpty());
FavoriteTask mySubProject1CompleFavorite = editor.addFavorite(mySubProject1Comple, false);
FavoriteTask mySubProject1LibFavorite = editor.addFavorite(mySubProject1Lib, false);
FavoriteTask mySubProject1DocFavorite = editor.addFavorite(mySubProject1Doc, false);
FavoriteTask mySubSubProjectCompileFavorite = editor.addFavorite(mySubSubProjectCompile, false);
FavoriteTask mySubSubProjectLibFavorite = editor.addFavorite(mySubSubProjectLib, false);
FavoriteTask mySubSubProjectDocFavorite = editor.addFavorite(mySubSubProjectDoc, false);
List<FavoriteTask> favoritesToMove = new ArrayList<FavoriteTask>();
favoritesToMove.add(mySubProject1CompleFavorite);
favoritesToMove.add(mySubProject1DocFavorite);
favoritesToMove.add(mySubSubProjectLibFavorite);
//our observer will make sure the order is correct.
TestOrderFavoritesObserver observer = new TestOrderFavoritesObserver(editor, mySubProject1LibFavorite,
mySubProject1CompleFavorite, mySubSubProjectCompileFavorite, mySubProject1DocFavorite,
mySubSubProjectDocFavorite, mySubSubProjectLibFavorite);
editor.addFavoriteTasksObserver(observer, false);
editor.moveFavoritesAfter(favoritesToMove);
//we're going to move them again, set the new expected order.
observer.setExpectedOrder(mySubProject1LibFavorite, mySubSubProjectCompileFavorite, mySubProject1CompleFavorite,
mySubSubProjectDocFavorite, mySubProject1DocFavorite, mySubSubProjectLibFavorite);
editor.moveFavoritesAfter(favoritesToMove);
//move again. Set the new order. Notice that both mySubProject1DocFavorite and mySubSubProjectLibFavorite has stopped moving.
observer.setExpectedOrder(mySubProject1LibFavorite, mySubSubProjectCompileFavorite, mySubSubProjectDocFavorite,
mySubProject1CompleFavorite, mySubProject1DocFavorite, mySubSubProjectLibFavorite);
editor.moveFavoritesAfter(favoritesToMove);
//one last time. Set the new order. Notice that the items have stopped moving. They're all at the bottom.
observer.setExpectedOrder(mySubProject1LibFavorite, mySubSubProjectCompileFavorite, mySubSubProjectDocFavorite,
mySubProject1CompleFavorite, mySubProject1DocFavorite, mySubSubProjectLibFavorite);
editor.moveFavoritesAfter(favoritesToMove);
}