@Test public void testNoNotifications() throws Exception { when(environment.getArgument("username")).thenReturn("test"); when(store.fetch(anyString())).thenReturn(Optional.empty()); final SortedSet<Notification> actual = fetcher.get(environment); verify(store).fetch(eq("test")); assertThat(actual).isNotNull(); assertThat(actual).isEmpty(); }
@Nullable @Override public SortedSet<Notification> get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { return null; } final Optional<UserNotifications> notifications; try { notifications = store.fetch(username); } catch (NotificationStoreException e) { LOGGER.error("Unable to fetch notifications", e); return null; } if (!notifications.isPresent()) { return Collections.emptySortedSet(); } return notifications.get().getNotifications(); }
NotificationDataFetcher implements DataFetcher<SortedSet<Notification>> { @Nullable @Override public SortedSet<Notification> get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { return null; } final Optional<UserNotifications> notifications; try { notifications = store.fetch(username); } catch (NotificationStoreException e) { LOGGER.error("Unable to fetch notifications", e); return null; } if (!notifications.isPresent()) { return Collections.emptySortedSet(); } return notifications.get().getNotifications(); } }
NotificationDataFetcher implements DataFetcher<SortedSet<Notification>> { @Nullable @Override public SortedSet<Notification> get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { return null; } final Optional<UserNotifications> notifications; try { notifications = store.fetch(username); } catch (NotificationStoreException e) { LOGGER.error("Unable to fetch notifications", e); return null; } if (!notifications.isPresent()) { return Collections.emptySortedSet(); } return notifications.get().getNotifications(); } NotificationDataFetcher(final NotificationStore store); }
NotificationDataFetcher implements DataFetcher<SortedSet<Notification>> { @Nullable @Override public SortedSet<Notification> get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { return null; } final Optional<UserNotifications> notifications; try { notifications = store.fetch(username); } catch (NotificationStoreException e) { LOGGER.error("Unable to fetch notifications", e); return null; } if (!notifications.isPresent()) { return Collections.emptySortedSet(); } return notifications.get().getNotifications(); } NotificationDataFetcher(final NotificationStore store); @Nullable @Override SortedSet<Notification> get(DataFetchingEnvironment environment); }
NotificationDataFetcher implements DataFetcher<SortedSet<Notification>> { @Nullable @Override public SortedSet<Notification> get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { return null; } final Optional<UserNotifications> notifications; try { notifications = store.fetch(username); } catch (NotificationStoreException e) { LOGGER.error("Unable to fetch notifications", e); return null; } if (!notifications.isPresent()) { return Collections.emptySortedSet(); } return notifications.get().getNotifications(); } NotificationDataFetcher(final NotificationStore store); @Nullable @Override SortedSet<Notification> get(DataFetchingEnvironment environment);  }