@Test public final void shouldReturnEmptyMenu() { MenuDefinition menuDefinition = menuService.getMenu(Locale.ENGLISH); Assert.assertNull(menuDefinition.getAdministrationCategory()); Assert.assertNull(menuDefinition.getHomeCategory()); assertEquals(0, menuDefinition.getItems().size()); }
@Override @Transactional(readOnly = true) @Monitorable public MenuDefinition getMenu(final Locale locale) { MenuDefinition menuDefinition = new MenuDefinition(); List<Entity> menuCategories = menuCrudService.getSortedMenuCategories(); for (Entity menuCategory : menuCategories) { String authRoleIdentifier = menuCategory.getStringField(MenuCategoryFields.AUTH_ROLE); if (!currentUserHasPrivilegesOf(authRoleIdentifier)) { continue; } MenuItemsGroup category = buildCategoryWithItems(menuCategory, locale); if (ADMINISTRATION_CATEGORY.equals(category.getName())) { menuDefinition.setAdministrationCategory(category); } else if (HOME_CATEGORY.equals(category.getName())) { menuDefinition.setHomeCategory(category); } else if (!category.getItems().isEmpty()) { menuDefinition.addItem(category); } } return menuDefinition; }
MenuServiceImpl implements InternalMenuService { @Override @Transactional(readOnly = true) @Monitorable public MenuDefinition getMenu(final Locale locale) { MenuDefinition menuDefinition = new MenuDefinition(); List<Entity> menuCategories = menuCrudService.getSortedMenuCategories(); for (Entity menuCategory : menuCategories) { String authRoleIdentifier = menuCategory.getStringField(MenuCategoryFields.AUTH_ROLE); if (!currentUserHasPrivilegesOf(authRoleIdentifier)) { continue; } MenuItemsGroup category = buildCategoryWithItems(menuCategory, locale); if (ADMINISTRATION_CATEGORY.equals(category.getName())) { menuDefinition.setAdministrationCategory(category); } else if (HOME_CATEGORY.equals(category.getName())) { menuDefinition.setHomeCategory(category); } else if (!category.getItems().isEmpty()) { menuDefinition.addItem(category); } } return menuDefinition; } }
MenuServiceImpl implements InternalMenuService { @Override @Transactional(readOnly = true) @Monitorable public MenuDefinition getMenu(final Locale locale) { MenuDefinition menuDefinition = new MenuDefinition(); List<Entity> menuCategories = menuCrudService.getSortedMenuCategories(); for (Entity menuCategory : menuCategories) { String authRoleIdentifier = menuCategory.getStringField(MenuCategoryFields.AUTH_ROLE); if (!currentUserHasPrivilegesOf(authRoleIdentifier)) { continue; } MenuItemsGroup category = buildCategoryWithItems(menuCategory, locale); if (ADMINISTRATION_CATEGORY.equals(category.getName())) { menuDefinition.setAdministrationCategory(category); } else if (HOME_CATEGORY.equals(category.getName())) { menuDefinition.setHomeCategory(category); } else if (!category.getItems().isEmpty()) { menuDefinition.addItem(category); } } return menuDefinition; }  }
MenuServiceImpl implements InternalMenuService { @Override @Transactional(readOnly = true) @Monitorable public MenuDefinition getMenu(final Locale locale) { MenuDefinition menuDefinition = new MenuDefinition(); List<Entity> menuCategories = menuCrudService.getSortedMenuCategories(); for (Entity menuCategory : menuCategories) { String authRoleIdentifier = menuCategory.getStringField(MenuCategoryFields.AUTH_ROLE); if (!currentUserHasPrivilegesOf(authRoleIdentifier)) { continue; } MenuItemsGroup category = buildCategoryWithItems(menuCategory, locale); if (ADMINISTRATION_CATEGORY.equals(category.getName())) { menuDefinition.setAdministrationCategory(category); } else if (HOME_CATEGORY.equals(category.getName())) { menuDefinition.setHomeCategory(category); } else if (!category.getItems().isEmpty()) { menuDefinition.addItem(category); } } return menuDefinition; }  @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); }
MenuServiceImpl implements InternalMenuService { @Override @Transactional(readOnly = true) @Monitorable public MenuDefinition getMenu(final Locale locale) { MenuDefinition menuDefinition = new MenuDefinition(); List<Entity> menuCategories = menuCrudService.getSortedMenuCategories(); for (Entity menuCategory : menuCategories) { String authRoleIdentifier = menuCategory.getStringField(MenuCategoryFields.AUTH_ROLE); if (!currentUserHasPrivilegesOf(authRoleIdentifier)) { continue; } MenuItemsGroup category = buildCategoryWithItems(menuCategory, locale); if (ADMINISTRATION_CATEGORY.equals(category.getName())) { menuDefinition.setAdministrationCategory(category); } else if (HOME_CATEGORY.equals(category.getName())) { menuDefinition.setHomeCategory(category); } else if (!category.getItems().isEmpty()) { menuDefinition.addItem(category); } } return menuDefinition; }  @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);  }