@Test public void testUsernameNull() throws Exception { when(environment.getArgument("username")).thenReturn(null); try { mutation.get(environment); failBecauseExceptionWasNotThrown(GraphQLValidationError.class); } catch (GraphQLValidationError e) { assertThat(e.getMessage()).isEqualTo("username cannot be empty"); } verify(store, never()).removeAll(anyString()); }
@Override public Boolean get(DataFetchingEnvironment environment) { final String username = environment.getArgument("username"); if (Strings.isNullOrEmpty(username)) { throw new GraphQLValidationError("username cannot be empty"); } try { store.removeAll(username); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove all notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove all notifications"); } return true; }
RemoveAllNotificationsMutation 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"); } try { store.removeAll(username); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove all notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove all notifications"); } return true; } }
RemoveAllNotificationsMutation 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"); } try { store.removeAll(username); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove all notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove all notifications"); } return true; } RemoveAllNotificationsMutation(final NotificationStore store); }
RemoveAllNotificationsMutation 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"); } try { store.removeAll(username); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove all notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove all notifications"); } return true; } RemoveAllNotificationsMutation(final NotificationStore store); @Override Boolean get(DataFetchingEnvironment environment); }
RemoveAllNotificationsMutation 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"); } try { store.removeAll(username); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove all notifications for %s", username), e); throw new GraphQLValidationError("Unable to remove all notifications"); } return true; } RemoveAllNotificationsMutation(final NotificationStore store); @Override Boolean get(DataFetchingEnvironment environment);  }