/**
* This tests duplicating multiple favorites at once. First, we'll create some, then duplicate them.
*/
@Test
public void testDuplicatingMultipleFavorites() {
FavoritesEditor editor = new FavoritesEditor();
//add some tasks
FavoriteTask favoriteTask1 = editor.addFavorite(mySubProject1Comple, true);
FavoriteTask favoriteTask2 = editor.addFavorite(mySubSubProjectLib, false);
FavoriteTask favoriteTask3 = editor.addFavorite(mySubSubProjectDoc, false);
//now change the display names and the alwaysShowOutput field, just so we can verify that all fields are copied.
editFavorite(editor, favoriteTask1, "name1", false);
editFavorite(editor, favoriteTask2, "name2", true);
editFavorite(editor, favoriteTask3, "name3", false);
//get the ones to dupicate in a list
List<FavoriteTask> tasksToCopy = new ArrayList<FavoriteTask>();
tasksToCopy.add(favoriteTask1);
tasksToCopy.add(favoriteTask2);
//now perform the duplication
editor.duplicateFavorites(tasksToCopy, new TestEditFavoriteInteraction(new NameAndCommand("newname1", "newcommand1"),
new NameAndCommand("newname2", "newcommand2")));
//there should be 5 tasks now
Assert.assertEquals(5, editor.getFavoriteTasks().size());
//the 4th one (3 from index 0) should be the same as the first one
FavoriteTask favoriteTask4 = editor.getFavoriteTasks().get(3);
Assert.assertNotNull(favoriteTask4);
Assert.assertEquals("newcommand1", favoriteTask4.getFullCommandLine());
Assert.assertEquals("newname1", favoriteTask4.getDisplayName());
Assert.assertEquals(favoriteTask1.alwaysShowOutput(), favoriteTask4.alwaysShowOutput());
//the 5th one (4 from index 0) should be the same as the second one
FavoriteTask favoriteTask5 = editor.getFavoriteTasks().get(4);
Assert.assertNotNull(favoriteTask5);
Assert.assertEquals("newcommand2", favoriteTask5.getFullCommandLine());
Assert.assertEquals("newname2", favoriteTask5.getDisplayName());
Assert.assertEquals(favoriteTask2.alwaysShowOutput(), favoriteTask5.alwaysShowOutput());
}