JournalArticleContentDashboardItem implements ContentDashboardItem<JournalArticle> { @Override public List<Version> getVersions(Locale locale) { return Stream.of( _toVersionOptional(_journalArticle, locale), _toVersionOptional(_latestApprovedJournalArticle, locale) ).filter( Optional::isPresent ).map( Optional::get ).sorted( Comparator.comparing(Version::getVersion) ).collect( Collectors.toList() ); } JournalArticleContentDashboardItem(
		List<AssetCategory> assetCategories, List<AssetTag> assetTags,
		ContentDashboardItemActionProviderTracker
			contentDashboardItemActionProviderTracker,
		ContentDashboardItemType contentDashboardItemType, Group group,
		InfoItemFieldValuesProvider<JournalArticle> infoItemFieldValuesProvider,
		JournalArticle journalArticle, Language language,
		JournalArticle latestApprovedJournalArticle); @Override List<AssetCategory> getAssetCategories(); @Override List<AssetCategory> getAssetCategories(long assetVocabularyId); @Override List<AssetTag> getAssetTags(); @Override List<Locale> getAvailableLocales(); @Override List<ContentDashboardItemAction> getContentDashboardItemActions(
		HttpServletRequest httpServletRequest,
		ContentDashboardItemAction.Type... types); @Override ContentDashboardItemType getContentDashboardItemType(); @Override Date getCreateDate(); @Override Map<String, Object> getData(Locale locale); @Override Locale getDefaultLocale(); @Override Object getDisplayFieldValue(String fieldName, Locale locale); @Override InfoItemReference getInfoItemReference(); @Override Date getModifiedDate(); @Override String getScopeName(Locale locale); @Override String getTitle(Locale locale); @Override long getUserId(); @Override List<Version> getVersions(Locale locale); @Override boolean isViewable(HttpServletRequest httpServletRequest);  }
@Test public void testGetVersions() { JournalArticle journalArticle = _getJournalArticle(); Mockito.when( journalArticle.getStatus() ).thenReturn( WorkflowConstants.STATUS_APPROVED ); JournalArticleContentDashboardItem journalArticleContentDashboardItem = new JournalArticleContentDashboardItem( null, null, null, null, null, null, journalArticle, _getLanguage(), null); List<ContentDashboardItem.Version> versions = journalArticleContentDashboardItem.getVersions(LocaleUtil.US); Assert.assertEquals(versions.toString(), 1, versions.size()); ContentDashboardItem.Version version = versions.get(0); Assert.assertEquals( WorkflowConstants.LABEL_APPROVED, version.getLabel()); Assert.assertEquals("success", version.getStyle()); }
@Test public void testGetVersionsWithApprovedVersion() { JournalArticle journalArticle1 = _getJournalArticle(); Mockito.when( journalArticle1.getStatus() ).thenReturn( WorkflowConstants.STATUS_DRAFT ); Mockito.when( journalArticle1.getVersion() ).thenReturn( 1.1 ); JournalArticle journalArticle2 = _getJournalArticle(); Mockito.when( journalArticle2.getStatus() ).thenReturn( WorkflowConstants.STATUS_APPROVED ); Mockito.when( journalArticle1.getVersion() ).thenReturn( 1.0 ); JournalArticleContentDashboardItem journalArticleContentDashboardItem = new JournalArticleContentDashboardItem( null, null, null, null, null, null, journalArticle1, _getLanguage(), journalArticle2); List<ContentDashboardItem.Version> versions = journalArticleContentDashboardItem.getVersions(LocaleUtil.US); Assert.assertEquals(versions.toString(), 2, versions.size()); ContentDashboardItem.Version version1 = versions.get(0); Assert.assertEquals( WorkflowConstants.LABEL_APPROVED, version1.getLabel()); Assert.assertEquals("success", version1.getStyle()); ContentDashboardItem.Version version2 = versions.get(1); Assert.assertEquals(WorkflowConstants.LABEL_DRAFT, version2.getLabel()); Assert.assertEquals("secondary", version2.getStyle()); }