use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.
the class FavoritesTest method testRemovingNonExistantFavorite.
/**
* This tests removing a favorite that isn't in our favorites editor. We just want to make sure we're not notified
* of a change and that this doesn't blow up.
*/
public void testRemovingNonExistantFavorite() {
//remove a task that doesn't exist. We should NOT be notified and it should not blow up
FavoritesEditor otherEditor = new FavoritesEditor();
Assert.assertTrue(otherEditor.getFavoriteTasks().isEmpty());
otherEditor.addFavorite(mySubProject1Comple, true);
FavoriteTask favoriteTask = otherEditor.getFavoriteTasks().get(0);
//create another editor. This is the one we're really interested in.
FavoritesEditor interestedEditor = new FavoritesEditor();
//create an observer so we can make sure we're NOT notified of the deletion. We won't assign it any expectations.
final FavoritesEditor.FavoriteTasksObserver observer = context.mock(FavoritesEditor.FavoriteTasksObserver.class);
interestedEditor.addFavoriteTasksObserver(observer, false);
//now remove the task
List<FavoriteTask> tasks = new ArrayList<FavoriteTask>();
tasks.add(favoriteTask);
interestedEditor.removeFavorites(tasks);
//it should still exist in the original
Assert.assertEquals(1, otherEditor.getFavoriteTasks().size());
//nothing exists in the new one.
Assert.assertTrue(interestedEditor.getFavoriteTasks().isEmpty());
}
Aggregations