CCM NG: Fixed several test failures due to recent changes.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4594 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
2b414205ae
commit
e525d974bb
|
|
@ -71,95 +71,95 @@ import static org.librecms.CmsConstants.*;
|
|||
//@Indexed
|
||||
@NamedQueries({
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findById",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "WHERE i.objectId = :objectId "
|
||||
+ "AND (EXISTS(SELECT p FROM Permission p "
|
||||
+ "WHERE p.grantedPrivilege = 'read' "
|
||||
+ "AND p.grantee IN :roles "
|
||||
+ "AND p.object = i)"
|
||||
+ "OR true = :admin)")
|
||||
name = "ContentItem.findById",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "WHERE i.objectId = :objectId "
|
||||
+ "AND (EXISTS(SELECT p FROM Permission p "
|
||||
+ "WHERE p.grantedPrivilege = 'read' "
|
||||
+ "AND p.grantee IN :roles "
|
||||
+ "AND p.object = i)"
|
||||
+ "OR true = :admin)")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findByType",
|
||||
query = "SELECT i FROM ContentItem i WHERE TYPE(i) = :type")
|
||||
name = "ContentItem.findByType",
|
||||
query = "SELECT i FROM ContentItem i WHERE TYPE(i) = :type")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findByFolder",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "'")
|
||||
name = "ContentItem.findByFolder",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "'")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.countItemsInFolder",
|
||||
query = "SELECT count(i) FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "'")
|
||||
name = "ContentItem.countItemsInFolder",
|
||||
query = "SELECT count(i) FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "'")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findByNameInFolder",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND i.displayName = :name")
|
||||
name = "ContentItem.findByNameInFolder",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND i.displayName = :name")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.countByNameInFolder",
|
||||
query = "SELECT COUNT(i) FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND i.displayName = :name")
|
||||
name = "ContentItem.countByNameInFolder",
|
||||
query = "SELECT COUNT(i) FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND i.displayName = :name")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.filterByFolderAndName",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND LOWER(i.displayName) LIKE CONCAT(LOWER(:name), '%')")
|
||||
name = "ContentItem.filterByFolderAndName",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND LOWER(i.displayName) LIKE CONCAT(LOWER(:name), '%')")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.countFilterByFolderAndName",
|
||||
query = "SELECT COUNT(i) FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND LOWER(i.displayName) LIKE CONCAT(LOWER(:name), '%')"
|
||||
name = "ContentItem.countFilterByFolderAndName",
|
||||
query = "SELECT COUNT(i) FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND LOWER(i.displayName) LIKE CONCAT(LOWER(:name), '%')"
|
||||
)
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.hasLiveVersion",
|
||||
query = "SELECT (CASE WHEN COUNT(i) > 0 THEN true ELSE false END) "
|
||||
+ "FROM ContentItem i "
|
||||
+ "WHERE i.itemUuid = :uuid "
|
||||
+ "AND i.version = org.librecms.contentsection.ContentItemVersion.LIVE")
|
||||
name = "ContentItem.hasLiveVersion",
|
||||
query = "SELECT (CASE WHEN COUNT(i) > 0 THEN true ELSE false END) "
|
||||
+ "FROM ContentItem i "
|
||||
+ "WHERE i.itemUuid = :uuid "
|
||||
+ "AND i.version = org.librecms.contentsection.ContentItemVersion.LIVE")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findDraftVersion",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "WHERE i.itemUuid = :uuid "
|
||||
+ "AND i.version = org.librecms.contentsection.ContentItemVersion.DRAFT")
|
||||
name = "ContentItem.findDraftVersion",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "WHERE i.itemUuid = :uuid "
|
||||
+ "AND i.version = org.librecms.contentsection.ContentItemVersion.DRAFT")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findLiveVersion",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "WHERE i.itemUuid = :uuid "
|
||||
+ "AND i.version = org.librecms.contentsection.ContentItemVersion.LIVE")
|
||||
name = "ContentItem.findLiveVersion",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "WHERE i.itemUuid = :uuid "
|
||||
+ "AND i.version = org.librecms.contentsection.ContentItemVersion.LIVE")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findItemWithWorkflow",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "WHERE i.workflow = :workflow"
|
||||
name = "ContentItem.findItemWithWorkflow",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "WHERE i.workflow = :workflow"
|
||||
)
|
||||
})
|
||||
public class ContentItem extends CcmObject implements Serializable {
|
||||
|
|
@ -178,13 +178,13 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
*/
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_NAMES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_NAMES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
// @Field
|
||||
private LocalizedString name;
|
||||
|
|
@ -203,13 +203,13 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
*/
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_TITLES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_TITLES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
@IndexedEmbedded
|
||||
private LocalizedString title;
|
||||
|
|
@ -219,12 +219,12 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
*/
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_DESCRIPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_DESCRIPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@IndexedEmbedded
|
||||
private LocalizedString description;
|
||||
|
||||
|
|
@ -432,19 +432,35 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
}
|
||||
|
||||
public Date getCreationDate() {
|
||||
return new Date(creationDate.getTime());
|
||||
if (creationDate == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new Date(creationDate.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public void setCreationDate(final Date creationDate) {
|
||||
this.creationDate = new Date(creationDate.getTime());
|
||||
if (creationDate == null) {
|
||||
this.creationDate = null;
|
||||
} else {
|
||||
this.creationDate = new Date(creationDate.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public Date getLastModified() {
|
||||
return new Date(lastModified.getTime());
|
||||
if (lastModified == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new Date(lastModified.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public void setLastModified(final Date lastModified) {
|
||||
this.lastModified = new Date(lastModified.getTime());
|
||||
if (lastModified == null) {
|
||||
this.lastModified = null;
|
||||
} else {
|
||||
this.lastModified = new Date(lastModified.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public String getCreationUserName() {
|
||||
|
|
@ -533,15 +549,15 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
@Override
|
||||
public String toString(final String data) {
|
||||
return super.toString(String.format(", itemUuid = %s, "
|
||||
+ "name = %s, "
|
||||
// + "contentType = { %s }, "
|
||||
+ "title = %s, "
|
||||
+ "description = %s, "
|
||||
+ "version = %s, "
|
||||
+ "launchDate = %s, "
|
||||
+ "lifecycle = { %s }, "
|
||||
+ "workflow = { %s }"
|
||||
+ "%s",
|
||||
+ "name = %s, "
|
||||
// + "contentType = { %s }, "
|
||||
+ "title = %s, "
|
||||
+ "description = %s, "
|
||||
+ "version = %s, "
|
||||
+ "launchDate = %s, "
|
||||
+ "lifecycle = { %s }, "
|
||||
+ "workflow = { %s }"
|
||||
+ "%s",
|
||||
itemUuid,
|
||||
Objects.toString(name),
|
||||
// Objects.toString(contentType),
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ import javax.transaction.Transactional;
|
|||
import org.libreccm.security.PermissionChecker;
|
||||
import org.librecms.contentsection.privileges.TypePrivileges;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Manager class providing several methods to manipulate {@link ContentItem}s.
|
||||
*
|
||||
|
|
@ -389,6 +391,9 @@ public class ContentItemManager {
|
|||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
// final String uuid = UUID.randomUUID().toString();
|
||||
// copy.setUuid(uuid);
|
||||
// copy.setItemUuid(uuid);
|
||||
copy.setContentType(contentType.get());
|
||||
|
||||
if (draftItem.getWorkflow() != null) {
|
||||
|
|
@ -399,26 +404,6 @@ public class ContentItemManager {
|
|||
copy.setWorkflow(copyWorkflow);
|
||||
}
|
||||
|
||||
contentItemRepo.save(copy);
|
||||
|
||||
draftItem.getCategories().forEach(categorization -> categoryManager
|
||||
.addObjectToCategory(copy, categorization.getCategory()));
|
||||
|
||||
final Optional<Folder> itemFolder = getItemFolder(draftItem);
|
||||
if (itemFolder.isPresent()) {
|
||||
try {
|
||||
categoryManager.removeObjectFromCategory(
|
||||
copy, getItemFolder(draftItem).get());
|
||||
} catch (ObjectNotAssignedToCategoryException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
categoryManager.addObjectToCategory(
|
||||
copy,
|
||||
targetFolder,
|
||||
CATEGORIZATION_TYPE_FOLDER);
|
||||
|
||||
for (AttachmentList attachmentList : item.getAttachments()) {
|
||||
copyAttachmentList(attachmentList, copy);
|
||||
}
|
||||
|
|
@ -536,6 +521,24 @@ public class ContentItemManager {
|
|||
}
|
||||
}
|
||||
|
||||
contentItemRepo.save(copy);
|
||||
|
||||
draftItem.getCategories().forEach(categorization -> categoryManager
|
||||
.addObjectToCategory(copy, categorization.getCategory()));
|
||||
final Optional<Folder> itemFolder = getItemFolder(draftItem);
|
||||
if (itemFolder.isPresent()) {
|
||||
try {
|
||||
categoryManager.removeObjectFromCategory(
|
||||
copy, getItemFolder(draftItem).get());
|
||||
} catch (ObjectNotAssignedToCategoryException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
categoryManager.addObjectToCategory(
|
||||
copy,
|
||||
targetFolder,
|
||||
CATEGORIZATION_TYPE_FOLDER);
|
||||
|
||||
if (targetFolder.equals(getItemFolder(item).orElse(null))) {
|
||||
final long number = contentItemRepo.countFilterByFolderAndName(
|
||||
targetFolder, String.format("%s_copy",
|
||||
|
|
@ -546,8 +549,6 @@ public class ContentItemManager {
|
|||
index));
|
||||
}
|
||||
|
||||
contentItemRepo.save(copy);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -372,7 +372,12 @@ public class ContentItemRepository
|
|||
public void save(final ContentItem item) {
|
||||
final Date now = new Date();
|
||||
final Subject subject = shiro.getSubject();
|
||||
final String userName = subject.getPrincipal().toString();
|
||||
final String userName;
|
||||
if (subject == null || subject.getPrincipal() == null) {
|
||||
userName = "";
|
||||
} else {
|
||||
userName = subject.getPrincipal().toString();
|
||||
}
|
||||
|
||||
if (isNew(item)) {
|
||||
item.setCreationDate(now);
|
||||
|
|
@ -399,21 +404,20 @@ public class ContentItemRepository
|
|||
// draft.getCategories().stream()
|
||||
// .map(categorization -> categorization.getCategory())
|
||||
// .forEach(category -> removeCategoryFromItem(item, category));
|
||||
for(final Categorization categorization : draft.getCategories()) {
|
||||
for (final Categorization categorization : draft.getCategories()) {
|
||||
final Category category = categorization.getCategory();
|
||||
|
||||
removeCategoryFromItem(item, category);
|
||||
}
|
||||
|
||||
|
||||
super.delete(draft);
|
||||
}
|
||||
|
||||
private void removeCategoryFromItem(final ContentItem item,
|
||||
final Category category) {
|
||||
try {
|
||||
categoryManager.removeObjectFromCategory(item, category);
|
||||
} catch(ObjectNotAssignedToCategoryException ex) {
|
||||
categoryManager.removeObjectFromCategory(item, category);
|
||||
} catch (ObjectNotAssignedToCategoryException ex) {
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ public class ContentItemRepositoryTest {
|
|||
.addAsLibraries(getCcmCoreDependencies())
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@
|
|||
<ccm_core.categorizations categorization_id="-30400"
|
||||
category_id="-1600"
|
||||
object_id="-900"
|
||||
category_order="1"
|
||||
category_order="2"
|
||||
object_order="4"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@
|
|||
<ccm_core.categorizations categorization_id="-30400"
|
||||
category_id="-410"
|
||||
object_id="-900"
|
||||
category_order="1"
|
||||
category_order="2"
|
||||
object_order="4"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@
|
|||
<ccm_core.categorizations categorization_id="-30110"
|
||||
category_id="-2300"
|
||||
object_id="-10110"
|
||||
category_order="1"
|
||||
category_order="2"
|
||||
object_order="1"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
|
|
|||
|
|
@ -676,7 +676,7 @@
|
|||
<ccm_core.categorizations categorization_id="-30500"
|
||||
category_id="-2120"
|
||||
object_id="-10500"
|
||||
category_order="1"
|
||||
category_order="2"
|
||||
object_order="1"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
|
|
|||
|
|
@ -647,7 +647,7 @@
|
|||
<ccm_core.categorizations categorization_id="-30100"
|
||||
category_id="-2110"
|
||||
object_id="-10100"
|
||||
category_order="1"
|
||||
category_order="2"
|
||||
object_order="1"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
|
|
|||
|
|
@ -566,7 +566,7 @@
|
|||
<ccm_core.categorizations categorization_id="-30100"
|
||||
category_id="-2300"
|
||||
object_id="-10100"
|
||||
category_order="1"
|
||||
category_order="2"
|
||||
object_order="1"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@
|
|||
<ccm_core.categorizations categorization_id="-30100"
|
||||
category_id="-2120"
|
||||
object_id="-10100"
|
||||
category_order="1"
|
||||
category_order="2"
|
||||
object_order="1"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@
|
|||
<ccm_core.categorizations categorization_id="-30200"
|
||||
category_id="-2100"
|
||||
object_id="-10200"
|
||||
category_order="1"
|
||||
category_order="2"
|
||||
object_order="2"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.libreccm.auditing;
|
|||
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
|
||||
import org.hibernate.envers.RevisionListener;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.Shiro;
|
||||
|
|
@ -46,7 +45,11 @@ public class CcmRevisionListener implements RevisionListener {
|
|||
final Shiro shiro = cdiUtil.findBean(Shiro.class);
|
||||
|
||||
final Subject subject = shiro.getSubject();
|
||||
revision.setUserName(subject.getPrincipal().toString());
|
||||
if (subject == null || subject.getPrincipal() == null) {
|
||||
revision.setUserName("");
|
||||
} else {
|
||||
revision.setUserName(subject.getPrincipal().toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,9 +277,9 @@ public class CategoryManager {
|
|||
query.setParameter("category", category);
|
||||
query.setParameter("object", object);
|
||||
|
||||
final Categorization categorization;
|
||||
final List<Categorization> categorizations;
|
||||
try {
|
||||
categorization = query.getSingleResult();
|
||||
categorizations = query.getResultList();
|
||||
} catch (NoResultException ex) {
|
||||
LOGGER.warn(String.format(
|
||||
"No categorization for category %s and object %s found."
|
||||
|
|
@ -290,7 +290,7 @@ public class CategoryManager {
|
|||
return;
|
||||
}
|
||||
|
||||
entityManager.remove(categorization);
|
||||
categorizations.forEach(entityManager::remove);
|
||||
|
||||
// shiro.getSystemUser().execute(() -> {
|
||||
// object.removeCategory(categorization);
|
||||
|
|
|
|||
|
|
@ -100,33 +100,43 @@ public class CcmObjectRepositoryTest {
|
|||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.libreccm.core.CcmObjectRepositoryTest.war").
|
||||
addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
|
||||
.addPackage(org.libreccm.categorization.Categorization.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.configuration.Configuration.class.
|
||||
getPackage())
|
||||
.addPackage(org.libreccm.core.CcmObject.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.PermissionChecker.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
||||
getPackage())
|
||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||
.addClass(org.libreccm.portation.Portable.class)
|
||||
.addAsLibraries(getModuleDependencies())
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.libreccm.core.CcmObjectRepositoryTest.war")
|
||||
.addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
|
||||
.addPackage(org.libreccm.categorization.Categorization.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.configuration.Configuration.class.
|
||||
getPackage())
|
||||
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
|
||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
||||
.addClass(org.libreccm.modules.CcmModule.class)
|
||||
.addClass(org.libreccm.modules.ModuleEvent.class)
|
||||
.addClass(org.libreccm.modules.InitEvent.class)
|
||||
.addClass(org.libreccm.modules.InstallEvent.class)
|
||||
.addClass(org.libreccm.modules.UnInstallEvent.class)
|
||||
.addClass(org.libreccm.modules.ShutdownEvent.class)
|
||||
.addPackage(org.libreccm.security.PermissionChecker.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
||||
getPackage())
|
||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||
.addClass(org.libreccm.portation.Portable.class)
|
||||
.addPackage(com.arsdigita.kernel.security.SecurityConfig.class
|
||||
.getPackage())
|
||||
.addAsLibraries(getModuleDependencies())
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,7 +173,7 @@ public class CcmObjectRepositoryTest {
|
|||
*/
|
||||
@Test
|
||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||
+ "after-save-changed.yml")
|
||||
+ "after-save-changed.yml")
|
||||
@InSequence(4)
|
||||
public void datasetOnly2() {
|
||||
System.out.println("Dataset loaded successfully.");
|
||||
|
|
@ -277,9 +287,9 @@ public class CcmObjectRepositoryTest {
|
|||
@Test
|
||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||
+ "after-save-new.yml",
|
||||
excludeColumns = {"object_id", "uuid"})
|
||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||
+ "after-save-new.yml",
|
||||
excludeColumns = {"object_id", "uuid"})
|
||||
@InSequence(300)
|
||||
public void saveNewCcmObject() {
|
||||
final CcmObject obj = new CcmObject();
|
||||
|
|
@ -297,9 +307,9 @@ public class CcmObjectRepositoryTest {
|
|||
@Test
|
||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||
+ "after-save-changed.yml",
|
||||
excludeColumns = {"object_id"})
|
||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||
+ "after-save-changed.yml",
|
||||
excludeColumns = {"object_id"})
|
||||
@InSequence(400)
|
||||
public void saveChangedCcmObject() {
|
||||
final CcmObject obj = ccmObjectRepository.findById(-20L).get();
|
||||
|
|
@ -328,9 +338,9 @@ public class CcmObjectRepositoryTest {
|
|||
@Test
|
||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||
+ "after-delete.yml",
|
||||
excludeColumns = {"object_id"})
|
||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||
+ "after-delete.yml",
|
||||
excludeColumns = {"object_id"})
|
||||
@InSequence(600)
|
||||
public void deleteCcmObject() {
|
||||
final CcmObject obj = ccmObjectRepository.findById(-20L).get();
|
||||
|
|
@ -343,8 +353,10 @@ public class CcmObjectRepositoryTest {
|
|||
* a {@link IllegalArgumentException} if called with {@link null} for the
|
||||
* object to delete.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@Test(expected = NullPointerException.class)
|
||||
@ShouldThrowException(NullPointerException.class)
|
||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
||||
@ShouldMatchDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
||||
@InSequence(700)
|
||||
public void deleteNullValue() {
|
||||
ccmObjectRepository.delete(null);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class PartyRepositoryTest {
|
|||
.getPackage())
|
||||
.addPackage(
|
||||
org.libreccm.configuration.ConfigurationManager.class
|
||||
.getPackage())
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
|
|
@ -269,8 +269,11 @@ public class PartyRepositoryTest {
|
|||
shiro.getSystemUser().execute(() -> partyRepository.delete(user));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@Test(expected = NullPointerException.class)
|
||||
@ShouldThrowException(NullPointerException.class)
|
||||
@UsingDataSet("datasets/org/libreccm/security/PartyRepositoryTest/data.yml")
|
||||
@ShouldMatchDataSet(
|
||||
"datasets/org/libreccm/security/PartyRepositoryTest/data.yml")
|
||||
@InSequence(700)
|
||||
public void deleteNullValue() {
|
||||
shiro.getSystemUser().execute(() -> partyRepository.delete(null));
|
||||
|
|
|
|||
Loading…
Reference in New Issue