Exemple #1
0
  protected void testScheduleArticle(boolean approved, int when) throws Exception {

    int initialSearchArticlesCount =
        JournalTestUtil.getSearchArticlesCount(_group.getCompanyId(), _group.getGroupId());

    Date now = new Date();

    JournalArticle article = addArticle(_group.getGroupId(), now, when, approved);

    JournalArticleLocalServiceUtil.checkArticles();

    article = JournalArticleLocalServiceUtil.getArticle(article.getId());

    AssetEntry assetEntry =
        AssetEntryLocalServiceUtil.getEntry(
            JournalArticle.class.getName(), article.getResourcePrimKey());

    if (when == _WHEN_FUTURE) {
      Assert.assertFalse(article.isApproved());
      Assert.assertFalse(assetEntry.isVisible());

      if (approved) {
        Assert.assertTrue(article.isScheduled());
      } else {
        Assert.assertTrue(article.isDraft());
      }
    } else {
      Assert.assertFalse(article.isScheduled());
      Assert.assertEquals(approved, article.isApproved());
      Assert.assertEquals(approved, assetEntry.isVisible());

      if (approved) {
        Assert.assertEquals(
            initialSearchArticlesCount + 1,
            JournalTestUtil.getSearchArticlesCount(_group.getCompanyId(), _group.getGroupId()));
      } else {
        Assert.assertEquals(
            initialSearchArticlesCount,
            JournalTestUtil.getSearchArticlesCount(_group.getCompanyId(), _group.getGroupId()));
      }
    }
  }
Exemple #2
0
  protected JournalArticle addArticle(long groupId, Date displayDate, int when, boolean approved)
      throws Exception {

    Map<Locale, String> titleMap = new HashMap<Locale, String>();

    titleMap.put(LocaleUtil.getDefault(), ServiceTestUtil.randomString());

    Map<Locale, String> descriptionMap = new HashMap<Locale, String>();

    descriptionMap.put(LocaleUtil.getDefault(), ServiceTestUtil.randomString());

    String content = DDMStructureTestUtil.getSampleStructuredContent();

    String xsd = DDMStructureTestUtil.getSampleStructureXSD();

    DDMStructure ddmStructure =
        DDMStructureTestUtil.addStructure(groupId, JournalArticle.class.getName(), xsd);

    DDMTemplate ddmTemplate =
        DDMTemplateTestUtil.addTemplate(groupId, ddmStructure.getStructureId());

    Calendar displayDateCalendar = getCalendar(displayDate, when);

    ServiceContext serviceContext = ServiceTestUtil.getServiceContext(groupId);

    if (approved) {
      serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);
    } else {
      serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
    }

    return JournalArticleLocalServiceUtil.addArticle(
        TestPropsValues.getUserId(),
        groupId,
        JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID,
        JournalArticleConstants.CLASSNAME_ID_DEFAULT,
        0,
        StringPool.BLANK,
        true,
        JournalArticleConstants.VERSION_DEFAULT,
        titleMap,
        descriptionMap,
        content,
        "general",
        ddmStructure.getStructureKey(),
        ddmTemplate.getTemplateKey(),
        null,
        displayDateCalendar.get(Calendar.MONTH),
        displayDateCalendar.get(Calendar.DAY_OF_MONTH),
        displayDateCalendar.get(Calendar.YEAR),
        displayDateCalendar.get(Calendar.HOUR_OF_DAY),
        displayDateCalendar.get(Calendar.MINUTE),
        0,
        0,
        0,
        0,
        0,
        true,
        0,
        0,
        0,
        0,
        0,
        true,
        true,
        false,
        null,
        null,
        null,
        null,
        serviceContext);
  }