From dd4e6693572f8b164f22d2dfce25d48ff0ae42ae Mon Sep 17 00:00:00 2001 From: jensp Date: Sun, 9 Oct 2016 17:12:05 +0000 Subject: [PATCH] CCM NG/ccm-cms: - Extended ContentSectionManager with bodies of methods for managing ContentTypes for a section, added bodies for tests to ContentSectionManager - Some improvments for other tests in ccm-cms - index page for project site of ccm-cms CCM NG/ccm-shortcuts: - Adjusted tests to lastest changes in ccm-core (DB-Schema) git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4367 8810af33-2d31-482b-a856-94f89814c4df --- .../contentsection/ContentSectionManager.java | 1 + ccm-cms/src/site/apt/index.apt | 12 + ccm-cms/src/site/site.xml | 24 ++ .../ContentItemManagerTest.java | 47 +-- .../ContentItemRepositoryTest.java | 20 +- .../ContentSectionManagerTest.java | 383 +++++++++++++++++- .../scripts/create_ccm_shortcuts_schema.sql | 18 +- .../scripts/create_ccm_shortcuts_schema.sql | 18 +- 8 files changed, 453 insertions(+), 70 deletions(-) create mode 100644 ccm-cms/src/site/apt/index.apt create mode 100644 ccm-cms/src/site/site.xml diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionManager.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionManager.java index 5cae4b79d..1ace1be46 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionManager.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionManager.java @@ -500,6 +500,7 @@ public class ContentSectionManager { * @throws IllegalArgumentException if the provided {@link ContentType} is * in use or the parameters or otherwise * illegal. + * @see ContentTypeRepository#delete(org.librecms.contentsection.ContentType) */ public void removeContentTypeFromSection( final Class type, diff --git a/ccm-cms/src/site/apt/index.apt b/ccm-cms/src/site/apt/index.apt new file mode 100644 index 000000000..8bef04e12 --- /dev/null +++ b/ccm-cms/src/site/apt/index.apt @@ -0,0 +1,12 @@ + ---------------- + Overview + ---------------- + Jens Pelzetter + ---------------- + 2016-10-09 + ---------------- + +LibreCMS + + The module (<<>>) for provides the foundation + for the CMS functionality of LibreCCM diff --git a/ccm-cms/src/site/site.xml b/ccm-cms/src/site/site.xml new file mode 100644 index 000000000..fc626a91f --- /dev/null +++ b/ccm-cms/src/site/site.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemManagerTest.java b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemManagerTest.java index d9a57f849..253e1a326 100644 --- a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemManagerTest.java +++ b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemManagerTest.java @@ -31,17 +31,12 @@ import org.jboss.arquillian.transaction.api.annotation.Transactional; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.jboss.shrinkwrap.resolver.api.maven.Maven; -import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage; -import org.jboss.shrinkwrap.resolver.api.maven.ScopeType; -import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependencies; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.libreccm.categorization.Category; import org.libreccm.categorization.CategoryRepository; import org.libreccm.security.Shiro; import org.libreccm.tests.categories.IntegrationTest; @@ -52,12 +47,8 @@ import org.librecms.contenttypes.Event; import org.librecms.lifecycle.LifecycleDefinition; import org.librecms.lifecycle.LifecycleDefinitionRepository; -import java.io.File; -import java.util.ArrayList; -import java.util.List; import java.util.Locale; import java.util.Optional; -import java.util.stream.IntStream; import javax.inject.Inject; import javax.persistence.EntityManager; @@ -65,6 +56,7 @@ import javax.persistence.TypedQuery; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; + import static org.libreccm.testutils.DependenciesHelpers.*; /** @@ -92,7 +84,7 @@ public class ContentItemManagerTest { @Inject private FolderRepository folderRepo; - + @Inject private Shiro shiro; @@ -126,37 +118,6 @@ public class ContentItemManagerTest { @Deployment public static WebArchive createDeployment() { -//// final PomEquippedResolveStage pom = Maven -//// .resolver() -//// .loadPomFromFile("pom.xml"); -//// final PomEquippedResolveStage dependencies = pom -//// .importCompileAndRuntimeDependencies(); -//// dependencies.addDependency(MavenDependencies.createDependency( -//// "org.libreccm:ccm-core", ScopeType.RUNTIME, false)); -//// dependencies.addDependency(MavenDependencies.createDependency( -//// "org.libreccm:ccm-testutils", ScopeType.RUNTIME, false)); -//// dependencies.addDependency(MavenDependencies.createDependency( -//// "net.sf.saxon:Saxon-HE", ScopeType.RUNTIME, false)); -//// dependencies.addDependency(MavenDependencies.createDependency( -//// "org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven", -//// ScopeType.RUNTIME, false)); -//// final File[] libsWithCcmCore = dependencies.resolve().withTransitivity() -//// .asFile(); -//// -// final List libsList = new ArrayList<>(libsWithCcmCore.length - 1); -// IntStream.range(0, libsWithCcmCore.length).forEach(i -> { -// final File lib = libsWithCcmCore[i]; -// if (!lib.getName().startsWith("ccm-core")) { -// libsList.add(lib); -// } -// }); -// final File[] libs = libsList.toArray(new File[libsList.size()]); -// -// for (File lib : libs) { -// System.err.printf("Adding file '%s' to test archive...%n", -// lib.getName()); -// } - return ShrinkWrap .create(WebArchive.class, "LibreCCM-org.librecms.contentsection.ContentItemManagerTest.war") @@ -201,7 +162,9 @@ public class ContentItemManagerTest { .getPackage()) .addPackage(org.librecms.contenttypes.Article.class.getPackage()) .addClass(com.arsdigita.kernel.security.SecurityConfig.class) - .addAsLibraries(getModuleDependencies()) + .addPackage(org.libreccm.tests.categories.IntegrationTest.class + .getPackage()) + // .addAsLibraries(getModuleDependencies()) .addAsLibraries(getCcmCoreDependencies()) .addAsResource("configs/shiro.ini", "shiro.ini") .addAsResource( diff --git a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java index bf87bbe19..edb8211a1 100644 --- a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java +++ b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java @@ -134,7 +134,9 @@ public class ContentItemRepositoryTest { .addPackage(org.librecms.contentsection.ContentSection.class .getPackage()) .addPackage(org.librecms.contenttypes.Article.class.getPackage()) - .addAsLibraries(getModuleDependencies()) + .addPackage(org.libreccm.tests.categories.IntegrationTest.class + .getPackage()) + // .addAsLibraries(getModuleDependencies()) .addAsLibraries(getCcmCoreDependencies()) .addAsResource("test-persistence.xml", "META-INF/persistence.xml") @@ -315,25 +317,25 @@ public class ContentItemRepositoryTest { assertThat(itemRepo.countFilterByFolderAndName(folder, "foo"), is(0L)); } - + @Test @InSequence(600) @UsingDataSet("datasets/org/librecms/contentsection/" + "ContentItemRepositoryTest/data.xml") @ShouldMatchDataSet(value = "datasets/org/librecms/contentsection/" - + "ContentItemRepositoryTest/after-save.xml", - excludeColumns = {"object_id", - "uuid", - "item_uuid", + + "ContentItemRepositoryTest/after-save.xml", + excludeColumns = {"object_id", + "uuid", + "item_uuid", "timestamp"}) public void saveChangedItem() { final Optional item = itemRepo.findById(-10100L); - + assertThat(item.isPresent(), is(true)); - + item.get().getName().addValue(Locale.ENGLISH, "first-article"); item.get().getTitle().addValue(Locale.ENGLISH, "First Article"); - + itemRepo.save(item.get()); } diff --git a/ccm-cms/src/test/java/org/librecms/contentsection/ContentSectionManagerTest.java b/ccm-cms/src/test/java/org/librecms/contentsection/ContentSectionManagerTest.java index 62a815ff9..dbdff01bd 100644 --- a/ccm-cms/src/test/java/org/librecms/contentsection/ContentSectionManagerTest.java +++ b/ccm-cms/src/test/java/org/librecms/contentsection/ContentSectionManagerTest.java @@ -52,9 +52,13 @@ import javax.inject.Inject; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import static org.librecms.CmsConstants.*; + import static org.libreccm.testutils.DependenciesHelpers.*; +import org.jboss.arquillian.container.test.api.ShouldThrowException; + /** + * Tests for the {@link ContentSectionManager}. * * @author Jens Pelzetter */ @@ -80,6 +84,9 @@ public class ContentSectionManagerTest { @Inject private CategoryRepository categoryRepo; + @Inject + private ContentTypeRepository typeRepo; + public ContentSectionManagerTest() { } @@ -156,24 +163,23 @@ public class ContentSectionManagerTest { .addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml"); } + /** + * Check if all injection points work. + */ @Test - @InSequence(10) - public void isRepositoryInjected() { + @InSequence(1) + public void checkInjection() { assertThat(repository, is(not(nullValue()))); - } - - @Test - @InSequence(20) - public void isManagerInjected() { assertThat(manager, is(not(nullValue()))); - } - - @Test - @InSequence(30) - public void isRoleRepositoryInjected() { assertThat(roleRepository, is(not(nullValue()))); + assertThat(confManager, is(not(nullValue()))); + assertThat(categoryRepo, is(not(nullValue()))); + assertThat(typeRepo, is(not(nullValue()))); } + /** + * Tries to create a new content section. + */ @Test @UsingDataSet("datasets/org/librecms/contentsection/" + "ContentSectionManagerTest/data.xml") @@ -196,6 +202,10 @@ public class ContentSectionManagerTest { manager.createContentSection("test"); } + /** + * Tries to rename a content section and checks if the content section, its + * root folders and its roles have been renamed to reflect the new name. + */ @Test @UsingDataSet("datasets/org/librecms/contentsection/" + "ContentSectionManagerTest/data.xml") @@ -231,6 +241,9 @@ public class ContentSectionManagerTest { categoryRepo.save(section.getRootAssetsFolder()); } + /** + * Tries to add a new role to a content section. + */ @Test @UsingDataSet("datasets/org/librecms/contentsection/" + "ContentSectionManagerTest/data.xml") @@ -253,6 +266,79 @@ public class ContentSectionManagerTest { PRIVILEGE_ITEMS_APPROVE); } + /** + * Verifies that + * {@link ContentSectionManager#addRoleToContentSection(org.librecms.contentsection.ContentSection, java.lang.String, java.lang.String...)} + * throws a {@link IllegalArgumentException} if the section to which the + * role should be added is {@code null}. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(301) + public void addRoleSectionIsNull() { + manager.addRoleToContentSection(null, + "reviewer", + PRIVILEGE_ITEMS_VIEW_PUBLISHED, + PRIVILEGE_ITEMS_PREVIEW, + PRIVILEGE_ITEMS_APPROVE); + } + + /** + * Verifies that + * {@link ContentSectionManager#addRoleToContentSection(org.librecms.contentsection.ContentSection, java.lang.String, java.lang.String...)} + * throws a {@link IllegalArgumentException} if the role to add is + * {@code null}. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(302) + public void addRoleNameIsNull() { + final ContentSection section = repository.findByLabel("info"); + + manager.addRoleToContentSection(section, + null, + PRIVILEGE_ITEMS_VIEW_PUBLISHED, + PRIVILEGE_ITEMS_PREVIEW, + PRIVILEGE_ITEMS_APPROVE); + } + + /** + * Verifies that + * {@link ContentSectionManager#addRoleToContentSection(org.librecms.contentsection.ContentSection, java.lang.String, java.lang.String...)} + * throws a {@link IllegalArgumentException} if the name of the role to add + * is empty. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(302) + public void addRoleNameIsEmpty() { + final ContentSection section = repository.findByLabel("info"); + + manager.addRoleToContentSection(section, + " ", + PRIVILEGE_ITEMS_VIEW_PUBLISHED, + PRIVILEGE_ITEMS_PREVIEW, + PRIVILEGE_ITEMS_APPROVE); + } + + /** + * Tries to remove a role from a content section. + */ @Test @UsingDataSet("datasets/org/librecms/contentsection/" + "ContentSectionManagerTest/data.xml") @@ -260,7 +346,7 @@ public class ContentSectionManagerTest { value = "datasets/org/librecms/contentsection/" + "ContentSectionManagerTest/after-remove-role.xml", excludeColumns = {"object_id"}) - @InSequence(300) + @InSequence(350) public void removeRole() { final ContentSection section = repository.findByLabel("info"); final Role role = roleRepository.findByName("info_publisher"); @@ -268,4 +354,275 @@ public class ContentSectionManagerTest { manager.removeRoleFromContentSection(section, role); } + /** + * Verifies that + * {@link ContentSectionManager#removeRoleFromContentSection(org.librecms.contentsection.ContentSection, org.libreccm.security.Role)} + * throws an {@link IllegalArgumentException} if called with {@code null} + * for the role to remove. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(351) + public void removeRoleNull() { + final ContentSection section = repository.findByLabel("info"); + + manager.removeRoleFromContentSection(section, null); + } + + /** + * Verifies that + * {@link ContentSectionManager#removeRoleFromContentSection(org.librecms.contentsection.ContentSection, org.libreccm.security.Role)} + * throws an {@link IllegalArgumentException} if called with {@code null} + * for the section from which to role is removed. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(352) + public void removeRoleSectionIsNull() { + final Role role = roleRepository.findByName("info_publisher"); + + manager.removeRoleFromContentSection(null, role); + } + + /** + * Tries to add content type to a content section by using + * {@link ContentSectionManager#addContentTypeToSection(java.lang.Class, org.librecms.contentsection.ContentSection, org.librecms.lifecycle.LifecycleDefinition, org.libreccm.workflow.WorkflowTemplate)}. + */ + @Test + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/after-add-contenttype.xml") + @InSequence(400) + public void addContentTypeToSection() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#addContentTypeToSection(java.lang.Class, org.librecms.contentsection.ContentSection, org.librecms.lifecycle.LifecycleDefinition, org.libreccm.workflow.WorkflowTemplate)}. + * does nothing if there is already a {@link ContentType} for the provided + * type in the provided content section. + */ + @Test + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @InSequence(500) + public void addAlreadyAddedTypeToSection() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#addContentTypeToSection(java.lang.Class, org.librecms.contentsection.ContentSection, org.librecms.lifecycle.LifecycleDefinition, org.libreccm.workflow.WorkflowTemplate)}. + * throws an {@link IllegalArgumentException} when called with {@code null} + * for the type to add. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(600) + public void addTypeToSectionTypeIsNull() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#addContentTypeToSection(java.lang.Class, org.librecms.contentsection.ContentSection, org.librecms.lifecycle.LifecycleDefinition, org.libreccm.workflow.WorkflowTemplate)}. + * throws an {@link IllegalArgumentException} when called with {@code null} + * for the section of the type to add. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(700) + public void addTypeToSectionSectionIsNull() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#addContentTypeToSection(java.lang.Class, org.librecms.contentsection.ContentSection, org.librecms.lifecycle.LifecycleDefinition, org.libreccm.workflow.WorkflowTemplate)}. + * throws an {@link IllegalArgumentException} when called with {@code null} + * for the default lifecycle for the type. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(800) + public void addTypeToSectionLifecycleIsNull() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#addContentTypeToSection(java.lang.Class, org.librecms.contentsection.ContentSection, org.librecms.lifecycle.LifecycleDefinition, org.libreccm.workflow.WorkflowTemplate)}. + * throws an {@link IllegalArgumentException} when called with {@code null} + * for the default workflow of the type to add. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(900) + public void addTypeToSectionWorkflowIsNull() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#addContentTypeToSection(java.lang.Class, org.librecms.contentsection.ContentSection, org.librecms.lifecycle.LifecycleDefinition, org.libreccm.workflow.WorkflowTemplate)}. + * throws an {@link IllegalArgumentException} when called with a lifecycle + * which does not belong to the provided {@link ContentSection}. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(1000) + public void addTypeToSectionLifecycleNotInSection() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#addContentTypeToSection(java.lang.Class, org.librecms.contentsection.ContentSection, org.librecms.lifecycle.LifecycleDefinition, org.libreccm.workflow.WorkflowTemplate)}. + * throws an {@link IllegalArgumentException} when called with a workflow + * which does not belong to the provided {@link ContentSection}. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(1100) + public void addTypeToSectionWorkflowNoInSection() { + fail(); + } + + /** + * Verifies the return value of + * {@link ContentSectionManager#hasContentType(java.lang.Class, org.librecms.contentsection.ContentSection)}. + */ + @Test + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/after-add-contenttype.xml") + @InSequence(1200) + public void verifyHasContentType() { + fail(); + } + + /** + * Tries to remove an unused content type from a section. + */ + @Test + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/after-remove-contenttype.xml") + @InSequence(1300) + public void removeContentTypeFromSection() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#removeContentTypeFromSection(java.lang.Class, org.librecms.contentsection.ContentSection)} + * does nothing if the provided section has no {@link ContentType} for the + * provided subclass of {@link ContentItem}. + */ + @Test + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @InSequence(1301) + public void removeNotExistingContentTypeFromSection() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#removeContentTypeFromSection(java.lang.Class, org.librecms.contentsection.ContentSection)} + * throws a {@link IllegalArgumentException} if the type to delete is still + * in use. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(1400) + public void removeContentTypeFromSectionTypeInUse() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#removeContentTypeFromSection(java.lang.Class, org.librecms.contentsection.ContentSection)} + * throws an {@link IllegalArgumentException} if called with {@code null} + * for the type to remove. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(1400) + public void removeContentTypeFromSectionTypeIsNull() { + fail(); + } + + /** + * Verifies that + * {@link ContentSectionManager#removeContentTypeFromSection(java.lang.Class, org.librecms.contentsection.ContentSection)} + * throws an {@link IllegalArgumentException} if called with {@code null} + * for the section from which the type is removed. + */ + @Test(expected = IllegalArgumentException.class) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentSectionManagerTest/data.xml") + @ShouldThrowException(IllegalArgumentException.class) + @InSequence(1400) + public void removeContentTypeFromSectionSectionIsNull() { + fail(); + } + } diff --git a/ccm-shortcuts/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_shortcuts_schema.sql b/ccm-shortcuts/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_shortcuts_schema.sql index 4bf3eb1cb..83d75da79 100644 --- a/ccm-shortcuts/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_shortcuts_schema.sql +++ b/ccm-shortcuts/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_shortcuts_schema.sql @@ -479,6 +479,13 @@ CREATE SCHEMA ccm_shortcuts; primary key (OBJECT_ID) ); + create table CCM_CORE.ROLE_DESCRIPTIONS ( + ROLE_ID bigint not null, + LOCALIZED_VALUE longvarchar, + LOCALE varchar(255) not null, + primary key (ROLE_ID, LOCALE) + ); + create table CCM_CORE.ROLE_MEMBERSHIPS ( MEMBERSHIP_ID bigint not null, MEMBER_ID bigint, @@ -492,10 +499,10 @@ CREATE SCHEMA ccm_shortcuts; CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, SETTING_VALUE_LONG bigint, - SETTING_VALUE_STRING varchar(1024), - SETTING_VALUE_BIG_DECIMAL decimal(19,2), - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_DOUBLE double, + SETTING_VALUE_BOOLEAN boolean, + SETTING_VALUE_BIG_DECIMAL decimal(19,2), + SETTING_VALUE_STRING varchar(1024), primary key (SETTING_ID) ); @@ -1016,6 +1023,11 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (OBJECT_ID) references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.ROLE_DESCRIPTIONS + add constraint FKo09bh4j3k3k0ph3awvjwx31ft + foreign key (ROLE_ID) + references CCM_CORE.CCM_ROLES; + alter table CCM_CORE.ROLE_MEMBERSHIPS add constraint FK9m88ywi7rcin7b7jrgh53emrq foreign key (MEMBER_ID) diff --git a/ccm-shortcuts/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_shortcuts_schema.sql b/ccm-shortcuts/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_shortcuts_schema.sql index 2423d8499..79ec45306 100644 --- a/ccm-shortcuts/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_shortcuts_schema.sql +++ b/ccm-shortcuts/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_shortcuts_schema.sql @@ -479,6 +479,13 @@ CREATE SCHEMA ccm_shortcuts; primary key (OBJECT_ID) ); + create table CCM_CORE.ROLE_DESCRIPTIONS ( + ROLE_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (ROLE_ID, LOCALE) + ); + create table CCM_CORE.ROLE_MEMBERSHIPS ( MEMBERSHIP_ID int8 not null, MEMBER_ID int8, @@ -492,10 +499,10 @@ CREATE SCHEMA ccm_shortcuts; CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, SETTING_VALUE_LONG int8, - SETTING_VALUE_STRING varchar(1024), - SETTING_VALUE_BIG_DECIMAL numeric(19, 2), - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_DOUBLE float8, + SETTING_VALUE_BOOLEAN boolean, + SETTING_VALUE_BIG_DECIMAL numeric(19, 2), + SETTING_VALUE_STRING varchar(1024), primary key (SETTING_ID) ); @@ -1016,6 +1023,11 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (OBJECT_ID) references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.ROLE_DESCRIPTIONS + add constraint FKo09bh4j3k3k0ph3awvjwx31ft + foreign key (ROLE_ID) + references CCM_CORE.CCM_ROLES; + alter table CCM_CORE.ROLE_MEMBERSHIPS add constraint FK9m88ywi7rcin7b7jrgh53emrq foreign key (MEMBER_ID)