Example usage for com.liferay.portal.kernel.service.persistence GroupFinderUtil countByLayouts

List of usage examples for com.liferay.portal.kernel.service.persistence GroupFinderUtil countByLayouts

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service.persistence GroupFinderUtil countByLayouts.

Prototype

public static int countByLayouts(long companyId, long parentGroupId, boolean site, Boolean active) 

Source Link

Usage

From source file:com.liferay.site.service.persistence.test.GroupFinderTest.java

License:Open Source License

@Test
public void testFindByLayouts2() throws Exception {
    int initialGroupCount = GroupFinderUtil.countByLayouts(TestPropsValues.getCompanyId(),
            GroupConstants.DEFAULT_PARENT_GROUP_ID, true, true);

    GroupTestUtil.addGroup();/*from w  w  w  . ja  v a2  s.  c o  m*/

    Group parentGroup = GroupTestUtil.addGroup();

    LayoutTestUtil.addLayout(parentGroup, false);

    Group childGroup1 = GroupTestUtil.addGroup(parentGroup.getGroupId());

    LayoutTestUtil.addLayout(childGroup1, false);

    Group childGroup2 = GroupTestUtil.addGroup(parentGroup.getGroupId());

    LayoutTestUtil.addLayout(childGroup2, true);

    GroupLocalServiceUtil.updateGroup(parentGroup.getGroupId(), parentGroup.getParentGroupId(),
            parentGroup.getNameMap(), parentGroup.getDescriptionMap(), parentGroup.getType(),
            parentGroup.isManualMembership(), parentGroup.getMembershipRestriction(),
            parentGroup.getFriendlyURL(), parentGroup.isInheritContent(), false,
            ServiceContextTestUtil.getServiceContext());

    List<Group> groups = GroupFinderUtil.findByLayouts(TestPropsValues.getCompanyId(),
            GroupConstants.DEFAULT_PARENT_GROUP_ID, true, true, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
            new GroupNameComparator(true));

    Assert.assertEquals(groups.toString(), initialGroupCount, groups.size());

    groups = GroupFinderUtil.findByLayouts(TestPropsValues.getCompanyId(), parentGroup.getGroupId(), true, true,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, new GroupNameComparator(true));

    Assert.assertEquals(groups.toString(), 2, groups.size());
}