@Test public void testIdsEmpty() throws Exception { when(environment.getArgument("username")).thenReturn("test"); when(environment.getArgument("ids")).thenReturn(Collections.emptyList()); final Boolean actual = mutation.get(environment); verify(store, never()).remove(anyString(), anyList()); assertThat(actual).isFalse(); }
@Override public Boolean get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { throw new GraphQLValidationError("username cannot be empty"); } final List<String> ids = environment.getArgument("ids"); if (ids == null || ids.isEmpty()) { return false; } try { store.remove(username, ids); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove notifications"); } return true; }
RemoveNotificationMutation implements DataFetcher<Boolean> { @Override public Boolean get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { throw new GraphQLValidationError("username cannot be empty"); } final List<String> ids = environment.getArgument("ids"); if (ids == null || ids.isEmpty()) { return false; } try { store.remove(username, ids); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove notifications"); } return true; } }
RemoveNotificationMutation implements DataFetcher<Boolean> { @Override public Boolean get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { throw new GraphQLValidationError("username cannot be empty"); } final List<String> ids = environment.getArgument("ids"); if (ids == null || ids.isEmpty()) { return false; } try { store.remove(username, ids); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove notifications"); } return true; } RemoveNotificationMutation(final NotificationStore store); }
RemoveNotificationMutation implements DataFetcher<Boolean> { @Override public Boolean get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { throw new GraphQLValidationError("username cannot be empty"); } final List<String> ids = environment.getArgument("ids"); if (ids == null || ids.isEmpty()) { return false; } try { store.remove(username, ids); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove notifications"); } return true; } RemoveNotificationMutation(final NotificationStore store); @Override Boolean get(DataFetchingEnvironment environment); }
RemoveNotificationMutation implements DataFetcher<Boolean> { @Override public Boolean get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { throw new GraphQLValidationError("username cannot be empty"); } final List<String> ids = environment.getArgument("ids"); if (ids == null || ids.isEmpty()) { return false; } try { store.remove(username, ids); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove notifications"); } return true; } RemoveNotificationMutation(final NotificationStore store); @Override Boolean get(DataFetchingEnvironment environment);  }