FavoritesEditor originalEditor = new FavoritesEditor();
Assert.assertTrue(originalEditor.getFavoriteTasks().isEmpty());
//add two tasks
FavoriteTask favoriteTask1 = originalEditor.addFavorite(mySubProject1Comple, true);
FavoriteTask favoriteTask2 = originalEditor.addFavorite(mySubSubProjectLib, false);
//now change the display name so its not the same as the full name, just so know each field is working.
originalEditor.editFavorite(favoriteTask1, new FavoritesEditor.EditFavoriteInteraction() {
public boolean editFavorite(FavoritesEditor.EditibleFavoriteTask favoriteTask) {
favoriteTask.displayName = "favorite 1";
return true;
}
public void reportError(String error) {
throw new AssertionFailedError("Unexpected error");
}
});
//make sure they were added properly
FavoriteTask originalFavoriteTask1 = originalEditor.getFavoriteTasks().get(0);
assertFavorite(originalFavoriteTask1, "mysubproject1:compile", "favorite 1", true);
FavoriteTask originalFavoriteTask2 = originalEditor.getFavoriteTasks().get(1);
assertFavorite(originalFavoriteTask2, "mysubproject1:mysubsubproject:lib", "mysubproject1:mysubsubproject:lib",
false);
File file = tempDir.createFile("fred.favorite-tasks");
originalEditor.exportToFile(new TestUtility.TestExportInteraction(file,
true)); //confirm overwrite because the above function actually creates the file.
FavoritesEditor newEditor = new FavoritesEditor();
newEditor.importFromFile(new TestUtility.TestImportInteraction(file));
//make sure they're the same
FavoriteTask readInFavoriteTask1 = originalEditor.getFavoriteTasks().get(0);
assertFavorite(readInFavoriteTask1, originalFavoriteTask1);
FavoriteTask readInFavoriteTask2 = originalEditor.getFavoriteTasks().get(1);
assertFavorite(readInFavoriteTask2, originalFavoriteTask2);
}