CategoriesService extends ConfigurationService<Categories> { public void deleteByName(String name) { Categories categories = retrieve(); Category category = findCategoryByName(categories, name); List<Category> values = new ArrayList<>(categories.getCategories()); values.remove(category); update(new Categories(values)); } @Inject  CategoriesService(CategoriesPersistenceService persistenceService, EntityEventSupport eventSupport); void create(Category category); void deleteByName(String name); void addRuleByName(String name, MatchRule matchRule);  }
@Test public void deleteByNameNoName() { thrown.expect(ValidationException.class); thrown.expectMessage("Category name must be specified."); categoriesService.deleteByName(" "); }
@Test public void deleteByNameNotFound() { thrown.expect(ValidationException.class); thrown.expectMessage("Category with name \"not-present\" not found."); categoriesService.deleteByName("not-present"); }
@Test public void deleteByName() { categoriesService.deleteByName("a"); assertNotNull(savedCategories); assertEquals(ImmutableList.of(), savedCategories.getCategories()); }