Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.

Prototype

int STATUS_APPROVED

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.

Click Source Link

Usage

From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesCountWithStatusApprovedAndExcludedCategories() throws Exception {

    addCategory();//from   ww w  .  j a va 2  s.c om

    MBCategory excludedCategory1 = addCategory();
    MBCategory excludedCategory2 = addCategory();

    MBCategory draftCategory = addCategory();

    MBCategoryLocalServiceUtil.updateStatus(draftCategory.getUserId(), draftCategory.getCategoryId(),
            WorkflowConstants.STATUS_DRAFT);

    Assert.assertEquals(3, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(),
            MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED));
    Assert.assertEquals(1, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(),
            new long[] { excludedCategory1.getCategoryId(), excludedCategory2.getCategoryId() },
            new long[] { MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID }, WorkflowConstants.STATUS_APPROVED));
}

From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesCountWithStatusApprovedAndExcludedCategory() throws Exception {

    addCategory();/*from  w ww .j  a va2 s  . co m*/

    MBCategory excludedCategory = addCategory();
    MBCategory draftCategory = addCategory();

    MBCategoryLocalServiceUtil.updateStatus(draftCategory.getUserId(), draftCategory.getCategoryId(),
            WorkflowConstants.STATUS_DRAFT);

    Assert.assertEquals(2, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(),
            MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED));
    Assert.assertEquals(1,
            MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(), excludedCategory.getCategoryId(),
                    MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED));
}

From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesWithStatusApprovedAndExcludedCategories() throws Exception {

    List<MBCategory> expectedCategories = new ArrayList<>();

    expectedCategories.add(addCategory());

    MBCategory excludedCategory1 = addCategory();

    expectedCategories.add(excludedCategory1);

    MBCategory excludedCategory2 = addCategory();

    expectedCategories.add(excludedCategory2);

    MBCategory draftCategory = addCategory();

    MBCategoryLocalServiceUtil.updateStatus(draftCategory.getUserId(), draftCategory.getCategoryId(),
            WorkflowConstants.STATUS_DRAFT);

    List<MBCategory> categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(),
            WorkflowConstants.STATUS_APPROVED);

    AssertUtils.assertEquals(expectedCategories, categories);

    expectedCategories.remove(excludedCategory1);
    expectedCategories.remove(excludedCategory2);

    categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(),
            new long[] { excludedCategory1.getCategoryId(), excludedCategory2.getCategoryId() },
            new long[] { MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID }, WorkflowConstants.STATUS_APPROVED,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    AssertUtils.assertEquals(expectedCategories, categories);
}

From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesWithStatusApprovedAndExcludedCategory() throws Exception {

    List<MBCategory> expectedCategories = new ArrayList<>();

    expectedCategories.add(addCategory());

    MBCategory excludedCategory = addCategory();

    expectedCategories.add(excludedCategory);

    MBCategory draftCategory = addCategory();

    MBCategoryLocalServiceUtil.updateStatus(draftCategory.getUserId(), draftCategory.getCategoryId(),
            WorkflowConstants.STATUS_DRAFT);

    List<MBCategory> categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(),
            WorkflowConstants.STATUS_APPROVED);

    AssertUtils.assertEquals(expectedCategories, categories);

    expectedCategories.remove(excludedCategory);

    categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(), excludedCategory.getCategoryId(),
            MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    AssertUtils.assertEquals(expectedCategories, categories);
}

From source file:com.liferay.message.boards.service.test.MBCategoryServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesAndThreadsCountInRootCategory() throws Exception {

    addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    MBCategory category1 = addCategory();

    addMessage(category1.getCategoryId());

    MBCategory category2 = addCategory();

    addMessage(category2.getCategoryId());

    addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        int categoriesAndThreadsCount = MBCategoryServiceUtil.getCategoriesAndThreadsCount(_group.getGroupId(),
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(4, categoriesAndThreadsCount);
    }/* w  ww .  j a va 2 s .  c o m*/
}

From source file:com.liferay.message.boards.service.test.MBCategoryServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesAndThreadsCountInRootCategoryWithOnlyCategories() throws Exception {

    MBCategory category1 = addCategory();

    addCategory(category1.getCategoryId());

    addCategory();//from   w  w w . ja  v a 2 s .  co  m

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        int categoriesAndThreadsCount = MBCategoryServiceUtil.getCategoriesAndThreadsCount(_group.getGroupId(),
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(2, categoriesAndThreadsCount);
    }
}

From source file:com.liferay.message.boards.service.test.MBCategoryServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesAndThreadsCountInRootCategoryWithOnlyThreads() throws Exception {

    addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        int categoriesAndThreadsCount = MBCategoryServiceUtil.getCategoriesAndThreadsCount(_group.getGroupId(),
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(2, categoriesAndThreadsCount);
    }/*from   ww  w. j  av a  2s.c  o m*/
}

From source file:com.liferay.message.boards.service.test.MBCategoryServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesAndThreadsCountWithOnlyCategories() throws Exception {

    MBCategory category1 = addCategory();

    addCategory(category1.getCategoryId());

    addCategory();/*from ww w.  j a v  a  2 s.com*/

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        int categoriesAndThreadsCount = MBCategoryServiceUtil.getCategoriesAndThreadsCount(_group.getGroupId(),
                category1.getCategoryId(), WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(1, categoriesAndThreadsCount);
    }
}

From source file:com.liferay.message.boards.service.test.MBCategoryServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesAndThreadsInRootCategory() throws Exception {
    MBMessage message1 = addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    MBCategory category1 = addCategory();

    addMessage(category1.getCategoryId());

    MBCategory category2 = addCategory();

    addMessage(category2.getCategoryId());

    MBMessage message2 = addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        List<Object> categoriesAndThreads = MBCategoryServiceUtil.getCategoriesAndThreads(_group.getGroupId(),
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(categoriesAndThreads.toString(), 4, categoriesAndThreads.size());
        Assert.assertEquals(category1, categoriesAndThreads.get(0));
        Assert.assertEquals(category2, categoriesAndThreads.get(1));
        Assert.assertEquals(message1.getThread(), categoriesAndThreads.get(2));
        Assert.assertEquals(message2.getThread(), categoriesAndThreads.get(3));
    }//from w w  w .  j  a  v a 2  s.c o  m
}

From source file:com.liferay.message.boards.service.test.MBCategoryServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesAndThreadsInRootCategoryWithOnlyCategories() throws Exception {

    MBCategory category1 = addCategory();

    addCategory(category1.getCategoryId());

    MBCategory category2 = addCategory();

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        List<Object> categoriesAndThreads = MBCategoryServiceUtil.getCategoriesAndThreads(_group.getGroupId(),
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(categoriesAndThreads.toString(), 2, categoriesAndThreads.size());
        Assert.assertEquals(category1, categoriesAndThreads.get(0));
        Assert.assertEquals(category2, categoriesAndThreads.get(1));
    }/* w  ww.  j av a  2  s  .  c  o m*/
}