CCM NG/ccm-cms: Copying and moving items to another contentsection is now supported by the ContentItemManager.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4374 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-10-13 17:05:58 +00:00
parent 325c6fbc80
commit 938f44f106
6 changed files with 416 additions and 298 deletions

View File

@ -83,6 +83,12 @@ public class ContentItemManager {
@Inject @Inject
private CategoryManager categoryManager; private CategoryManager categoryManager;
@Inject
private FolderManager folderManager;
@Inject
private ContentSectionManager sectionManager;
@Inject @Inject
private ContentItemRepository contentItemRepo; private ContentItemRepository contentItemRepo;
@ -183,7 +189,7 @@ public class ContentItemManager {
type.getName())); type.getName()));
} }
if (name == null || name.isEmpty()) { if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The name of a content item can't be blank."); "The name of a content item can't be blank.");
} }
@ -233,7 +239,7 @@ public class ContentItemManager {
* a the item is republished. * a the item is republished.
* *
* @param item The item to move. * @param item The item to move.
* @param target The folder to which the item is moved. * @param targetFolder The folder to which the item is moved.
*/ */
@AuthorizationRequired @AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@ -241,12 +247,12 @@ public class ContentItemManager {
@RequiresPrivilege(CmsConstants.PRIVILEGE_ITEMS_EDIT) @RequiresPrivilege(CmsConstants.PRIVILEGE_ITEMS_EDIT)
final ContentItem item, final ContentItem item,
@RequiresPrivilege(CmsConstants.PRIVILEGE_ITEMS_EDIT) @RequiresPrivilege(CmsConstants.PRIVILEGE_ITEMS_EDIT)
final Folder target) { final Folder targetFolder) {
if (item == null) { if (item == null) {
throw new IllegalArgumentException("The item to move can't be null."); throw new IllegalArgumentException("The item to move can't be null.");
} }
if (target == null) { if (targetFolder == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The target folder can't be null."); "The target folder can't be null.");
} }
@ -254,6 +260,23 @@ public class ContentItemManager {
final ContentItem draftItem = getDraftVersion(item, item.getClass()); final ContentItem draftItem = getDraftVersion(item, item.getClass());
final Optional<Folder> currentFolder = getItemFolder(item); final Optional<Folder> currentFolder = getItemFolder(item);
if (!sectionManager.hasContentType(draftItem.getClass(),
targetFolder.getSection())) {
throw new IllegalArgumentException(String.format(
"Can't move item %d:\"%s\" to folder \"%s\"."
+ "The target folder %d:\"%s\" belongs to content section "
+ "%d:\"%s\". The content type \"%s\" has not registered"
+ "for this section.",
draftItem.getObjectId(),
draftItem.getDisplayName(),
folderManager.getFolderPath(targetFolder, true),
targetFolder.getObjectId(),
targetFolder.getDisplayName(),
targetFolder.getSection().getObjectId(),
targetFolder.getSection().getDisplayName(),
draftItem.getClass().getName()));
}
if (currentFolder.isPresent()) { if (currentFolder.isPresent()) {
try { try {
categoryManager.removeObjectFromCategory(draftItem, categoryManager.removeObjectFromCategory(draftItem,
@ -265,7 +288,7 @@ public class ContentItemManager {
categoryManager.addObjectToCategory( categoryManager.addObjectToCategory(
draftItem, draftItem,
target, targetFolder,
CmsConstants.CATEGORIZATION_TYPE_FOLDER); CmsConstants.CATEGORIZATION_TYPE_FOLDER);
} }
@ -279,10 +302,12 @@ public class ContentItemManager {
* target folder is the same folder as the folder of the * target folder is the same folder as the folder of the
* original item an index is appended to the name of the * original item an index is appended to the name of the
* item. * item.
*
* @return The copy of the item
*/ */
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void copy( public ContentItem copy(
final ContentItem item, final ContentItem item,
@RequiresPrivilege(CmsConstants.PRIVILEGE_ITEMS_CREATE_NEW) @RequiresPrivilege(CmsConstants.PRIVILEGE_ITEMS_CREATE_NEW)
final Folder targetFolder) { final Folder targetFolder) {
@ -308,6 +333,22 @@ public class ContentItemManager {
} }
final ContentItem draftItem = getDraftVersion(item, item.getClass()); final ContentItem draftItem = getDraftVersion(item, item.getClass());
if (!sectionManager.hasContentType(draftItem.getClass(),
targetFolder.getSection())) {
throw new IllegalArgumentException(String.format(
"Can't copy item %d:\"%s\" to folder \"%s\"."
+ "The target folder %d:\"%s\" belongs to content section "
+ "%d:\"%s\". The content type \"%s\" has not registered"
+ "for this section.",
draftItem.getObjectId(),
draftItem.getDisplayName(),
folderManager.getFolderPath(targetFolder, true),
targetFolder.getObjectId(),
targetFolder.getDisplayName(),
targetFolder.getSection().getObjectId(),
targetFolder.getSection().getDisplayName(),
draftItem.getClass().getName()));
}
final ContentItem copy; final ContentItem copy;
try { try {
@ -477,6 +518,8 @@ public class ContentItemManager {
} }
contentItemRepo.save(copy); contentItemRepo.save(copy);
return copy;
} }
private boolean propertyIsExcluded(final String name) { private boolean propertyIsExcluded(final String name) {

View File

@ -76,7 +76,6 @@ public class News extends ContentItem implements Serializable {
* the function recentItems. * the function recentItems.
*/ */
@Column(name = "HOMEPAGE") @Column(name = "HOMEPAGE")
@NotEmpty
private boolean homepage; private boolean homepage;
public LocalizedString getText() { public LocalizedString getText() {
@ -88,11 +87,11 @@ public class News extends ContentItem implements Serializable {
} }
public Date getReleaseDate() { public Date getReleaseDate() {
return releaseDate; return new Date(releaseDate.getTime());
} }
public void setReleaseDate(final Date releaseDate) { public void setReleaseDate(final Date releaseDate) {
this.releaseDate = releaseDate; this.releaseDate = new Date(releaseDate.getTime());
} }
public boolean isHomepage() { public boolean isHomepage() {

View File

@ -37,7 +37,6 @@ import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.libreccm.categorization.CategoryRepository;
import org.libreccm.security.Shiro; import org.libreccm.security.Shiro;
import org.libreccm.tests.categories.IntegrationTest; import org.libreccm.tests.categories.IntegrationTest;
import org.libreccm.workflow.WorkflowTemplate; import org.libreccm.workflow.WorkflowTemplate;
@ -116,61 +115,61 @@ public class ContentItemManagerTest {
@Deployment @Deployment
public static WebArchive createDeployment() { public static WebArchive createDeployment() {
return ShrinkWrap return ShrinkWrap
.create(WebArchive.class, .create(WebArchive.class,
"LibreCCM-org.librecms.contentsection.ContentItemManagerTest.war"). "LibreCCM-org.librecms.contentsection.ContentItemManagerTest.war")
addPackage(org.libreccm.auditing.CcmRevision.class.getPackage()) .addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
.addPackage(org.libreccm.categorization.Categorization.class .addPackage(org.libreccm.categorization.Categorization.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage()) .addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
.addPackage(org.libreccm.configuration.Configuration.class .addPackage(org.libreccm.configuration.Configuration.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.core.CcmCore.class.getPackage()) .addPackage(org.libreccm.core.CcmCore.class.getPackage())
.addPackage(org.libreccm.jpa.EntityManagerProducer.class .addPackage(org.libreccm.jpa.EntityManagerProducer.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.security.Permission.class.getPackage()) .addPackage(org.libreccm.security.Permission.class.getPackage())
.addPackage(org.libreccm.web.CcmApplication.class.getPackage()) .addPackage(org.libreccm.web.CcmApplication.class.getPackage())
.addPackage(org.libreccm.workflow.Workflow.class.getPackage()) .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addPackage(com.arsdigita.bebop.Component.class.getPackage()) .addPackage(com.arsdigita.bebop.Component.class.getPackage())
.addPackage(com.arsdigita.bebop.util.BebopConstants.class .addPackage(com.arsdigita.bebop.util.BebopConstants.class
.getPackage()) .getPackage())
.addClass(com.arsdigita.kernel.KernelConfig.class) .addClass(com.arsdigita.kernel.KernelConfig.class)
.addClass(com.arsdigita.runtime.CCMResourceManager.class) .addClass(com.arsdigita.runtime.CCMResourceManager.class)
.addClass( .addClass(
com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class). com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class)
addClass( .addClass(
com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class). com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class)
addClass( .addClass(
com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class). com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class)
addClass( .addClass(
com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class). com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class)
addClass(com.arsdigita.cms.dispatcher.ItemResolver.class) .addClass(com.arsdigita.cms.dispatcher.ItemResolver.class)
.addPackage(com.arsdigita.util.Lockable.class.getPackage()) .addPackage(com.arsdigita.util.Lockable.class.getPackage())
.addPackage(com.arsdigita.web.BaseServlet.class.getPackage()) .addPackage(com.arsdigita.web.BaseServlet.class.getPackage())
.addPackage(org.librecms.Cms.class.getPackage()) .addPackage(org.librecms.Cms.class.getPackage())
.addPackage(org.librecms.assets.Asset.class.getPackage()) .addPackage(org.librecms.assets.Asset.class.getPackage())
.addPackage(org.librecms.attachments.AttachmentList.class .addPackage(org.librecms.attachments.AttachmentList.class
.getPackage()) .getPackage())
.addPackage(org.librecms.lifecycle.Lifecycle.class.getPackage()) .addPackage(org.librecms.lifecycle.Lifecycle.class.getPackage())
.addPackage(org.librecms.contentsection.ContentSection.class .addPackage(org.librecms.contentsection.ContentSection.class
.getPackage()) .getPackage())
.addPackage(org.librecms.contenttypes.Article.class.getPackage()). .addPackage(org.librecms.contenttypes.Article.class.getPackage()).
addClass(com.arsdigita.kernel.security.SecurityConfig.class) addClass(com.arsdigita.kernel.security.SecurityConfig.class)
.addPackage(org.libreccm.tests.categories.IntegrationTest.class .addPackage(org.libreccm.tests.categories.IntegrationTest.class
.getPackage()) .getPackage())
// .addAsLibraries(getModuleDependencies()) // .addAsLibraries(getModuleDependencies())
.addAsLibraries(getCcmCoreDependencies()) .addAsLibraries(getCcmCoreDependencies())
.addAsResource("configs/shiro.ini", "shiro.ini") .addAsResource("configs/shiro.ini", "shiro.ini")
.addAsResource( .addAsResource(
"configs/org/librecms/contentsection/ContentItemManagerTest/log4j2.xml", "configs/org/librecms/contentsection/ContentItemManagerTest/log4j2.xml",
"log4j2.xml") "log4j2.xml")
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",
"META-INF/persistence.xml") "META-INF/persistence.xml")
.addAsWebInfResource("test-web.xml", "web.xml") .addAsWebInfResource("test-web.xml", "web.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml"); .addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
} }
/** /**
@ -206,23 +205,23 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(1100) @InSequence(1100)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-create-contentitem.xml", + "ContentItemManagerTest/after-create-contentitem.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "id",
"item_uuid", "item_uuid",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"task_id", "task_id",
"uuid", "uuid",
"timestamp", "timestamp",
"workflow_id" "workflow_id"
}) })
public void createContentItem() { public void createContentItem() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
final Folder folder = section.getRootDocumentsFolder(); final Folder folder = section.getRootDocumentsFolder();
@ -242,10 +241,10 @@ public class ContentItemManagerTest {
article.getWorkflow(), is(not(nullValue()))); article.getWorkflow(), is(not(nullValue())));
final TypedQuery<Long> query = entityManager.createQuery( final TypedQuery<Long> query = entityManager.createQuery(
"SELECT COUNT(w) FROM Workflow w", Long.class); "SELECT COUNT(w) FROM Workflow w", Long.class);
final long workflowCount = query.getSingleResult(); final long workflowCount = query.getSingleResult();
assertThat("Expected three workflows in database.", assertThat("Expected three workflows in database.",
workflowCount, is(3L)); workflowCount, is(4L));
} }
/** /**
@ -257,9 +256,9 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(1200) @InSequence(1200)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemTypeNotInSection() { public void createItemTypeNotInSection() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
@ -276,9 +275,9 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(1300) @InSequence(1300)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNull() { public void createItemNameIsNull() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
@ -295,9 +294,9 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(1400) @InSequence(1400)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsEmpty() { public void createItemNameIsEmpty() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
@ -315,9 +314,9 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(1500) @InSequence(1500)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemFolderIsNull() { public void createItemFolderIsNull() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
@ -332,37 +331,37 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(2100) @InSequence(2100)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/" + "ContentItemManagerTest/"
+ "after-create-contentitem-with-workflow.xml", + "after-create-contentitem-with-workflow.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "id",
"item_uuid", "item_uuid",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"task_id", "task_id",
"timestamp", "timestamp",
"uuid", "uuid",
"workflow_id" "workflow_id"
}) })
public void createContentItemWithWorkflow() { public void createContentItemWithWorkflow() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
final Folder folder = section.getRootDocumentsFolder(); final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L); .findById(-110L);
final Article article = itemManager.createContentItem( final Article article = itemManager.createContentItem(
"new-article", "new-article",
section, section,
folder, folder,
workflowTemplate, workflowTemplate,
Article.class); Article.class);
assertThat("DisplayName has not the expected value.", assertThat("DisplayName has not the expected value.",
article.getDisplayName(), is(equalTo("new-article"))); article.getDisplayName(), is(equalTo("new-article")));
@ -374,10 +373,10 @@ public class ContentItemManagerTest {
article.getWorkflow(), is(not(nullValue()))); article.getWorkflow(), is(not(nullValue())));
final TypedQuery<Long> query = entityManager.createQuery( final TypedQuery<Long> query = entityManager.createQuery(
"SELECT COUNT(w) FROM Workflow w", Long.class); "SELECT COUNT(w) FROM Workflow w", Long.class);
final long workflowCount = query.getSingleResult(); final long workflowCount = query.getSingleResult();
assertThat("Expected three workflows in database.", assertThat("Expected three workflows in database.",
workflowCount, is(3L)); workflowCount, is(4L));
} }
/** /**
@ -389,16 +388,16 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(2200) @InSequence(2200)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemTypeNotInSectionWithWorkflow() { public void createItemTypeNotInSectionWithWorkflow() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
final Folder folder = section.getRootDocumentsFolder(); final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L); .findById(-110L);
itemManager.createContentItem("Test", itemManager.createContentItem("Test",
section, section,
@ -416,16 +415,16 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(2300) @InSequence(2300)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNullWithWorkflow() { public void createItemNameIsNullWithWorkflow() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
final Folder folder = section.getRootDocumentsFolder(); final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L); .findById(-110L);
itemManager.createContentItem(null, itemManager.createContentItem(null,
section, section,
@ -443,9 +442,9 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(2400) @InSequence(2400)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNullWorkflowIsNull() { public void createItemNameIsNullWorkflowIsNull() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
@ -467,15 +466,15 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(2600) @InSequence(2600)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemFolderIsNullWithWorkflow() { public void createItemFolderIsNullWithWorkflow() {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L); .findById(-110L);
itemManager.createContentItem("Test", itemManager.createContentItem("Test",
section, section,
@ -491,19 +490,19 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(3100) @InSequence(3100)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-move.xml", + "ContentItemManagerTest/after-move.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"task_id", "task_id",
"uuid", "uuid",
"workflow_id" "workflow_id"
}) })
public void moveItem() { public void moveItem() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -521,23 +520,54 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(3110) @InSequence(3110)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-move-to-other-section.xml", + "ContentItemManagerTest/after-move-to-other-section.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"task_id", "task_id",
"uuid", "uuid",
"workflow_id" "workflow_id"
}) })
public void moveToOtherContentSection() { public void moveToOtherContentSection() {
fail("Not implemented yet"); final Optional<ContentItem> item = itemRepo.findById(-10100L);
final Folder targetFolder = folderRepo.findById(-2300L);
assertThat(item.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue())));
itemManager.move(item.get(), targetFolder);
} }
/**
* Verifies that
* {@link ContentItemManager#move(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder)
* throws an {@link IllegalArgumentException} if the type of the item to
* copy has not been registered in content section to which the target
* folder belongs.
*/
@Test(expected = IllegalArgumentException.class)
@InSequence(4120)
@UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void moveToOtherContentSectionTypeNotPresent() {
final Optional<ContentItem> item = itemRepo.findById(-10400L);
final Folder targetFolder = folderRepo.findById(-2300L);
assertThat(item.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue())));
itemManager.move(item.get(), targetFolder);
}
/** /**
* Verifies that * Verifies that
* {@link ContentItemManager#move(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder)} * {@link ContentItemManager#move(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder)}
@ -547,9 +577,9 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(3200) @InSequence(3200)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveItemNull() { public void moveItemNull() {
final Folder targetFolder = folderRepo.findById(-2120L); final Folder targetFolder = folderRepo.findById(-2120L);
@ -567,11 +597,11 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(3200) @InSequence(3200)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveItemFolderNull() { public void moveItemTargetFolderIsNull() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -585,23 +615,23 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(4100) @InSequence(4100)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-copy-to-other-folder.xml", + "ContentItemManagerTest/after-copy-to-other-folder.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "id",
"item_uuid", "item_uuid",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"task_id", "task_id",
"uuid", "uuid",
"timestamp", "timestamp",
"workflow_id" "workflow_id"
}) })
public void copyToOtherFolder() { public void copyToOtherFolder() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -619,25 +649,58 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(4110) @InSequence(4110)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-copy-to-folder-in-other-section.xml", + "ContentItemManagerTest/after-copy-to-folder-in-other-section.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "content_type_id",
"item_uuid", "id",
"lifecycle_id", "item_uuid",
"object_id", "lifecycle_id",
"object_order", "object_id",
"phase_id", "object_order",
"rev", "phase_id",
"task_id", "rev",
"uuid", "task_id",
"timestamp", "uuid",
"workflow_id" "timestamp",
}) "workflow_id"})
public void copyToFolderInOtherSection() { public void copyToFolderInOtherSection() {
fail(); final Optional<ContentItem> source = itemRepo.findById(-10100L);
final Folder targetFolder = folderRepo.findById(-2300L);
assertThat(source.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue())));
final ContentItem target = itemManager.copy(source.get(), targetFolder);
assertThat(target.getUuid(), is(not(equalTo(source.get().getUuid()))));
assertThat(target.getItemUuid(), is(equalTo(target.getUuid())));
}
/**
* Verifies that
* {@link ContentItemManager#copy(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder)}
* throws an {@link IllegalArgumentException} if the type of the item to
* copy has not been registered in content section to which the target
* folder belongs.
*/
@Test(expected = IllegalArgumentException.class)
@InSequence(4120)
@UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void copyToFolderInOtherSectionTypeNotPresent() {
final Optional<ContentItem> source = itemRepo.findById(-10400L);
final Folder targetFolder = folderRepo.findById(-2300L);
assertThat(source.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue())));
itemManager.copy(source.get(), targetFolder);
} }
/** /**
@ -649,23 +712,23 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(4200) @InSequence(4200)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-copy-to-same-folder.xml", + "ContentItemManagerTest/after-copy-to-same-folder.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "id",
"item_uuid", "item_uuid",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"task_id", "task_id",
"timestamp", "timestamp",
"uuid", "uuid",
"workflow_id" "workflow_id"
}) })
public void copyToSameFolder() { public void copyToSameFolder() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -685,10 +748,10 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(4300) @InSequence(4300)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyItemNull() { public void copyItemNull() {
final Folder targetFolder = folderRepo.findById(-2120L); final Folder targetFolder = folderRepo.findById(-2120L);
@ -706,10 +769,10 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(4400) @InSequence(4400)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyItemToFolderNull() { public void copyItemToFolderNull() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
@ -728,22 +791,22 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(5100) @InSequence(5100)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-publish.xml", + "ContentItemManagerTest/after-publish.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "id",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"task_id", "task_id",
"timestamp", "timestamp",
"uuid", "uuid",
"workflow_id" "workflow_id"
}) })
public void publishItem() { public void publishItem() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -763,26 +826,26 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(5200) @InSequence(5200)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-publish.xml", + "ContentItemManagerTest/after-publish.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "id",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"task_id", "task_id",
"timestamp", "timestamp",
"uuid", "uuid",
"workflow_id" "workflow_id"
}) })
public void publishItemWithLifecycle() { public void publishItemWithLifecycle() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
final LifecycleDefinition lifecycleDef = lifecycleDefinitionRepo final LifecycleDefinition lifecycleDef = lifecycleDefinitionRepo
.findById(-200L); .findById(-200L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
assertThat(lifecycleDef, is(not(nullValue()))); assertThat(lifecycleDef, is(not(nullValue())));
@ -798,29 +861,29 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(5300) @InSequence(5300)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-republish.xml", + "ContentItemManagerTest/after-republish.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "id",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"revend", "revend",
"task_id", "task_id",
"timestamp", "timestamp",
"uuid", "uuid",
"workflow_id"}) "workflow_id"})
public void republishItem() { public void republishItem() {
final Optional<ContentItem> item = itemRepo.findById(-10200L); final Optional<ContentItem> item = itemRepo.findById(-10200L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
item.get().getName().addValue(Locale.ENGLISH, "article2-edited"); item.get().getName().addValue(Locale.ENGLISH, "article2-edited");
item.get().getTitle() item.get().getTitle()
.addValue(Locale.ENGLISH, "Article has been edited"); .addValue(Locale.ENGLISH, "Article has been edited");
itemRepo.save(item.get()); itemRepo.save(item.get());
final Optional<ContentItem> draft = itemRepo.findById(-10200L); final Optional<ContentItem> draft = itemRepo.findById(-10200L);
@ -838,9 +901,9 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(5400) @InSequence(5400)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void publishItemNull() { public void publishItemNull() {
final ContentItem item = null; final ContentItem item = null;
@ -857,11 +920,11 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(5500) @InSequence(5500)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void publishItemLifecycleNull() { public void publishItemLifecycleIsNull() {
final Optional<ContentItem> draft = itemRepo.findById(-10200L); final Optional<ContentItem> draft = itemRepo.findById(-10200L);
itemManager.publish(draft.get(), null); itemManager.publish(draft.get(), null);
@ -874,22 +937,22 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(6000) @InSequence(6000)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/after-unpublish.xml", + "ContentItemManagerTest/after-unpublish.xml",
excludeColumns = {"categorization_id", excludeColumns = {"categorization_id",
"id", "id",
"lifecycle_id", "lifecycle_id",
"object_id", "object_id",
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"revend", "revend",
"task_id", "task_id",
"timestamp", "timestamp",
"uuid", "uuid",
"workflow_id"}) "workflow_id"})
public void unpublishItem() { public void unpublishItem() {
final Optional<ContentItem> item = itemRepo.findById(-10200L); final Optional<ContentItem> item = itemRepo.findById(-10200L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -905,9 +968,9 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(6100) @InSequence(6100)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
public void unpublishNonLiveItem() { public void unpublishNonLiveItem() {
final Optional<ContentItem> item = itemRepo.findById(-10300L); final Optional<ContentItem> item = itemRepo.findById(-10300L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -924,9 +987,9 @@ public class ContentItemManagerTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(6200) @InSequence(6200)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void unpublishItemNull() { public void unpublishItemNull() {
final ContentItem item = null; final ContentItem item = null;
@ -941,9 +1004,9 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(7000) @InSequence(7000)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
public void isLive() { public void isLive() {
final Optional<ContentItem> item1 = itemRepo.findById(-10100L); final Optional<ContentItem> item1 = itemRepo.findById(-10100L);
final Optional<ContentItem> item2 = itemRepo.findById(-10200L); final Optional<ContentItem> item2 = itemRepo.findById(-10200L);
@ -971,9 +1034,9 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(8000) @InSequence(8000)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
public void getLiveVersion() { public void getLiveVersion() {
final Optional<ContentItem> draft1 = itemRepo.findById(-10100L); final Optional<ContentItem> draft1 = itemRepo.findById(-10100L);
final Optional<ContentItem> draft2 = itemRepo.findById(-10200L); final Optional<ContentItem> draft2 = itemRepo.findById(-10200L);
@ -986,7 +1049,7 @@ public class ContentItemManagerTest {
ContentItem.class).isPresent(), ContentItem.class).isPresent(),
is(false)); is(false));
final Optional<Article> liveVersion = itemManager.getLiveVersion( final Optional<Article> liveVersion = itemManager.getLiveVersion(
draft2.get(), Article.class); draft2.get(), Article.class);
assertThat(liveVersion.isPresent(), assertThat(liveVersion.isPresent(),
is(true)); is(true));
assertThat(liveVersion.get().getObjectId(), assertThat(liveVersion.get().getObjectId(),
@ -1003,7 +1066,7 @@ public class ContentItemManagerTest {
is(false)); is(false));
final Optional<ContentItem> fromLive = itemManager.getLiveVersion( final Optional<ContentItem> fromLive = itemManager.getLiveVersion(
live2.get(), ContentItem.class); live2.get(), ContentItem.class);
assertThat(fromLive.isPresent(), assertThat(fromLive.isPresent(),
is(true)); is(true));
assertThat(fromLive.get().getObjectId(), assertThat(fromLive.get().getObjectId(),
@ -1022,9 +1085,9 @@ public class ContentItemManagerTest {
@Test @Test
@InSequence(8100) @InSequence(8100)
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
// getDraftVersion // getDraftVersion
public void getDraftVersion() { public void getDraftVersion() {
final Optional<ContentItem> draft1 = itemRepo.findById(-10100L); final Optional<ContentItem> draft1 = itemRepo.findById(-10100L);
@ -1048,7 +1111,7 @@ public class ContentItemManagerTest {
final Optional<ContentItem> live2 = itemRepo.findById(-99200L); final Optional<ContentItem> live2 = itemRepo.findById(-99200L);
final ContentItem draftVersion = itemManager.getDraftVersion( final ContentItem draftVersion = itemManager.getDraftVersion(
live2.get(), ContentItem.class); live2.get(), ContentItem.class);
assertThat(draftVersion, is(not(nullValue()))); assertThat(draftVersion, is(not(nullValue())));
assertThat(draftVersion.getObjectId(), is(-10200L)); assertThat(draftVersion.getObjectId(), is(-10200L));

View File

@ -58,8 +58,10 @@ public class DatasetsTest extends DatasetsVerifier {
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem-with-workflow.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem-with-workflow.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-move.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-move.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-move-to-other-section.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-other-folder.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-other-folder.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-same-folder.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-same-folder.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-folder-in-other-section.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-publish.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-publish.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-republish.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-republish.xml",
"/datasets/org/librecms/contentsection/ContentItemManagerTest/after-unpublish.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-unpublish.xml",

View File

@ -237,6 +237,10 @@
<ccm_core.resource_titles object_id="-1100" <ccm_core.resource_titles object_id="-1100"
locale="en" locale="en"
localized_value="info" /> localized_value="info" />
<ccm_core.resource_titles object_id="-1200"
locale="en"
localized_value="projects" />
<ccm_core.applications object_id="-1200" <ccm_core.applications object_id="-1200"
application_type="org.librecms.contentsection.ContentSection" application_type="org.librecms.contentsection.ContentSection"
primary_url="projects" /> primary_url="projects" />
@ -275,6 +279,10 @@
content_section_id="-1100" /> content_section_id="-1100" />
<ccm_cms.folder_content_section_map folder_id="-2200" <ccm_cms.folder_content_section_map folder_id="-2200"
content_section_id="-1100" /> content_section_id="-1100" />
<ccm_cms.folder_content_section_map folder_id="-2300"
content_section_id="-1200" />
<ccm_cms.folder_content_section_map folder_id="-2400"
content_section_id="-1200" />
<ccm_cms.content_section_workflow_templates <ccm_cms.content_section_workflow_templates
content_section_id="-1100" content_section_id="-1100"

View File

@ -237,6 +237,9 @@
<ccm_core.resource_titles object_id="-1100" <ccm_core.resource_titles object_id="-1100"
locale="en" locale="en"
localized_value="info" /> localized_value="info" />
<ccm_core.resource_titles object_id="-1200"
locale="en"
localized_value="projects" />
<ccm_core.applications object_id="-1100" <ccm_core.applications object_id="-1100"
application_type="org.librecms.contentsection.ContentSection" application_type="org.librecms.contentsection.ContentSection"