DepotAdminMembershipsDisplayContext { public List<Group> getDepotGroups(int start, int end) throws PortalException { List<Group> depotGroups = _getDepotGroups(); return ListUtil.subList(depotGroups, start, end); } DepotAdminMembershipsDisplayContext(
			ItemSelector itemSelector,
			LiferayPortletRequest liferayPortletRequest,
			LiferayPortletResponse liferayPortletResponse); List<Group> getDepotGroups(int start, int end); int getDepotGroupsCount(); String getItemSelectorEventName(); PortletURL getItemSelectorURL(); String getLabel(); String getRoles(Group group); User getUser(); boolean isDeletable(); boolean isSelectable();  }
@Test public void testGetDepotGroupsWithDepotAndCompanyAdmin() throws Exception { Group group = getDepotGroup(); Mockito.when( _user.getGroups() ).thenReturn( Collections.singletonList(group) ); DepotAdminMembershipsDisplayContext depotAdminMembershipsDisplayContext = new DepotAdminMembershipsDisplayContext( Mockito.mock(ItemSelector.class), _getLiferayPortletRequest( new ThemeDisplayBuilder().withPermissionChecker( getPermissionCheckerWithCompanyAdmin() ).build()), null); List<Group> depots = depotAdminMembershipsDisplayContext.getDepotGroups( 0, 20); Assert.assertEquals(depots.toString(), 1, depots.size()); }
@Test public void testGetDepotGroupsWithDepotAndNoCompanyAdminAndAssignMember() throws Exception { Group group = getDepotGroup(); Mockito.when( _user.getGroups() ).thenReturn( Collections.singletonList(group) ); DepotAdminMembershipsDisplayContext depotAdminMembershipsDisplayContext = new DepotAdminMembershipsDisplayContext( Mockito.mock(ItemSelector.class), _getLiferayPortletRequest( new ThemeDisplayBuilder().withPermissionChecker( getPermissionCheckerWithNoCompanyAdminAndAssignMember() ).build()), null); List<Group> depots = depotAdminMembershipsDisplayContext.getDepotGroups( 0, 20); Assert.assertEquals(depots.toString(), 1, depots.size()); }
@Test public void testGetDepotGroupsWithDepotAndNoCompanyAdminAndNoAssignMember() throws Exception { Group group = getDepotGroup(); Mockito.when( _user.getGroups() ).thenReturn( Collections.singletonList(group) ); DepotAdminMembershipsDisplayContext depotAdminMembershipsDisplayContext = new DepotAdminMembershipsDisplayContext( Mockito.mock(ItemSelector.class), _getLiferayPortletRequest( new ThemeDisplayBuilder().withPermissionChecker( getPermissionCheckerWithNoCompanyAdminAndNoAssignMember() ).build()), null); List<Group> depots = depotAdminMembershipsDisplayContext.getDepotGroups( 0, 20); Assert.assertEquals(depots.toString(), 0, depots.size()); }
@Test public void testGetDepotGroupsWithSite() throws Exception { Group group = getSiteGroup(); Mockito.when( _user.getGroups() ).thenReturn( Collections.singletonList(group) ); DepotAdminMembershipsDisplayContext depotAdminMembershipsDisplayContext = new DepotAdminMembershipsDisplayContext( Mockito.mock(ItemSelector.class), _getLiferayPortletRequest( new ThemeDisplayBuilder().build()), null); List<Group> depots = depotAdminMembershipsDisplayContext.getDepotGroups( 0, 20); Assert.assertEquals(depots.toString(), 0, depots.size()); }