CCM NG/ccm-cms: AttachmentListManager finished
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4427 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
0e8fe19efd
commit
4b9f65d40b
|
|
@ -302,7 +302,7 @@ public class AttachmentListManager {
|
|||
*
|
||||
* @param attachmentList The list to move.
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public void moveUp(
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
|
|
|
|||
|
|
@ -19,11 +19,15 @@
|
|||
package org.librecms.contentsection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.libreccm.security.RequiresPrivilege;
|
||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -51,15 +55,15 @@ public class ItemAttachmentManager {
|
|||
/**
|
||||
* Adds the provided {@link Asset} to the provided {@link AttachmentList}.
|
||||
*
|
||||
* @param asset The {@link Asset} to add.
|
||||
* @param asset The {@link Asset} to add.
|
||||
* @param attachmentList The attachment list to which the asset is added.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public void attachAsset(
|
||||
final Asset asset,
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
final AttachmentList attachmentList) {
|
||||
final Asset asset,
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
final AttachmentList attachmentList) {
|
||||
|
||||
if (asset == null) {
|
||||
throw new IllegalArgumentException("Can't attach asset null.");
|
||||
|
|
@ -67,7 +71,7 @@ public class ItemAttachmentManager {
|
|||
|
||||
if (attachmentList == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't attach an asset to attachment list null.");
|
||||
"Can't attach an asset to attachment list null.");
|
||||
}
|
||||
|
||||
// For shared assets (we assume that every asset already in the database
|
||||
|
|
@ -76,7 +80,7 @@ public class ItemAttachmentManager {
|
|||
saveNonSharedAsset(asset);
|
||||
} else {
|
||||
final TypedQuery<Long> countQuery = entityManager.createNamedQuery(
|
||||
"ItemAttachment.countByAssetIdAndList", Long.class);
|
||||
"ItemAttachment.countByAssetIdAndList", Long.class);
|
||||
countQuery.setParameter("asset", asset);
|
||||
countQuery.setParameter("attachmentList", attachmentList);
|
||||
|
||||
|
|
@ -111,14 +115,23 @@ public class ItemAttachmentManager {
|
|||
* {@link AttachmentList}. If the asset is a non shared asset the asset is
|
||||
* deleted.
|
||||
*
|
||||
* @param asset The {@link Asset} to remove.
|
||||
* @param asset The {@link Asset} to remove.
|
||||
* @param attachmentList The attachment list to which the asset is removed
|
||||
* from.
|
||||
* from.
|
||||
*/
|
||||
public void unattachAsset(final Asset asset,
|
||||
final AttachmentList attachmentList) {
|
||||
if (asset == null) {
|
||||
throw new IllegalArgumentException("Can't unattach null.");
|
||||
}
|
||||
|
||||
if (attachmentList == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't unattach an asset from list null.");
|
||||
}
|
||||
|
||||
final TypedQuery<Long> countQuery = entityManager.createNamedQuery(
|
||||
"ItemAttachment.countByAssetIdAndList", Long.class);
|
||||
"ItemAttachment.countByAssetIdAndList", Long.class);
|
||||
countQuery.setParameter("asset", asset);
|
||||
countQuery.setParameter("attachmentList", attachmentList);
|
||||
|
||||
|
|
@ -128,17 +141,18 @@ public class ItemAttachmentManager {
|
|||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
final TypedQuery<ItemAttachment> query = entityManager
|
||||
.createNamedQuery("ItemAttachment.findByAssetByAndList",
|
||||
ItemAttachment.class);
|
||||
.createNamedQuery("ItemAttachment.findByAssetByAndList",
|
||||
ItemAttachment.class);
|
||||
query.setParameter("asset", asset);
|
||||
query.setParameter("attachmentList", attachmentList);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
final List<ItemAttachment> attachments = query.getResultList();
|
||||
attachments.forEach((attachment) -> entityManager.remove(attachment));
|
||||
|
||||
if (!assetManager.isShared(asset)) {
|
||||
// assetRepo.delete(asset);
|
||||
entityManager.remove(asset);
|
||||
}
|
||||
}
|
||||
|
|
@ -147,28 +161,147 @@ public class ItemAttachmentManager {
|
|||
* Moves the {@link Asset} one position up in the provided
|
||||
* {@link AttachmentList}.
|
||||
*
|
||||
* @param asset The asset to move up. If the asset is not part of the
|
||||
* provided {@link AttachmentList} an {@link IllegalArgumentException} is
|
||||
* thrown.
|
||||
* @param asset The asset to move up. If the asset is not part of
|
||||
* the provided {@link AttachmentList} an
|
||||
* {@link IllegalArgumentException} is thrown.
|
||||
* @param attachmentList The attachment list in which the item is moved.
|
||||
*/
|
||||
public void moveUp(final Asset asset,
|
||||
final AttachmentList attachmentList) {
|
||||
throw new UnsupportedOperationException("Not implemented yet");
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public void moveUp(
|
||||
final Asset asset,
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
final AttachmentList attachmentList) {
|
||||
|
||||
if (asset == null) {
|
||||
throw new IllegalArgumentException("Can't move null.");
|
||||
}
|
||||
|
||||
if (attachmentList == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't move up an asset in list null.");
|
||||
}
|
||||
|
||||
final TypedQuery<Long> countQuery = entityManager.createNamedQuery(
|
||||
"ItemAttachment.countByAssetIdAndList", Long.class);
|
||||
countQuery.setParameter("asset", asset);
|
||||
countQuery.setParameter("attachmentList", attachmentList);
|
||||
final long count = countQuery.getSingleResult();
|
||||
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
final TypedQuery<ItemAttachment> query = entityManager.createNamedQuery(
|
||||
"ItemAttachment.findByAssetByAndList", ItemAttachment.class);
|
||||
query.setParameter("asset", asset);
|
||||
query.setParameter("attachmentList", attachmentList);
|
||||
final ItemAttachment<?> selected = query.getSingleResult();
|
||||
|
||||
final Optional<ItemAttachment<?>> attachment1 = attachmentList
|
||||
.getAttachments().stream()
|
||||
.filter(attachment -> {
|
||||
return attachment.getSortKey() == selected.getSortKey();
|
||||
})
|
||||
.findFirst();
|
||||
final Optional<ItemAttachment<?>> attachment2 = attachmentList
|
||||
.getAttachments().stream()
|
||||
.filter(attachment -> {
|
||||
return attachment.getSortKey() >= selected.getSortKey() + 1;
|
||||
})
|
||||
.findFirst();
|
||||
|
||||
if (!attachment2.isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final long sortKey1 = attachment1.get().getSortKey();
|
||||
final long sortKey2 = attachment2.get().getSortKey();
|
||||
|
||||
attachment1.get().setSortKey(sortKey2);
|
||||
attachment2.get().setSortKey(sortKey1);
|
||||
|
||||
entityManager.merge(attachment1.get());
|
||||
entityManager.merge(attachment2.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the {@link Asset} one position down in the provided
|
||||
* {@link AttachmentList}.
|
||||
*
|
||||
* @param asset The asset to move down. If the asset is not part of the
|
||||
* provided {@link AttachmentList} an {@link IllegalArgumentException} is
|
||||
* thrown.
|
||||
* @param asset The asset to move down. If the asset is not part of
|
||||
* the provided {@link AttachmentList} an
|
||||
* {@link IllegalArgumentException} is thrown.
|
||||
* @param attachmentList The attachment list in which the item is moved.
|
||||
*/
|
||||
public void moveDown(final Asset asset,
|
||||
final AttachmentList attachmentList) {
|
||||
throw new UnsupportedOperationException("Not implemented yet");
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public void moveDown(
|
||||
final Asset asset,
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
final AttachmentList attachmentList) {
|
||||
|
||||
if (asset == null) {
|
||||
throw new IllegalArgumentException("Can't move down null.");
|
||||
}
|
||||
|
||||
if (attachmentList == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't move down an asset in list null.");
|
||||
}
|
||||
|
||||
final TypedQuery<Long> countQuery = entityManager.createNamedQuery(
|
||||
"ItemAttachment.countByAssetIdAndList", Long.class);
|
||||
countQuery.setParameter("asset", asset);
|
||||
countQuery.setParameter("attachmentList", attachmentList);
|
||||
final long count = countQuery.getSingleResult();
|
||||
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
final TypedQuery<ItemAttachment> query = entityManager.createNamedQuery(
|
||||
"ItemAttachment.findByAssetByAndList", ItemAttachment.class);
|
||||
query.setParameter("asset", asset);
|
||||
query.setParameter("attachmentList", attachmentList);
|
||||
final ItemAttachment<?> selected = query.getSingleResult();
|
||||
|
||||
final Optional<ItemAttachment<?>> attachment1 = attachmentList
|
||||
.getAttachments().stream()
|
||||
.filter(attachment -> {
|
||||
return attachment.getSortKey() == selected.getSortKey();
|
||||
})
|
||||
.findFirst();
|
||||
final List<ItemAttachment<?>> lower = attachmentList
|
||||
.getAttachments().stream()
|
||||
.filter(attachment -> {
|
||||
return attachment.getSortKey() <= selected.getSortKey() - 1;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
Collections.sort(lower);
|
||||
|
||||
final Optional<ItemAttachment<?>> attachment2;
|
||||
if (lower.isEmpty()) {
|
||||
attachment2 = Optional.empty();
|
||||
} else {
|
||||
attachment2 = Optional.of(lower.get(lower.size() - 1));
|
||||
}
|
||||
|
||||
if (!attachment2.isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final long sortKey1 = attachment1.get().getSortKey();
|
||||
final long sortKey2 = attachment2.get().getSortKey();
|
||||
|
||||
attachment1.get().setSortKey(sortKey2);
|
||||
attachment2.get().setSortKey(sortKey1);
|
||||
|
||||
entityManager.merge(attachment1.get());
|
||||
entityManager.merge(attachment2.get());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,60 +105,60 @@ public class ItemAttachmentManagerTest {
|
|||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.librecms.assets.AssetManagerTest.war")
|
||||
.addPackage(org.libreccm.auditing.CcmRevision.class.getPackage()).
|
||||
addPackage(org.libreccm.categorization.Categorization.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
||||
.addPackage(org.libreccm.configuration.Configuration.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.core.CcmCore.class.getPackage())
|
||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||
.addPackage(com.arsdigita.bebop.Component.class.getPackage())
|
||||
.addPackage(com.arsdigita.bebop.util.BebopConstants.class
|
||||
.getPackage())
|
||||
.addClass(com.arsdigita.kernel.KernelConfig.class)
|
||||
.addClass(com.arsdigita.runtime.CCMResourceManager.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class).
|
||||
addClass(
|
||||
com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class).
|
||||
addClass(
|
||||
com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class).
|
||||
addClass(
|
||||
com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class).
|
||||
addClass(com.arsdigita.cms.dispatcher.ItemResolver.class)
|
||||
.addPackage(com.arsdigita.util.Lockable.class.getPackage())
|
||||
.addPackage(com.arsdigita.web.BaseServlet.class.getPackage())
|
||||
.addPackage(org.librecms.Cms.class.getPackage())
|
||||
.addPackage(org.librecms.assets.BinaryAsset.class.getPackage())
|
||||
.addPackage(org.librecms.contentsection.Asset.class.getPackage()).
|
||||
addPackage(org.librecms.lifecycle.Lifecycle.class.getPackage())
|
||||
.addPackage(org.librecms.contentsection.ContentSection.class
|
||||
.getPackage())
|
||||
.addPackage(org.librecms.contenttypes.Article.class.getPackage()).
|
||||
addClass(com.arsdigita.kernel.security.SecurityConfig.class)
|
||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||
.getPackage())
|
||||
// .addAsLibraries(getModuleDependencies())
|
||||
.addAsLibraries(getCcmCoreDependencies())
|
||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||
.addAsResource(
|
||||
"configs/org/librecms/contentsection/ContentItemManagerTest/log4j2.xml",
|
||||
"log4j2.xml")
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.librecms.assets.AssetManagerTest.war")
|
||||
.addPackage(org.libreccm.auditing.CcmRevision.class.getPackage()).
|
||||
addPackage(org.libreccm.categorization.Categorization.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
||||
.addPackage(org.libreccm.configuration.Configuration.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.core.CcmCore.class.getPackage())
|
||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||
.addPackage(com.arsdigita.bebop.Component.class.getPackage())
|
||||
.addPackage(com.arsdigita.bebop.util.BebopConstants.class
|
||||
.getPackage())
|
||||
.addClass(com.arsdigita.kernel.KernelConfig.class)
|
||||
.addClass(com.arsdigita.runtime.CCMResourceManager.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class)
|
||||
.addClass(com.arsdigita.cms.dispatcher.ItemResolver.class)
|
||||
.addPackage(com.arsdigita.util.Lockable.class.getPackage())
|
||||
.addPackage(com.arsdigita.web.BaseServlet.class.getPackage())
|
||||
.addPackage(org.librecms.Cms.class.getPackage())
|
||||
.addPackage(org.librecms.assets.BinaryAsset.class.getPackage())
|
||||
.addPackage(org.librecms.contentsection.Asset.class.getPackage()).
|
||||
addPackage(org.librecms.lifecycle.Lifecycle.class.getPackage())
|
||||
.addPackage(org.librecms.contentsection.ContentSection.class
|
||||
.getPackage())
|
||||
.addPackage(org.librecms.contenttypes.Article.class.getPackage()).
|
||||
addClass(com.arsdigita.kernel.security.SecurityConfig.class)
|
||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||
.getPackage())
|
||||
// .addAsLibraries(getModuleDependencies())
|
||||
.addAsLibraries(getCcmCoreDependencies())
|
||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||
.addAsResource(
|
||||
"configs/org/librecms/contentsection/ContentItemManagerTest/log4j2.xml",
|
||||
"log4j2.xml")
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -193,13 +193,13 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(100)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/after-attach-nonshared.xml",
|
||||
excludeColumns = {"timestamp",
|
||||
"uuid",
|
||||
"attachment_id"})
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/after-attach-nonshared.xml",
|
||||
excludeColumns = {"timestamp",
|
||||
"uuid",
|
||||
"attachment_id"})
|
||||
public void attachNonSharedAsset() throws MimeTypeParseException {
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
|
@ -222,13 +222,13 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(100)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/after-attach-shared.xml",
|
||||
excludeColumns = {"timestamp",
|
||||
"uuid",
|
||||
"attachment_id"})
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/after-attach-shared.xml",
|
||||
excludeColumns = {"timestamp",
|
||||
"uuid",
|
||||
"attachment_id"})
|
||||
public void attachSharedAsset() throws MimeTypeParseException {
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
|
@ -248,9 +248,9 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(110)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
public void attachAssetAlreadyAttached() {
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
|
@ -270,9 +270,9 @@ public class ItemAttachmentManagerTest {
|
|||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(120)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void attachAssetNull() {
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
|
|
@ -293,9 +293,9 @@ public class ItemAttachmentManagerTest {
|
|||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(130)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void attachAssetToListNull() {
|
||||
final AttachmentList list = null;
|
||||
|
|
@ -311,12 +311,12 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(210)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/"
|
||||
+ "after-unattach-shared.xml",
|
||||
excludeColumns = {"timestamp"})
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/"
|
||||
+ "after-unattach-shared.xml",
|
||||
excludeColumns = {"timestamp"})
|
||||
public void unattachSharedAsset() {
|
||||
final Asset asset = assetRepo.findById(-610L);
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
|
|
@ -338,12 +338,12 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(220)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/"
|
||||
+ "after-unattach-nonshared.xml",
|
||||
excludeColumns = {"timestamp"})
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/"
|
||||
+ "after-unattach-nonshared.xml",
|
||||
excludeColumns = {"timestamp"})
|
||||
public void unattachNonSharedAsset() {
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
|
|
@ -365,11 +365,19 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(220)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
public void unattachAssetNotAttached() {
|
||||
fail("Not implemented yet");
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final AttachmentList list = item.get().getAttachments().get(1);
|
||||
|
||||
attachmentManager.unattachAsset(asset, list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -381,12 +389,19 @@ public class ItemAttachmentManagerTest {
|
|||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(230)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void unattachAssetNull() {
|
||||
fail("Not implemented yet");
|
||||
final Asset asset = null;
|
||||
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final AttachmentList list = item.get().getAttachments().get(0);
|
||||
|
||||
attachmentManager.unattachAsset(asset, list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -398,12 +413,17 @@ public class ItemAttachmentManagerTest {
|
|||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(240)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void unattachAssetFromListNull() {
|
||||
fail("Not implemented yet");
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
||||
final AttachmentList list = null;
|
||||
|
||||
attachmentManager.unattachAsset(asset, list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -414,11 +434,19 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(300)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/after-move-up.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/after-move-up.xml",
|
||||
excludeColumns = {"timestamp"})
|
||||
public void moveUp() {
|
||||
fail("Not implemented yet");
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final AttachmentList list = item.get().getAttachments().get(0);
|
||||
|
||||
attachmentManager.moveUp(list.getAttachments().get(0).getAsset(),
|
||||
list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -429,11 +457,17 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(310)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
public void moveUpLast() {
|
||||
fail("Not implemented yet");
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final AttachmentList list = item.get().getAttachments().get(0);
|
||||
|
||||
attachmentManager.moveUp(list.getAttachments().get(2).getAsset(),
|
||||
list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -445,12 +479,39 @@ public class ItemAttachmentManagerTest {
|
|||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(320)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveUpNull() {
|
||||
fail("Not implemented yet");
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final AttachmentList list = item.get().getAttachments().get(0);
|
||||
|
||||
attachmentManager.moveUp(null, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that
|
||||
* {@link ItemAttachmentManager#moveUp(org.librecms.contentsection.Asset, org.librecms.contentsection.AttachmentList)}
|
||||
* throws an {@link IllegalArgumentException} if called with {@code null}
|
||||
* for the list.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(330)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveUpInListNull() {
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
||||
final AttachmentList list = null;
|
||||
|
||||
attachmentManager.moveUp(asset, list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -461,11 +522,19 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(400)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/after-move-down.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/after-move-down.xml",
|
||||
excludeColumns = {"timestamp"})
|
||||
public void moveDown() {
|
||||
fail("Not implemented yet");
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final AttachmentList list = item.get().getAttachments().get(0);
|
||||
|
||||
attachmentManager.moveDown(list.getAttachments().get(2).getAsset(),
|
||||
list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -476,11 +545,17 @@ public class ItemAttachmentManagerTest {
|
|||
@Test
|
||||
@InSequence(410)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
public void moveDownFirst() {
|
||||
fail("Not implemented yet");
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final AttachmentList list = item.get().getAttachments().get(0);
|
||||
|
||||
attachmentManager.moveDown(list.getAttachments().get(0).getAsset(),
|
||||
list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -492,12 +567,39 @@ public class ItemAttachmentManagerTest {
|
|||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(420)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveDownNull() {
|
||||
fail("Not implemented yet");
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final AttachmentList list = item.get().getAttachments().get(0);
|
||||
|
||||
attachmentManager.moveDown(null, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that
|
||||
* {@link ItemAttachmentManager#moveDown(org.librecms.contentsection.Asset, org.librecms.contentsection.AttachmentList)}
|
||||
* throws an {@link IllegalArgumentException} if called with {@code null}
|
||||
* for the list.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(430)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveDownInListNull() {
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
||||
final AttachmentList list = null;
|
||||
|
||||
attachmentManager.moveDown(asset, list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
<ccm_core.ccm_revisions id="0"
|
||||
timestamp="1451602800" />
|
||||
<ccm_core.ccm_revisions id="1"
|
||||
timestamp="1451602800" />
|
||||
|
||||
<ccm_core.ccm_objects object_id="-100"
|
||||
display_name="info"
|
||||
|
|
@ -320,12 +322,12 @@
|
|||
asset_id="-710"
|
||||
attachment_list_id="-510010" />
|
||||
<ccm_cms.attachments attachment_id="-510120"
|
||||
sort_key="2"
|
||||
sort_key="3"
|
||||
uuid="5a34deae-9e3a-41e8-abd8-6a7d10dd9e7d"
|
||||
asset_id="-720"
|
||||
attachment_list_id="-510010" />
|
||||
<ccm_cms.attachments attachment_id="-510130"
|
||||
sort_key="3"
|
||||
sort_key="2"
|
||||
uuid="9e34627c-2da9-45fe-aae3-48801bd27cbe"
|
||||
asset_id="-610"
|
||||
attachment_list_id="-510010" />
|
||||
|
|
@ -345,6 +347,7 @@
|
|||
<ccm_cms.attachments_aud attachment_id="-510120"
|
||||
rev="0"
|
||||
revtype="0"
|
||||
revend="1"
|
||||
sort_key="2"
|
||||
uuid="5a34deae-9e3a-41e8-abd8-6a7d10dd9e7d"
|
||||
asset_id="-720"
|
||||
|
|
@ -352,6 +355,7 @@
|
|||
<ccm_cms.attachments_aud attachment_id="-510130"
|
||||
rev="0"
|
||||
revtype="0"
|
||||
revend="1"
|
||||
sort_key="3"
|
||||
uuid="9e34627c-2da9-45fe-aae3-48801bd27cbe"
|
||||
asset_id="-610"
|
||||
|
|
@ -370,7 +374,20 @@
|
|||
uuid="395c43dc-4aea-43e3-a2de-13e10f3a63f7"
|
||||
asset_id="-630"
|
||||
attachment_list_id="-510030" />
|
||||
<ccm_cms.attachments_aud attachment_id="-510120"
|
||||
rev="1"
|
||||
revtype="1"
|
||||
sort_key="3"
|
||||
uuid="5a34deae-9e3a-41e8-abd8-6a7d10dd9e7d"
|
||||
asset_id="-720"
|
||||
attachment_list_id="-510010" />
|
||||
<ccm_cms.attachments_aud attachment_id="-510130"
|
||||
rev="1"
|
||||
revtype="1"
|
||||
sort_key="2"
|
||||
uuid="9e34627c-2da9-45fe-aae3-48801bd27cbe"
|
||||
asset_id="-610"
|
||||
attachment_list_id="-510010" />
|
||||
|
||||
</dataset>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
<ccm_core.ccm_revisions id="0"
|
||||
timestamp="1451602800" />
|
||||
<ccm_core.ccm_revisions id="1"
|
||||
timestamp="1451602800" />
|
||||
|
||||
<ccm_core.ccm_objects object_id="-100"
|
||||
display_name="info"
|
||||
|
|
@ -315,12 +317,12 @@
|
|||
item_id="-510" />
|
||||
|
||||
<ccm_cms.attachments attachment_id="-510110"
|
||||
sort_key="1"
|
||||
sort_key="2"
|
||||
uuid="de1d8531-df11-4808-9679-9ffa7537ebd1"
|
||||
asset_id="-710"
|
||||
attachment_list_id="-510010" />
|
||||
<ccm_cms.attachments attachment_id="-510120"
|
||||
sort_key="2"
|
||||
sort_key="1"
|
||||
uuid="5a34deae-9e3a-41e8-abd8-6a7d10dd9e7d"
|
||||
asset_id="-720"
|
||||
attachment_list_id="-510010" />
|
||||
|
|
@ -338,6 +340,7 @@
|
|||
<ccm_cms.attachments_aud attachment_id="-510110"
|
||||
rev="0"
|
||||
revtype="0"
|
||||
revend="1"
|
||||
sort_key="1"
|
||||
uuid="de1d8531-df11-4808-9679-9ffa7537ebd1"
|
||||
asset_id="-710"
|
||||
|
|
@ -345,6 +348,7 @@
|
|||
<ccm_cms.attachments_aud attachment_id="-510120"
|
||||
rev="0"
|
||||
revtype="0"
|
||||
revend="1"
|
||||
sort_key="2"
|
||||
uuid="5a34deae-9e3a-41e8-abd8-6a7d10dd9e7d"
|
||||
asset_id="-720"
|
||||
|
|
@ -370,7 +374,20 @@
|
|||
uuid="395c43dc-4aea-43e3-a2de-13e10f3a63f7"
|
||||
asset_id="-630"
|
||||
attachment_list_id="-510030" />
|
||||
<ccm_cms.attachments_aud attachment_id="-510110"
|
||||
rev="1"
|
||||
revtype="1"
|
||||
sort_key="2"
|
||||
uuid="de1d8531-df11-4808-9679-9ffa7537ebd1"
|
||||
asset_id="-710"
|
||||
attachment_list_id="-510010" />
|
||||
<ccm_cms.attachments_aud attachment_id="-510120"
|
||||
rev="1"
|
||||
revtype="1"
|
||||
sort_key="1"
|
||||
uuid="5a34deae-9e3a-41e8-abd8-6a7d10dd9e7d"
|
||||
asset_id="-720"
|
||||
attachment_list_id="-510010" />
|
||||
|
||||
</dataset>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue