### Question:
MenuServiceImpl implements InternalMenuService { @Override @Transactional public void removeCategory(final MenuCategoryDefinition menuCategoryDefinition) { Entity menuCategory = menuCrudService.getCategory(menuCategoryDefinition); if (menuCategory == null) { return; } if (menuCategory.getHasManyField(MenuCategoryFields.ITEMS).size() == 0) { menuCrudService.delete(menuCategory); } }  @Override @Transactional(readOnly = true) @Monitorable MenuDefinition getMenu(final Locale locale); @Override @Transactional void addView(final MenuItemDefinition itemDefinition); @Override @Transactional void removeView(final MenuItemDefinition itemDefinition); @Override @Transactional void createCategory(final MenuCategoryDefinition menuCategoryDefinition); @Override @Transactional void removeCategory(final MenuCategoryDefinition menuCategoryDefinition); @Override @Transactional void createItem(final MenuItemDefinition itemDefinition); @Override @Transactional void removeItem(final MenuItemDefinition itemDefinition);  }### Answer:
@Test public final void shouldNotRemoveCategoryIfHasAnyItems() { MenuCategoryDefinition menuCategoryDefinition = new MenuCategoryDefinition(PLUGIN_IDENTIFIER, "categoryName", ROLE_VISIBLE); Entity itemEntity = mock(Entity.class); Entity categoryEntity = mockCategory(PLUGIN_IDENTIFIER, "categoryName", ROLE_VISIBLE, Lists.newArrayList(itemEntity)); given(menuCrudService.getCategory(menuCategoryDefinition)).willReturn(categoryEntity); menuService.removeCategory(menuCategoryDefinition); verify(menuCrudService, never()).delete(categoryEntity); }
@Test public final void shouldRemoveCategory() { MenuCategoryDefinition menuCategoryDefinition = new MenuCategoryDefinition(PLUGIN_IDENTIFIER, "categoryName", ROLE_VISIBLE); Entity categoryEntity = mockCategory(PLUGIN_IDENTIFIER, "categoryName", ROLE_VISIBLE, Collections.<Entity> emptyList()); given(menuCrudService.getCategory(menuCategoryDefinition)).willReturn(categoryEntity); menuService.removeCategory(menuCategoryDefinition); verify(menuCrudService).delete(categoryEntity); }