@Test public void testCategoryNull() throws Exception { when(environment.getArgument("category")).thenReturn(null); try { mutation.get(environment); failBecauseExceptionWasNotThrown(GraphQLValidationError.class); } catch (GraphQLValidationError e) { assertThat(e.getMessage()).isEqualTo("category cannot be empty"); } verify(store, never()).remove(anyString()); }
@Override public Boolean get(DataFetchingEnvironment environment) { final String category = environment.getArgument("category"); if (Strings.isNullOrEmpty(category)) { throw new GraphQLValidationError("category cannot be empty"); } try { store.remove(category); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove rule for %s", category), e); throw new GraphQLValidationError("Unable to remove rule"); } return true; }
RemoveRuleMutation implements DataFetcher<Boolean> { @Override public Boolean get(DataFetchingEnvironment environment) { final String category = environment.getArgument("category"); if (Strings.isNullOrEmpty(category)) { throw new GraphQLValidationError("category cannot be empty"); } try { store.remove(category); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove rule for %s", category), e); throw new GraphQLValidationError("Unable to remove rule"); } return true; } }
RemoveRuleMutation implements DataFetcher<Boolean> { @Override public Boolean get(DataFetchingEnvironment environment) { final String category = environment.getArgument("category"); if (Strings.isNullOrEmpty(category)) { throw new GraphQLValidationError("category cannot be empty"); } try { store.remove(category); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove rule for %s", category), e); throw new GraphQLValidationError("Unable to remove rule"); } return true; } RemoveRuleMutation(final RuleStore store); }
RemoveRuleMutation implements DataFetcher<Boolean> { @Override public Boolean get(DataFetchingEnvironment environment) { final String category = environment.getArgument("category"); if (Strings.isNullOrEmpty(category)) { throw new GraphQLValidationError("category cannot be empty"); } try { store.remove(category); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove rule for %s", category), e); throw new GraphQLValidationError("Unable to remove rule"); } return true; } RemoveRuleMutation(final RuleStore store); @Override Boolean get(DataFetchingEnvironment environment); }
RemoveRuleMutation implements DataFetcher<Boolean> { @Override public Boolean get(DataFetchingEnvironment environment) { final String category = environment.getArgument("category"); if (Strings.isNullOrEmpty(category)) { throw new GraphQLValidationError("category cannot be empty"); } try { store.remove(category); } catch (NotificationStoreException e) { LOGGER.error(String.format("Unable to remove rule for %s", category), e); throw new GraphQLValidationError("Unable to remove rule"); } return true; } RemoveRuleMutation(final RuleStore store); @Override Boolean get(DataFetchingEnvironment environment);  }