Search in sources :

Example 26 with FavoriteTask

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());
}
Also used : FavoritesEditor(org.gradle.gradleplugin.foundation.favorites.FavoritesEditor) ArrayList(java.util.ArrayList) FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask)

Aggregations

FavoriteTask (org.gradle.gradleplugin.foundation.favorites.FavoriteTask)26 FavoritesEditor (org.gradle.gradleplugin.foundation.favorites.FavoritesEditor)19 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 Expectations (org.jmock.Expectations)5 File (java.io.File)3 FavoriteTaskVersion1 (org.gradle.openapi.external.foundation.favorites.FavoriteTaskVersion1)3 TestUtility (org.gradle.foundation.TestUtility)2 SwingEditFavoriteInteraction (org.gradle.gradleplugin.userinterface.swing.generic.SwingEditFavoriteInteraction)1 FavoriteTaskWrapper (org.gradle.openapi.wrappers.foundation.favorites.FavoriteTaskWrapper)1