@Test public void cleanLimitExceededNotificationsWithAExpiredNotification() throws Exception { TestSubscriber<Object> objectTestSubscriber = TestSubscriber.create(); Map<String, RoomNotification> list = new HashMap<>(); long timeStamp = System.currentTimeMillis(); RoomNotification notification = createNotification(timeStamp, timeStamp, "me", true); list.put(notification.getKey(), notification); timeStamp = System.currentTimeMillis(); notification = createNotification(timeStamp + 10000, timeStamp - 1000, "me", true); list.put(notification.getKey(), notification); timeStamp = System.currentTimeMillis(); notification = createNotification(timeStamp + 20000, timeStamp - 2000, "me", true); list.put(notification.getKey(), notification); RoomNotificationPersistence roomNotificationPersistence = new NotPersistenceRoom(list); NotificationsCleaner notificationsCleaner = new NotificationsCleaner(roomNotificationPersistence, Calendar.getInstance(TimeZone.getTimeZone("UTC")), getAptoideAccountManager(), getNotificationProvider(), CrashReport.getInstance()); notificationsCleaner.cleanLimitExceededNotifications(2) .subscribe(objectTestSubscriber); objectTestSubscriber.awaitTerminalEvent(); objectTestSubscriber.assertCompleted(); objectTestSubscriber.assertNoErrors(); assertEquals(2, roomNotificationPersistence.getAllSortedDesc() .toBlocking() .first() .size()); }
public Completable cleanLimitExceededNotifications(int limit) { return removeExpiredNotifications().andThen(removeExceededLimitNotifications(limit)); }
NotificationsCleaner { public Completable cleanLimitExceededNotifications(int limit) { return removeExpiredNotifications().andThen(removeExceededLimitNotifications(limit)); } }
NotificationsCleaner { public Completable cleanLimitExceededNotifications(int limit) { return removeExpiredNotifications().andThen(removeExceededLimitNotifications(limit)); } NotificationsCleaner(RoomNotificationPersistence roomNotificationPersistence,
      Calendar calendar, AptoideAccountManager accountManager,
      NotificationProvider notificationProvider, CrashReport crashReport); }
NotificationsCleaner { public Completable cleanLimitExceededNotifications(int limit) { return removeExpiredNotifications().andThen(removeExceededLimitNotifications(limit)); } NotificationsCleaner(RoomNotificationPersistence roomNotificationPersistence,
      Calendar calendar, AptoideAccountManager accountManager,
      NotificationProvider notificationProvider, CrashReport crashReport); void setup(); Completable cleanOtherUsersNotifications(String id); Completable cleanLimitExceededNotifications(int limit); }
NotificationsCleaner { public Completable cleanLimitExceededNotifications(int limit) { return removeExpiredNotifications().andThen(removeExceededLimitNotifications(limit)); } NotificationsCleaner(RoomNotificationPersistence roomNotificationPersistence,
      Calendar calendar, AptoideAccountManager accountManager,
      NotificationProvider notificationProvider, CrashReport crashReport); void setup(); Completable cleanOtherUsersNotifications(String id); Completable cleanLimitExceededNotifications(int limit); static final int MAX_NUMBER_NOTIFICATIONS_SAVED; }