From 5af072c9e629f44d4dabcee3fa1beb4cbe8906c0 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 25 Jun 2015 12:03:58 -0500 Subject: [PATCH] Fix tests --- .../astrid/reminders/NotificationTests.java | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/androidTest/java/com/todoroo/astrid/reminders/NotificationTests.java b/src/androidTest/java/com/todoroo/astrid/reminders/NotificationTests.java index 9d6dfe475..86e229937 100644 --- a/src/androidTest/java/com/todoroo/astrid/reminders/NotificationTests.java +++ b/src/androidTest/java/com/todoroo/astrid/reminders/NotificationTests.java @@ -5,7 +5,7 @@ */ package com.todoroo.astrid.reminders; -import android.content.Intent; +import android.app.Notification; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.dao.TaskDao; @@ -23,6 +23,8 @@ import javax.inject.Singleton; import dagger.Module; import dagger.Provides; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -42,17 +44,9 @@ public class NotificationTests extends DatabaseTestCase { public Broadcaster getBroadcaster() { return mock(Broadcaster.class); } - - @Singleton - @Provides - public Notifier getNotifier() { - return mock(Notifier.class); - } } @Inject TaskDao taskDao; - @Inject - NotificationReceiver notificationReceiver; @Inject NotificationManager notificationManager; @Inject Broadcaster broadcaster; @Inject Notifier notifier; @@ -63,7 +57,6 @@ public class NotificationTests extends DatabaseTestCase { verifyNoMoreInteractions(notificationManager); verifyNoMoreInteractions(broadcaster); - verifyNoMoreInteractions(notifier); } public void testAlarmToNotification() { @@ -71,14 +64,10 @@ public class NotificationTests extends DatabaseTestCase { setTitle("rubberduck"); setDueDate(DateUtilities.now() - DateUtilities.ONE_DAY); }}; - taskDao.persist(task); - notificationReceiver.handle(new Intent() {{ - putExtra(NotificationReceiver.ID_KEY, task.getId()); - putExtra(NotificationReceiver.EXTRAS_TYPE, ReminderService.TYPE_DUE); - }}); + taskDao.persist(task); - verify(notifier).triggerTaskNotification(task.getId(), ReminderService.TYPE_DUE); + notifier.triggerTaskNotification(task.getId(), ReminderService.TYPE_DUE); } public void testDeletedTaskDoesntTriggerNotification() { @@ -88,10 +77,7 @@ public class NotificationTests extends DatabaseTestCase { }}; taskDao.persist(task); - notificationReceiver.handle(new Intent() {{ - putExtra(NotificationReceiver.ID_KEY, task.getId()); - putExtra(NotificationReceiver.EXTRAS_TYPE, ReminderService.TYPE_DUE); - }}); + notifier.triggerTaskNotification(task.getId(),ReminderService.TYPE_DUE); verify(notificationManager).cancel((int) task.getId()); } @@ -103,10 +89,7 @@ public class NotificationTests extends DatabaseTestCase { }}; taskDao.persist(task); - notificationReceiver.handle(new Intent() {{ - putExtra(NotificationReceiver.ID_KEY, task.getId()); - putExtra(NotificationReceiver.EXTRAS_TYPE, ReminderService.TYPE_DUE); - }}); + notifier.triggerTaskNotification(task.getId(), ReminderService.TYPE_DUE); verify(notificationManager).cancel((int) task.getId()); }