CCM NG/ccm-cms: Fixed several test failures

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4870 8810af33-2d31-482b-a856-94f89814c4df

Former-commit-id: 3521d30ec1
pull/2/head
jensp 2017-07-14 14:59:16 +00:00
parent 28beeb4213
commit 595c6ef7ed
7 changed files with 592 additions and 405 deletions

View File

@ -1278,6 +1278,7 @@ public class ContentItemManager {
.createNamedQuery( .createNamedQuery(
"ContentItem.findLiveVersion", ContentItem.class); "ContentItem.findLiveVersion", ContentItem.class);
query.setParameter("uuid", item.getItemUuid()); query.setParameter("uuid", item.getItemUuid());
contentItemRepo.setAuthorizationParameters(query);
final ContentItem result = query.getSingleResult(); final ContentItem result = query.getSingleResult();
if (type.isAssignableFrom(result.getClass())) { if (type.isAssignableFrom(result.getClass())) {

View File

@ -465,11 +465,14 @@ public class AssetManagerTest {
"categorization_id", "categorization_id",
"object_order"}) "object_order"})
public void copyAssetToSameFolder() { public void copyAssetToSameFolder() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get(); final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = folderRepo.findById(-420L).get(); final Folder targetFolder = folderRepo.findById(-420L).get();
assetManager.copy(asset, targetFolder); assetManager.copy(asset, targetFolder);
});
} }
/** /**

View File

@ -101,8 +101,8 @@ public class ContentItemL10NManagerTest {
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())
@ -130,14 +130,14 @@ public class ContentItemL10NManagerTest {
com.arsdigita.cms.dispatcher.ContentItemDispatcher.class). com.arsdigita.cms.dispatcher.ContentItemDispatcher.class).
addClass(com.arsdigita.dispatcher.Dispatcher.class) addClass(com.arsdigita.dispatcher.Dispatcher.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(org.librecms.dispatcher.ItemResolver.class) .addClass(org.librecms.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())
@ -224,11 +224,14 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void hasLanguageLanguageIsNull() { public void hasLanguageLanguageIsNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
assertThat(l10nManager.hasLanguage(item.get(), null), assertThat(l10nManager.hasLanguage(item.get(), null),
is(true)); is(true));
});
} }
@ -245,10 +248,13 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/after-add-language.xml", + "ContentItemL10NManagerTest/after-add-language.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void addLanguage() { public void addLanguage() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
l10nManager.addLanguage(item.get(), Locale.GERMAN); l10nManager.addLanguage(item.get(), Locale.GERMAN);
});
} }
/** /**
@ -264,10 +270,13 @@ public class ContentItemL10NManagerTest {
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
public void addLanguageAlreadyPresent() { public void addLanguageAlreadyPresent() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
l10nManager.addLanguage(item.get(), Locale.FRENCH); l10nManager.addLanguage(item.get(), Locale.FRENCH);
});
} }
@ -285,9 +294,12 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void addLanguageItemIsNull() { public void addLanguageItemIsNull() {
shiro.getSystemUser().execute(() -> {
final ContentItem item = null; final ContentItem item = null;
l10nManager.addLanguage(item, Locale.GERMAN); l10nManager.addLanguage(item, Locale.GERMAN);
});
} }
/** /**
@ -304,10 +316,13 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void addLanguageLanguageIsNull() { public void addLanguageLanguageIsNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
l10nManager.addLanguage(item.get(), null); l10nManager.addLanguage(item.get(), null);
});
} }
/** /**
@ -323,10 +338,13 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/after-remove-language.xml", + "ContentItemL10NManagerTest/after-remove-language.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void removeLanguage() { public void removeLanguage() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
l10nManager.removeLanguage(item.get(), Locale.FRENCH); l10nManager.removeLanguage(item.get(), Locale.FRENCH);
});
} }
/** /**
@ -342,10 +360,13 @@ public class ContentItemL10NManagerTest {
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
public void removeNotPresentLanguage() { public void removeNotPresentLanguage() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
l10nManager.removeLanguage(item.get(), Locale.GERMAN); l10nManager.removeLanguage(item.get(), Locale.GERMAN);
});
} }
/** /**
@ -363,9 +384,12 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void removeLanguageItemIsNull() { public void removeLanguageItemIsNull() {
shiro.getSystemUser().execute(() -> {
final ContentItem item = null; final ContentItem item = null;
l10nManager.removeLanguage(item, Locale.GERMAN); l10nManager.removeLanguage(item, Locale.GERMAN);
});
} }
/** /**
@ -383,10 +407,13 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void removeLanguageLanguageIsNull() { public void removeLanguageLanguageIsNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
l10nManager.removeLanguage(item.get(), null); l10nManager.removeLanguage(item.get(), null);
});
} }
@ -403,10 +430,13 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/after-normalize.xml", + "ContentItemL10NManagerTest/after-normalize.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void normalizeItem() { public void normalizeItem() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10200L); final Optional<ContentItem> item = itemRepo.findById(-10200L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
l10nManager.normalizeLanguages(item.get()); l10nManager.normalizeLanguages(item.get());
});
} }
/** /**
@ -422,10 +452,13 @@ public class ContentItemL10NManagerTest {
value = "datasets/org/librecms/contentsection/" value = "datasets/org/librecms/contentsection/"
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
public void normalizeItemAlreadyNormalized() { public void normalizeItemAlreadyNormalized() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
l10nManager.normalizeLanguages(item.get()); l10nManager.normalizeLanguages(item.get());
});
} }
@ -444,9 +477,12 @@ public class ContentItemL10NManagerTest {
+ "ContentItemL10NManagerTest/data.xml") + "ContentItemL10NManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void normalizeItemNull() { public void normalizeItemNull() {
shiro.getSystemUser().execute(() -> {
final ContentItem item = null; final ContentItem item = null;
l10nManager.normalizeLanguages(item); l10nManager.normalizeLanguages(item);
});
} }
} }

View File

@ -228,6 +228,7 @@ public class ContentItemManagerTest {
"object_order", "object_order",
"phase_id", "phase_id",
"rev", "rev",
"task_assignment_id",
"task_id", "task_id",
"uuid", "uuid",
"timestamp", "timestamp",
@ -259,7 +260,7 @@ public class ContentItemManagerTest {
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 four workflows in database.",
workflowCount, is(4L)); workflowCount, is(4L));
}); });
} }
@ -278,6 +279,8 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemTypeNotInSection() { public void createItemTypeNotInSection() {
shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo final ContentSection section = sectionRepo
.findByLabel("info") .findByLabel("info")
.get(); .get();
@ -288,6 +291,7 @@ public class ContentItemManagerTest {
folder, folder,
Event.class, Event.class,
Locale.ENGLISH); Locale.ENGLISH);
});
} }
/** /**
@ -303,6 +307,7 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNull() { public void createItemNameIsNull() {
shiro.getSystemUser().execute(() -> { shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo final ContentSection section = sectionRepo
.findByLabel("info") .findByLabel("info")
@ -330,6 +335,7 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsEmpty() { public void createItemNameIsEmpty() {
shiro.getSystemUser().execute(() -> { shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo final ContentSection section = sectionRepo
.findByLabel("info") .findByLabel("info")
@ -358,6 +364,7 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(NullPointerException.class) @ShouldThrowException(NullPointerException.class)
public void createItemFolderIsNull() { public void createItemFolderIsNull() {
shiro.getSystemUser().execute(() -> { shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo final ContentSection section = sectionRepo
.findByLabel("info") .findByLabel("info")
@ -392,11 +399,13 @@ public class ContentItemManagerTest {
"phase_id", "phase_id",
"rev", "rev",
"task_id", "task_id",
"task_assignment_id",
"timestamp", "timestamp",
"uuid", "uuid",
"workflow_id" "workflow_id"
}) })
public void createContentItemWithWorkflow() { public void createContentItemWithWorkflow() {
shiro.getSystemUser().execute(() -> { shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo final ContentSection section = sectionRepo
.findByLabel("info") .findByLabel("info")
@ -477,6 +486,7 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNullWithWorkflow() { public void createItemNameIsNullWithWorkflow() {
shiro.getSystemUser().execute(() -> { shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo final ContentSection section = sectionRepo
.findByLabel("info") .findByLabel("info")
@ -509,6 +519,7 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void createItemNameIsNullWorkflowIsNull() { public void createItemNameIsNullWorkflowIsNull() {
shiro.getSystemUser().execute(() -> { shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo final ContentSection section = sectionRepo
.findByLabel("info") .findByLabel("info")
@ -538,6 +549,7 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(NullPointerException.class) @ShouldThrowException(NullPointerException.class)
public void createItemFolderIsNullWithWorkflow() { public void createItemFolderIsNullWithWorkflow() {
shiro.getSystemUser().execute(() -> { shiro.getSystemUser().execute(() -> {
final ContentSection section = sectionRepo final ContentSection section = sectionRepo
.findByLabel("info") .findByLabel("info")
@ -577,6 +589,7 @@ public class ContentItemManagerTest {
}) })
public void moveItem() { public void moveItem() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -584,6 +597,7 @@ public class ContentItemManagerTest {
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.move(item.get(), targetFolder); itemManager.move(item.get(), targetFolder);
});
} }
/** /**
@ -607,6 +621,8 @@ public class ContentItemManagerTest {
"workflow_id" "workflow_id"
}) })
public void moveItemToOtherContentSection() { public void moveItemToOtherContentSection() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
final Folder targetFolder = folderRepo.findById(-2300L).get(); final Folder targetFolder = folderRepo.findById(-2300L).get();
@ -614,11 +630,12 @@ public class ContentItemManagerTest {
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.move(item.get(), targetFolder); itemManager.move(item.get(), targetFolder);
});
} }
/** /**
* Verifies that null null null null null null null null null null null null * Verifies that
* null null null null null null null null null null {@link ContentItemManager#move(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder) * {@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.
@ -631,6 +648,8 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveToOtherContentSectionTypeNotPresent() { public void moveToOtherContentSectionTypeNotPresent() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10400L); final Optional<ContentItem> item = itemRepo.findById(-10400L);
final Folder targetFolder = folderRepo.findById(-2300L).get(); final Folder targetFolder = folderRepo.findById(-2300L).get();
@ -638,6 +657,7 @@ public class ContentItemManagerTest {
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.move(item.get(), targetFolder); itemManager.move(item.get(), targetFolder);
});
} }
/** /**
@ -654,10 +674,13 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveItemNull() { public void moveItemNull() {
shiro.getSystemUser().execute(() -> {
final Folder targetFolder = folderRepo.findById(-2120L).get(); final Folder targetFolder = folderRepo.findById(-2120L).get();
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.move(null, targetFolder); itemManager.move(null, targetFolder);
});
} }
/** /**
@ -674,10 +697,13 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveItemTargetFolderIsNull() { public void moveItemTargetFolderIsNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
itemManager.move(item.get(), null); itemManager.move(item.get(), null);
});
} }
/** /**
@ -709,6 +735,8 @@ public class ContentItemManagerTest {
"workflow_id" "workflow_id"
}) })
public void copyToOtherFolder() { public void copyToOtherFolder() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -716,6 +744,7 @@ public class ContentItemManagerTest {
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.copy(item.get(), targetFolder); itemManager.copy(item.get(), targetFolder);
});
} }
/** /**
@ -747,16 +776,21 @@ public class ContentItemManagerTest {
"workflow_id" "workflow_id"
}) })
public void copyToFolderInOtherSection() { public void copyToFolderInOtherSection() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> source = itemRepo.findById(-10100L); final Optional<ContentItem> source = itemRepo.findById(-10100L);
final Folder targetFolder = folderRepo.findById(-2300L).get(); final Folder targetFolder = folderRepo.findById(-2300L).get();
assertThat(source.isPresent(), is(true)); assertThat(source.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
final ContentItem target = itemManager.copy(source.get(), targetFolder); final ContentItem target = itemManager.copy(source.get(),
targetFolder);
assertThat(target.getUuid(), is(not(equalTo(source.get().getUuid())))); assertThat(target.getUuid(),
is(not(equalTo(source.get().getUuid()))));
assertThat(target.getItemUuid(), is(equalTo(target.getUuid()))); assertThat(target.getItemUuid(), is(equalTo(target.getUuid())));
});
} }
/** /**
@ -774,6 +808,8 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyToFolderInOtherSectionTypeNotPresent() { public void copyToFolderInOtherSectionTypeNotPresent() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> source = itemRepo.findById(-10400L); final Optional<ContentItem> source = itemRepo.findById(-10400L);
final Folder targetFolder = folderRepo.findById(-2300L).get(); final Folder targetFolder = folderRepo.findById(-2300L).get();
@ -781,6 +817,7 @@ public class ContentItemManagerTest {
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.copy(source.get(), targetFolder); itemManager.copy(source.get(), targetFolder);
});
} }
/** /**
@ -814,6 +851,8 @@ public class ContentItemManagerTest {
"workflow_id" "workflow_id"
}) })
public void copyToSameFolder() { public void copyToSameFolder() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -821,6 +860,7 @@ public class ContentItemManagerTest {
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.copy(item.get(), targetFolder); itemManager.copy(item.get(), targetFolder);
});
} }
/** /**
@ -838,10 +878,13 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyItemNull() { public void copyItemNull() {
shiro.getSystemUser().execute(() -> {
final Folder targetFolder = folderRepo.findById(-2120L).get(); final Folder targetFolder = folderRepo.findById(-2120L).get();
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.copy(null, targetFolder); itemManager.copy(null, targetFolder);
});
} }
/** /**
@ -859,10 +902,13 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyItemToFolderNull() { public void copyItemToFolderNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
itemManager.copy(item.get(), null); itemManager.copy(item.get(), null);
});
} }
/** /**
@ -897,12 +943,15 @@ public class ContentItemManagerTest {
"workflow_id" "workflow_id"
}) })
public void publishItem() { public void publishItem() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final ContentItem live = itemManager.publish(item.get()); final ContentItem live = itemManager.publish(item.get());
assertThat(live, is(not(nullValue()))); assertThat(live, is(not(nullValue())));
assertThat(live.getVersion(), is(ContentItemVersion.LIVE)); assertThat(live.getVersion(), is(ContentItemVersion.LIVE));
});
} }
/** /**
@ -937,15 +986,19 @@ public class ContentItemManagerTest {
"workflow_id" "workflow_id"
}) })
public void publishItemWithLifecycle() { public void publishItemWithLifecycle() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
final LifecycleDefinition lifecycleDef = lifecycleDefinitionRepo final LifecycleDefinition lifecycleDef = lifecycleDefinitionRepo
.findById(-200L).get(); .findById(-200L).get();
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
assertThat(lifecycleDef, is(not(nullValue()))); assertThat(lifecycleDef, is(not(nullValue())));
final ContentItem live = itemManager.publish(item.get(), lifecycleDef); final ContentItem live = itemManager.publish(item.get(),
lifecycleDef);
assertThat(live, is(not(nullValue()))); assertThat(live, is(not(nullValue())));
assertThat(live.getVersion(), is(ContentItemVersion.LIVE)); assertThat(live.getVersion(), is(ContentItemVersion.LIVE));
});
} }
/** /**
@ -971,6 +1024,8 @@ public class ContentItemManagerTest {
"uuid", "uuid",
"workflow_id"}) "workflow_id"})
public void republishItem() { public void republishItem() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10200L); final Optional<ContentItem> item = itemRepo.findById(-10200L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -983,6 +1038,7 @@ public class ContentItemManagerTest {
assertThat(draft.get().getName().getValue(Locale.ENGLISH), assertThat(draft.get().getName().getValue(Locale.ENGLISH),
is(equalTo("article2-edited"))); is(equalTo("article2-edited")));
itemManager.publish(draft.get()); itemManager.publish(draft.get());
});
} }
/** /**
@ -999,9 +1055,12 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void publishItemNull() { public void publishItemNull() {
shiro.getSystemUser().execute(() -> {
final ContentItem item = null; final ContentItem item = null;
itemManager.publish(item); itemManager.publish(item);
});
} }
/** /**
@ -1018,9 +1077,12 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void publishItemLifecycleIsNull() { public void publishItemLifecycleIsNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> draft = itemRepo.findById(-10200L); final Optional<ContentItem> draft = itemRepo.findById(-10200L);
itemManager.publish(draft.get(), null); itemManager.publish(draft.get(), null);
});
} }
/** /**
@ -1047,10 +1109,13 @@ public class ContentItemManagerTest {
"uuid", "uuid",
"workflow_id"}) "workflow_id"})
public void unpublishItem() { public void unpublishItem() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10200L); final Optional<ContentItem> item = itemRepo.findById(-10200L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
itemManager.unpublish(item.get()); itemManager.unpublish(item.get());
});
} }
/** /**
@ -1065,10 +1130,13 @@ public class ContentItemManagerTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
public void unpublishNonLiveItem() { public void unpublishNonLiveItem() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-10300L); final Optional<ContentItem> item = itemRepo.findById(-10300L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
itemManager.unpublish(item.get()); itemManager.unpublish(item.get());
});
} }
/** /**
@ -1085,8 +1153,11 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void unpublishItemNull() { public void unpublishItemNull() {
shiro.getSystemUser().execute(() -> {
final ContentItem item = null; final ContentItem item = null;
itemManager.unpublish(item); itemManager.unpublish(item);
});
} }
/** /**
@ -1101,6 +1172,8 @@ public class ContentItemManagerTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
public void isLive() { public void isLive() {
shiro.getSystemUser().execute(() -> {
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);
final Optional<ContentItem> item3 = itemRepo.findById(-10300L); final Optional<ContentItem> item3 = itemRepo.findById(-10300L);
@ -1115,6 +1188,7 @@ public class ContentItemManagerTest {
assertThat(itemManager.isLive(item2.get()), is(true)); assertThat(itemManager.isLive(item2.get()), is(true));
assertThat(itemManager.isLive(item3.get()), is(false)); assertThat(itemManager.isLive(item3.get()), is(false));
assertThat(itemManager.isLive(item4.get()), is(false)); assertThat(itemManager.isLive(item4.get()), is(false));
});
} }
/** /**
@ -1131,6 +1205,8 @@ public class ContentItemManagerTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
public void getLiveVersion() { public void getLiveVersion() {
shiro.getSystemUser().execute(() -> {
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);
final Optional<ContentItem> draft3 = itemRepo.findById(-10300L); final Optional<ContentItem> draft3 = itemRepo.findById(-10300L);
@ -1168,6 +1244,7 @@ public class ContentItemManagerTest {
is(equalTo("acae860f-2ffa-450d-b486-054292f0dae6"))); is(equalTo("acae860f-2ffa-450d-b486-054292f0dae6")));
assertThat(fromLive.get().getVersion(), assertThat(fromLive.get().getVersion(),
is(ContentItemVersion.LIVE)); is(ContentItemVersion.LIVE));
});
} }
/** /**
@ -1183,22 +1260,28 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
// getDraftVersion // getDraftVersion
public void getDraftVersion() { public void getDraftVersion() {
shiro.getSystemUser().execute(() -> {
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);
final Optional<ContentItem> draft3 = itemRepo.findById(-10300L); final Optional<ContentItem> draft3 = itemRepo.findById(-10300L);
final Optional<ContentItem> draft4 = itemRepo.findById(-10400L); final Optional<ContentItem> draft4 = itemRepo.findById(-10400L);
assertThat(itemManager.getDraftVersion(draft1.get(), assertThat(itemManager.getDraftVersion(draft1.get(),
ContentItem.class).getObjectId(), ContentItem.class)
.getObjectId(),
is(-10100L)); is(-10100L));
assertThat(itemManager.getDraftVersion(draft2.get(), assertThat(itemManager.getDraftVersion(draft2.get(),
ContentItem.class).getObjectId(), ContentItem.class)
.getObjectId(),
is(-10200L)); is(-10200L));
assertThat(itemManager.getDraftVersion(draft3.get(), assertThat(itemManager.getDraftVersion(draft3.get(),
ContentItem.class).getObjectId(), ContentItem.class)
.getObjectId(),
is(-10300L)); is(-10300L));
assertThat(itemManager.getDraftVersion(draft4.get(), assertThat(itemManager.getDraftVersion(draft4.get(),
ContentItem.class).getObjectId(), ContentItem.class)
.getObjectId(),
is(-10400L)); is(-10400L));
final Optional<ContentItem> live2 = itemRepo.findById(-99200L); final Optional<ContentItem> live2 = itemRepo.findById(-99200L);
@ -1212,7 +1295,7 @@ public class ContentItemManagerTest {
is(equalTo("acae860f-2ffa-450d-b486-054292f0dae6"))); is(equalTo("acae860f-2ffa-450d-b486-054292f0dae6")));
assertThat(draftVersion.getVersion(), assertThat(draftVersion.getVersion(),
is(ContentItemVersion.DRAFT)); is(ContentItemVersion.DRAFT));
});
} }
} }

View File

@ -206,12 +206,16 @@ public class ItemAttachmentManagerTest {
"uuid", "uuid",
"attachment_id"}) "attachment_id"})
public void attachNonSharedAsset() throws MimeTypeParseException { public void attachNonSharedAsset() throws MimeTypeParseException {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final Asset file = assetRepo.findById(-720L).get(); final Asset file = assetRepo.findById(-720L).get();
attachmentManager.attachAsset(file, item.get().getAttachments().get(1)); attachmentManager.attachAsset(file, item.get().getAttachments().get(
1));
});
} }
/** /**
@ -231,6 +235,8 @@ public class ItemAttachmentManagerTest {
"uuid", "uuid",
"attachment_id"}) "attachment_id"})
public void attachSharedAsset() throws MimeTypeParseException { public void attachSharedAsset() throws MimeTypeParseException {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -238,6 +244,7 @@ public class ItemAttachmentManagerTest {
attachmentManager.attachAsset(shared, attachmentManager.attachAsset(shared,
item.get().getAttachments().get(1)); item.get().getAttachments().get(1));
});
} }
/** /**
@ -253,6 +260,8 @@ public class ItemAttachmentManagerTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
public void attachAssetAlreadyAttached() { public void attachAssetAlreadyAttached() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -260,6 +269,7 @@ public class ItemAttachmentManagerTest {
attachmentManager.attachAsset(shared, attachmentManager.attachAsset(shared,
item.get().getAttachments().get(1)); item.get().getAttachments().get(1));
});
} }
/** /**
@ -276,6 +286,8 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void attachAssetNull() { public void attachAssetNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -283,6 +295,7 @@ public class ItemAttachmentManagerTest {
attachmentManager.attachAsset(asset, attachmentManager.attachAsset(asset,
item.get().getAttachments().get(1)); item.get().getAttachments().get(1));
});
} }
/** /**
@ -299,10 +312,13 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void attachAssetToListNull() { public void attachAssetToListNull() {
shiro.getSystemUser().execute(() -> {
final AttachmentList list = null; final AttachmentList list = null;
final Asset shared = assetRepo.findById(-610L).get(); final Asset shared = assetRepo.findById(-610L).get();
attachmentManager.attachAsset(shared, list); attachmentManager.attachAsset(shared, list);
});
} }
/** /**
@ -319,6 +335,8 @@ public class ItemAttachmentManagerTest {
+ "after-unattach-shared.xml", + "after-unattach-shared.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void unattachSharedAsset() { public void unattachSharedAsset() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-610L).get(); final Asset asset = assetRepo.findById(-610L).get();
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
@ -328,6 +346,7 @@ public class ItemAttachmentManagerTest {
final AttachmentList list = item.get().getAttachments().get(0); final AttachmentList list = item.get().getAttachments().get(0);
attachmentManager.unattachAsset(asset, list); attachmentManager.unattachAsset(asset, list);
});
} }
/** /**
@ -346,6 +365,8 @@ public class ItemAttachmentManagerTest {
+ "after-unattach-nonshared.xml", + "after-unattach-nonshared.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void unattachNonSharedAsset() { public void unattachNonSharedAsset() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-720L).get(); final Asset asset = assetRepo.findById(-720L).get();
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
@ -355,6 +376,7 @@ public class ItemAttachmentManagerTest {
final AttachmentList list = item.get().getAttachments().get(0); final AttachmentList list = item.get().getAttachments().get(0);
attachmentManager.unattachAsset(asset, list); attachmentManager.unattachAsset(asset, list);
});
} }
/** /**
@ -370,6 +392,8 @@ public class ItemAttachmentManagerTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
public void unattachAssetNotAttached() { public void unattachAssetNotAttached() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-720L).get(); final Asset asset = assetRepo.findById(-720L).get();
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
@ -379,6 +403,7 @@ public class ItemAttachmentManagerTest {
final AttachmentList list = item.get().getAttachments().get(1); final AttachmentList list = item.get().getAttachments().get(1);
attachmentManager.unattachAsset(asset, list); attachmentManager.unattachAsset(asset, list);
});
} }
/** /**
@ -395,6 +420,8 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void unattachAssetNull() { public void unattachAssetNull() {
shiro.getSystemUser().execute(() -> {
final Asset asset = null; final Asset asset = null;
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
@ -403,6 +430,7 @@ public class ItemAttachmentManagerTest {
final AttachmentList list = item.get().getAttachments().get(0); final AttachmentList list = item.get().getAttachments().get(0);
attachmentManager.unattachAsset(asset, list); attachmentManager.unattachAsset(asset, list);
});
} }
/** /**
@ -419,12 +447,15 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void unattachAssetFromListNull() { public void unattachAssetFromListNull() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-720L).get(); final Asset asset = assetRepo.findById(-720L).get();
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
final AttachmentList list = null; final AttachmentList list = null;
attachmentManager.unattachAsset(asset, list); attachmentManager.unattachAsset(asset, list);
});
} }
/** /**
@ -441,6 +472,8 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/after-move-up.xml", + "ItemAttachmentManagerTest/after-move-up.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void moveUp() { public void moveUp() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -448,6 +481,7 @@ public class ItemAttachmentManagerTest {
attachmentManager.moveUp(list.getAttachments().get(0).getAsset(), attachmentManager.moveUp(list.getAttachments().get(0).getAsset(),
list); list);
});
} }
/** /**
@ -462,6 +496,8 @@ public class ItemAttachmentManagerTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
public void moveUpLast() { public void moveUpLast() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -469,6 +505,7 @@ public class ItemAttachmentManagerTest {
attachmentManager.moveUp(list.getAttachments().get(2).getAsset(), attachmentManager.moveUp(list.getAttachments().get(2).getAsset(),
list); list);
});
} }
/** /**
@ -485,12 +522,15 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveUpNull() { public void moveUpNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final AttachmentList list = item.get().getAttachments().get(0); final AttachmentList list = item.get().getAttachments().get(0);
attachmentManager.moveUp(null, list); attachmentManager.moveUp(null, list);
});
} }
/** /**
@ -507,12 +547,15 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveUpInListNull() { public void moveUpInListNull() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-720L).get(); final Asset asset = assetRepo.findById(-720L).get();
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
final AttachmentList list = null; final AttachmentList list = null;
attachmentManager.moveUp(asset, list); attachmentManager.moveUp(asset, list);
});
} }
/** /**
@ -529,6 +572,8 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/after-move-down.xml", + "ItemAttachmentManagerTest/after-move-down.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void moveDown() { public void moveDown() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -536,6 +581,7 @@ public class ItemAttachmentManagerTest {
attachmentManager.moveDown(list.getAttachments().get(2).getAsset(), attachmentManager.moveDown(list.getAttachments().get(2).getAsset(),
list); list);
});
} }
/** /**
@ -550,6 +596,8 @@ public class ItemAttachmentManagerTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
public void moveDownFirst() { public void moveDownFirst() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
@ -557,6 +605,7 @@ public class ItemAttachmentManagerTest {
attachmentManager.moveDown(list.getAttachments().get(0).getAsset(), attachmentManager.moveDown(list.getAttachments().get(0).getAsset(),
list); list);
});
} }
/** /**
@ -573,12 +622,15 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveDownNull() { public void moveDownNull() {
shiro.getSystemUser().execute(() -> {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final AttachmentList list = item.get().getAttachments().get(0); final AttachmentList list = item.get().getAttachments().get(0);
attachmentManager.moveDown(null, list); attachmentManager.moveDown(null, list);
});
} }
/** /**
@ -595,12 +647,15 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveDownInListNull() { public void moveDownInListNull() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-720L).get(); final Asset asset = assetRepo.findById(-720L).get();
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
final AttachmentList list = null; final AttachmentList list = null;
attachmentManager.moveDown(asset, list); attachmentManager.moveDown(asset, list);
});
} }
} }

View File

@ -12,7 +12,7 @@
active="false" /> active="false" />
<ccm_core.workflows workflow_id="-140" <ccm_core.workflows workflow_id="-140"
uuid="c6e317a1-88d5-48ab-8896-304d4c8d1f3e" uuid="c6e317a1-88d5-48ab-8896-304d4c8d1f3e"
active="false" /> active="true" />
<ccm_core.workflow_names workflow_id="-100" <ccm_core.workflow_names workflow_id="-100"
locale="en" locale="en"
@ -48,7 +48,7 @@
workflow_id="-110" /> workflow_id="-110" />
<ccm_core.workflow_tasks task_id="-140100" <ccm_core.workflow_tasks task_id="-140100"
uuid="438a742b-dc1f-42f4-8fb8-061fbed5b26b" uuid="438a742b-dc1f-42f4-8fb8-061fbed5b26b"
active="false" active="true"
workflow_id="-140" /> workflow_id="-140" />
<ccm_core.workflow_task_labels task_id="-100100" <ccm_core.workflow_task_labels task_id="-100100"
@ -728,6 +728,9 @@
<ccm_core.workflow_task_assignments task_assignment_id="-930" <ccm_core.workflow_task_assignments task_assignment_id="-930"
task_id="-110100" task_id="-110100"
role_id="-3200" /> role_id="-3200" />
<ccm_core.workflow_task_assignments task_assignment_id="-930930"
task_id="-140100"
role_id="-3200" />
<ccm_cms.content_section_roles role_id="-3100" <ccm_cms.content_section_roles role_id="-3100"
section_id="-1100" /> section_id="-1100" />

View File

@ -12,7 +12,7 @@
active="false" /> active="false" />
<ccm_core.workflows workflow_id="-140" <ccm_core.workflows workflow_id="-140"
uuid="c6e317a1-88d5-48ab-8896-304d4c8d1f3e" uuid="c6e317a1-88d5-48ab-8896-304d4c8d1f3e"
active="false" /> active="true" />
<ccm_core.workflow_names workflow_id="-100" <ccm_core.workflow_names workflow_id="-100"
locale="en" locale="en"
@ -34,7 +34,6 @@
<ccm_core.workflow_tasks task_id="-100100" <ccm_core.workflow_tasks task_id="-100100"
uuid="43db829c-7749-4ca9-8aba-241a9c2d00b3" uuid="43db829c-7749-4ca9-8aba-241a9c2d00b3"
active="false" active="false"
task_state="ENABLED"
workflow_id="-100" /> workflow_id="-100" />
<ccm_core.workflow_tasks task_id="-100200" <ccm_core.workflow_tasks task_id="-100200"
uuid="9d6112af-abde-42d6-9c9b-06bb0b245158" uuid="9d6112af-abde-42d6-9c9b-06bb0b245158"
@ -49,10 +48,11 @@
<ccm_core.workflow_tasks task_id="-140100" <ccm_core.workflow_tasks task_id="-140100"
uuid="75b64386-1df2-494a-bab8-2bab81f0ed45" uuid="75b64386-1df2-494a-bab8-2bab81f0ed45"
active="false" active="false"
task_state="ENABLED"
workflow_id="-140" /> workflow_id="-140" />
<ccm_core.workflow_tasks task_id="-140200" <ccm_core.workflow_tasks task_id="-140200"
uuid="0a68c843-71e3-4e97-9a77-9427f6220cb1" uuid="0a68c843-71e3-4e97-9a77-9427f6220cb1"
active="false" active="true"
workflow_id="-140" /> workflow_id="-140" />
<ccm_core.workflow_task_labels task_id="-100100" <ccm_core.workflow_task_labels task_id="-100100"
@ -741,6 +741,12 @@
<ccm_core.workflow_task_assignments task_assignment_id="-930" <ccm_core.workflow_task_assignments task_assignment_id="-930"
task_id="-110100" task_id="-110100"
role_id="-3200" /> role_id="-3200" />
<ccm_core.workflow_task_assignments task_assignment_id="-910910"
task_id="-140100"
role_id="-3200" />
<ccm_core.workflow_task_assignments task_assignment_id="-920920"
task_id="-140200"
role_id="-3300" />
<ccm_cms.content_section_roles role_id="-3100" <ccm_cms.content_section_roles role_id="-3100"
section_id="-1100" /> section_id="-1100" />