@Test void shouldFilterEvent() { Event event = mock(Event.class); NotificationPreference pref1 = mock(NotificationPreference.class); NotificationPreference pref2 = mock(NotificationPreference.class); String eventType = "myEventType"; when(event.getType()).thenReturn(eventType); when(pref1.getProperties()).thenReturn(Collections.emptyMap()); when(pref2.getProperties()) .thenReturn(Collections.singletonMap(NotificationPreferenceProperty.EVENT_TYPE, eventType)); when(event.getDate()).thenReturn(new Date(41)); when(pref2.getStartDate()).thenReturn(new Date(42)); assertTrue(this.notificationFilter.shouldFilter(event, Arrays.asList(pref1, pref2))); }
public boolean shouldFilter(Event event, Collection<NotificationPreference> preferences) { for (NotificationPreference preference : preferences) { Object preferenceEventType = preference.getProperties().get(NotificationPreferenceProperty.EVENT_TYPE); if (preferenceEventType != null && event.getType().equals(preferenceEventType) && preference.getStartDate().after(event.getDate())) { return true; } } return false; }
PreferenceDateNotificationFilter { public boolean shouldFilter(Event event, Collection<NotificationPreference> preferences) { for (NotificationPreference preference : preferences) { Object preferenceEventType = preference.getProperties().get(NotificationPreferenceProperty.EVENT_TYPE); if (preferenceEventType != null && event.getType().equals(preferenceEventType) && preference.getStartDate().after(event.getDate())) { return true; } } return false; } }
PreferenceDateNotificationFilter { public boolean shouldFilter(Event event, Collection<NotificationPreference> preferences) { for (NotificationPreference preference : preferences) { Object preferenceEventType = preference.getProperties().get(NotificationPreferenceProperty.EVENT_TYPE); if (preferenceEventType != null && event.getType().equals(preferenceEventType) && preference.getStartDate().after(event.getDate())) { return true; } } return false; }  }
PreferenceDateNotificationFilter { public boolean shouldFilter(Event event, Collection<NotificationPreference> preferences) { for (NotificationPreference preference : preferences) { Object preferenceEventType = preference.getProperties().get(NotificationPreferenceProperty.EVENT_TYPE); if (preferenceEventType != null && event.getType().equals(preferenceEventType) && preference.getStartDate().after(event.getDate())) { return true; } } return false; }  boolean shouldFilter(Event event, Collection<NotificationPreference> preferences); }
PreferenceDateNotificationFilter { public boolean shouldFilter(Event event, Collection<NotificationPreference> preferences) { for (NotificationPreference preference : preferences) { Object preferenceEventType = preference.getProperties().get(NotificationPreferenceProperty.EVENT_TYPE); if (preferenceEventType != null && event.getType().equals(preferenceEventType) && preference.getStartDate().after(event.getDate())) { return true; } } return false; }  boolean shouldFilter(Event event, Collection<NotificationPreference> preferences);  }