CCM NG/ccm-cms: Test pass again

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4530 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-01-21 12:02:43 +00:00
parent c899644e26
commit 08348b215e
14 changed files with 239 additions and 137 deletions

View File

@ -66,7 +66,7 @@ import static org.librecms.CmsConstants.*;
@Entity @Entity
@Audited @Audited
@Table(name = "CONTENT_ITEMS", schema = DB_SCHEMA) @Table(name = "CONTENT_ITEMS", schema = DB_SCHEMA)
@Indexed //@Indexed
@NamedQueries({ @NamedQueries({
@NamedQuery( @NamedQuery(
name = "ContentItem.findByType", name = "ContentItem.findByType",

View File

@ -18,7 +18,6 @@
*/ */
package org.librecms.contentsection; package org.librecms.contentsection;
import org.libreccm.categorization.Category;
import org.libreccm.security.Role; import org.libreccm.security.Role;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
@ -41,6 +40,7 @@ import java.util.ArrayList;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import org.libreccm.workflow.WorkflowTemplate; import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.lifecycle.LifecycleDefinition; import org.librecms.lifecycle.LifecycleDefinition;

View File

@ -542,13 +542,13 @@ public class ContentSectionManager {
section.addContentType(contentType); section.addContentType(contentType);
sectionRepo.save(section);
typeRepo.save(contentType);
section.getRoles().stream() section.getRoles().stream()
.forEach(role -> permissionManager.grantPrivilege( .forEach(role -> permissionManager.grantPrivilege(
TypePrivileges.USE_TYPE, role, contentType)); TypePrivileges.USE_TYPE, role, contentType));
sectionRepo.save(section);
typeRepo.save(contentType);
return contentType; return contentType;
} }

View File

@ -18,7 +18,6 @@
*/ */
package org.librecms.contentsection; package org.librecms.contentsection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -119,6 +118,7 @@ public class AssetManagerTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class)
.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())
@ -196,9 +196,11 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(100) @InSequence(100)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/AssetManagerTest/after-share.xml", value
= "datasets/org/librecms/contentsection/AssetManagerTest/after-share.xml",
excludeColumns = {"asset_id", excludeColumns = {"asset_id",
"categorization_id", "categorization_id",
"id", "id",
@ -232,8 +234,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(110) @InSequence(110)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void shareAssetNull() { public void shareAssetNull() {
final Folder folder = folderRepo.findById(-420L); final Folder folder = folderRepo.findById(-420L);
@ -252,8 +256,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(120) @InSequence(120)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void shareAssetFolderIsNull() throws MimeTypeParseException { public void shareAssetFolderIsNull() throws MimeTypeParseException {
final File file = new File(); final File file = new File();
@ -272,8 +278,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(130) @InSequence(130)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void shareAlreadySharedAsset() { public void shareAlreadySharedAsset() {
final Folder folder = folderRepo.findById(-420L); final Folder folder = folderRepo.findById(-420L);
@ -291,7 +299,8 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(300) @InSequence(300)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/AssetManagerTest/" value = "datasets/org/librecms/contentsection/AssetManagerTest/"
+ "after-clean-orphaned.xml", + "after-clean-orphaned.xml",
@ -307,7 +316,8 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(400) @InSequence(400)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/AssetManagerTest/" value = "datasets/org/librecms/contentsection/AssetManagerTest/"
+ "after-move-to-other-folder.xml", + "after-move-to-other-folder.xml",
@ -332,7 +342,8 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(410) @InSequence(410)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/AssetManagerTest/" value = "datasets/org/librecms/contentsection/AssetManagerTest/"
+ "after-move-to-other-contentsection.xml", + "after-move-to-other-contentsection.xml",
@ -358,8 +369,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(420) @InSequence(420)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveAssetNull() { public void moveAssetNull() {
final Asset asset = null; final Asset asset = null;
@ -378,8 +391,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(430) @InSequence(430)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveAssetTargetFolderIsNull() { public void moveAssetTargetFolderIsNull() {
final Asset asset = assetRepo.findById(-900L); final Asset asset = assetRepo.findById(-900L);
@ -398,8 +413,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(430) @InSequence(430)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveAssetTargetFolderIsNotAssetFolder() { public void moveAssetTargetFolderIsNotAssetFolder() {
final Asset asset = assetRepo.findById(-900L); final Asset asset = assetRepo.findById(-900L);
@ -417,7 +434,8 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(500) @InSequence(500)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/AssetManagerTest/" value = "datasets/org/librecms/contentsection/AssetManagerTest/"
+ "after-copy-to-other-folder.xml", + "after-copy-to-other-folder.xml",
@ -445,7 +463,8 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(510) @InSequence(510)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/AssetManagerTest/" value = "datasets/org/librecms/contentsection/AssetManagerTest/"
+ "after-copy-to-same-folder.xml", + "after-copy-to-same-folder.xml",
@ -475,7 +494,8 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(520) @InSequence(520)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/librecms/contentsection/AssetManagerTest/" value = "datasets/org/librecms/contentsection/AssetManagerTest/"
+ "after-copy-to-other-contentsection.xml", + "after-copy-to-other-contentsection.xml",
@ -505,8 +525,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(530) @InSequence(530)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyAssetNull() { public void copyAssetNull() {
final Asset asset = null; final Asset asset = null;
@ -525,8 +547,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(540) @InSequence(540)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyAssetTargetFolderIsNull() { public void copyAssetTargetFolderIsNull() {
final Asset asset = assetRepo.findById(-1100L); final Asset asset = assetRepo.findById(-1100L);
@ -545,8 +569,10 @@ public class AssetManagerTest {
*/ */
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@InSequence(550) @InSequence(550)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyAssetTargetFolderIsNotAssetFolder() { public void copyAssetTargetFolderIsNotAssetFolder() {
final Asset asset = assetRepo.findById(-1100L); final Asset asset = assetRepo.findById(-1100L);
@ -565,8 +591,10 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(600) @InSequence(600)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyIsAssetInUse() { public void verifyIsAssetInUse() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L);
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L);
@ -594,8 +622,10 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(700) @InSequence(700)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetPathWithoutContentSection() { public void verifyGetAssetPathWithoutContentSection() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L);
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L);
@ -628,8 +658,10 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(800) @InSequence(800)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetPathWithContentSection() { public void verifyGetAssetPathWithContentSection() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L);
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L);
@ -662,8 +694,10 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(900) @InSequence(900)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetFolder() { public void verifyGetAssetFolder() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L);
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L);
@ -715,8 +749,10 @@ public class AssetManagerTest {
*/ */
@Test @Test
@InSequence(1000) @InSequence(1000)
@UsingDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") @UsingDataSet(
@ShouldMatchDataSet("datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetFolders() { public void verifyGetAssetFolders() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L);
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L);

View File

@ -113,6 +113,7 @@ public class AssetRepositoryTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class)
.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())

View File

@ -109,6 +109,7 @@ public class AttachmentListManagerTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class)
.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())

View File

@ -39,6 +39,7 @@ 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.security.Shiro;
import org.libreccm.tests.categories.IntegrationTest; import org.libreccm.tests.categories.IntegrationTest;
import java.util.Locale; import java.util.Locale;
@ -70,6 +71,9 @@ public class ContentItemL10NManagerTest {
@Inject @Inject
private ContentItemL10NManager l10nManager; private ContentItemL10NManager l10nManager;
@Inject
private Shiro shiro;
public ContentItemL10NManagerTest() { public ContentItemL10NManagerTest() {
} }
@ -107,6 +111,7 @@ public class ContentItemL10NManagerTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class)
.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())
@ -171,15 +176,18 @@ public class ContentItemL10NManagerTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
public void verifyHasLanguage() { public void verifyHasLanguage() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); shiro.getSystemUser().execute(() -> {
assertThat(item.isPresent(), is(true)); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true));
assertThat(l10nManager.hasLanguage(item.get(), Locale.ENGLISH),
is(true));
assertThat(l10nManager.hasLanguage(item.get(), Locale.FRENCH),
is(true));
assertThat(l10nManager.hasLanguage(item.get(), Locale.GERMAN),
is(false));
});
assertThat(l10nManager.hasLanguage(item.get(), Locale.ENGLISH),
is(true));
assertThat(l10nManager.hasLanguage(item.get(), Locale.FRENCH),
is(true));
assertThat(l10nManager.hasLanguage(item.get(), Locale.GERMAN),
is(false));
} }
/** /**
@ -378,8 +386,8 @@ public class ContentItemL10NManagerTest {
} }
/** /**
* Tries to normalise the languages of a content item by using null null * Tries to normalise the languages of a content item by using
* null null null null null null null null null null null {@link ContentItemL10NManager#normalizedLanguages(org.librecms.contentsection.ContentItem) * {@link ContentItemL10NManager#normalizedLanguages(org.librecms.contentsection.ContentItem)}
*/ */
@Test @Test
@InSequence(120) @InSequence(120)

View File

@ -132,6 +132,7 @@ public class ContentItemManagerTest {
.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())
.addClass(org.libreccm.portation.Portable.class)
.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())
@ -229,28 +230,30 @@ public class ContentItemManagerTest {
"workflow_id" "workflow_id"
}) })
public void createContentItem() { public void createContentItem() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
final Folder folder = section.getRootDocumentsFolder(); final ContentSection section = sectionRepo.findByLabel("info");
final Folder folder = section.getRootDocumentsFolder();
final Article article = itemManager.createContentItem("new-article", final Article article = itemManager.createContentItem("new-article",
section, section,
folder, folder,
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")));
final Locale locale = new Locale("en"); final Locale locale = new Locale("en");
assertThat("Name has not the expected value.", assertThat("Name has not the expected value.",
article.getName().getValue(locale), article.getName().getValue(locale),
is(equalTo("new-article"))); is(equalTo("new-article")));
assertThat("workflow was not added to content item.", assertThat("workflow was not added to content item.",
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(4L)); workflowCount, is(4L));
});
} }
/** /**
@ -286,10 +289,12 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNull() { public void createItemNameIsNull() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
final Folder folder = section.getRootDocumentsFolder(); final ContentSection section = sectionRepo.findByLabel("info");
final Folder folder = section.getRootDocumentsFolder();
itemManager.createContentItem(null, section, folder, Article.class); itemManager.createContentItem(null, section, folder, Article.class);
});
} }
/** /**
@ -305,10 +310,12 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsEmpty() { public void createItemNameIsEmpty() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
final Folder folder = section.getRootDocumentsFolder(); final ContentSection section = sectionRepo.findByLabel("info");
final Folder folder = section.getRootDocumentsFolder();
itemManager.createContentItem(" ", section, folder, Article.class); itemManager.createContentItem(" ", section, folder, Article.class);
});
} }
/** /**
@ -325,9 +332,11 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemFolderIsNull() { public void createItemFolderIsNull() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo.findByLabel("info");
itemManager.createContentItem("Test", section, null, Article.class); itemManager.createContentItem("Test", section, null, Article.class);
});
} }
/** /**
@ -356,33 +365,35 @@ public class ContentItemManagerTest {
"workflow_id" "workflow_id"
}) })
public void createContentItemWithWorkflow() { public void createContentItemWithWorkflow() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
final Folder folder = section.getRootDocumentsFolder(); final ContentSection section = sectionRepo.findByLabel("info");
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")));
final Locale locale = new Locale("en"); final Locale locale = new Locale("en");
assertThat("Name has not the expected value.", assertThat("Name has not the expected value.",
article.getName().getValue(locale), article.getName().getValue(locale),
is(equalTo("new-article"))); is(equalTo("new-article")));
assertThat("workflow was not added to content item.", assertThat("workflow was not added to content item.",
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(4L)); workflowCount, is(4L));
});
} }
/** /**
@ -399,17 +410,19 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemTypeNotInSectionWithWorkflow() { public void createItemTypeNotInSectionWithWorkflow() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
final Folder folder = section.getRootDocumentsFolder(); final ContentSection section = sectionRepo.findByLabel("info");
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,
folder, folder,
workflowTemplate, workflowTemplate,
Event.class); Event.class);
});
} }
/** /**
@ -426,17 +439,19 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNullWithWorkflow() { public void createItemNameIsNullWithWorkflow() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
final Folder folder = section.getRootDocumentsFolder(); final ContentSection section = sectionRepo.findByLabel("info");
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,
folder, folder,
workflowTemplate, workflowTemplate,
Article.class); Article.class);
});
} }
/** /**
@ -453,14 +468,16 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNullWorkflowIsNull() { public void createItemNameIsNullWorkflowIsNull() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
final Folder folder = section.getRootDocumentsFolder(); final ContentSection section = sectionRepo.findByLabel("info");
final Folder folder = section.getRootDocumentsFolder();
itemManager.createContentItem(null, itemManager.createContentItem(null,
section, section,
folder, folder,
null, null,
Article.class); Article.class);
});
} }
/** /**
@ -477,16 +494,18 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemFolderIsNullWithWorkflow() { public void createItemFolderIsNullWithWorkflow() {
final ContentSection section = sectionRepo.findByLabel("info"); shiro.getSystemUser().execute(() -> {
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,
null, null,
workflowTemplate, workflowTemplate,
Article.class); Article.class);
});
} }
/** /**
@ -550,7 +569,7 @@ public class ContentItemManagerTest {
} }
/** /**
* Verifies that null {@link ContentItemManager#move(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder) * Verifies that null null null null null null null null null null null null {@link ContentItemManager#move(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder)
* throws an {@link IllegalArgumentException} if the type of the item to * throws an {@link IllegalArgumentException} if the type of the item to
* copy has not been registered in content section to which the target * copy has not been registered in content section to which the target
* folder belongs. * folder belongs.

View File

@ -107,6 +107,7 @@ public class ContentItemRepositoryTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class)
.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())

View File

@ -135,6 +135,7 @@ public class ContentSectionManagerTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.portation.Portable.class.getPackage())
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class. .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class.
getPackage()) getPackage())
.addPackage(org.libreccm.security.Permission.class.getPackage()) .addPackage(org.libreccm.security.Permission.class.getPackage())
@ -425,7 +426,9 @@ public class ContentSectionManagerTest {
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentSectionManagerTest/after-add-contenttype.xml", + "ContentSectionManagerTest/after-add-contenttype.xml",
excludeColumns = {"object_id", excludeColumns = {"object_id",
"uuid"}) "uuid",
"permission_id",
"creation_date"})
@InSequence(400) @InSequence(400)
public void addContentTypeToSection() { public void addContentTypeToSection() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L);

View File

@ -110,6 +110,7 @@ public class ContentTypeRepositoryTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class)
.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())

View File

@ -101,6 +101,7 @@ public class FolderManagerTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class. .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class.
getPackage()) getPackage())
.addClass(org.libreccm.portation.Portable.class)
.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())

View File

@ -116,6 +116,7 @@ public class ItemAttachmentManagerTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class .addPackage(org.libreccm.l10n.LocalizedString.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class)
.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())

View File

@ -529,5 +529,35 @@
object_id="-1100" object_id="-1100"
grantee_id="-3600" grantee_id="-3600"
creation_date="2016-07-15"/> creation_date="2016-07-15"/>
<ccm_core.permissions permission_id="-4710"
granted_privilege="use_type"
object_id="-10003"
grantee_id="-3100"
creation_date="2016-07-15" />
<ccm_core.permissions permission_id="-4720"
granted_privilege="use_type"
object_id="-10003"
grantee_id="-3200"
creation_date="2016-07-15" />
<ccm_core.permissions permission_id="-4730"
granted_privilege="use_type"
object_id="-10003"
grantee_id="-3300"
creation_date="2016-07-15" />
<ccm_core.permissions permission_id="-4740"
granted_privilege="use_type"
object_id="-10003"
grantee_id="-3400"
creation_date="2016-07-15" />
<ccm_core.permissions permission_id="-4750"
granted_privilege="use_type"
object_id="-10003"
grantee_id="-3500"
creation_date="2016-07-15" />
<ccm_core.permissions permission_id="-4760"
granted_privilege="use_type"
object_id="-10003"
grantee_id="-3600"
creation_date="2016-07-15" />
</dataset> </dataset>