mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9157 Wiki Page Service CRUD unit tests (listing ones to follow)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29540 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -202,7 +202,7 @@ public class WikiPageServiceImpl implements WikiPageService
|
||||
).getChildRef();
|
||||
|
||||
// Store the content
|
||||
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, false);
|
||||
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(content);
|
||||
|
||||
@@ -223,11 +223,13 @@ public class WikiPageServiceImpl implements WikiPageService
|
||||
NodeRef nodeRef = page.getNodeRef();
|
||||
|
||||
// Handle the rename case
|
||||
boolean renamed = false;
|
||||
if(! nodeService.getProperty(nodeRef, ContentModel.PROP_NAME).equals(page.getTitle()))
|
||||
{
|
||||
try
|
||||
{
|
||||
fileFolderService.rename(nodeRef, page.getTitle());
|
||||
renamed = true;
|
||||
}
|
||||
catch(FileNotFoundException e)
|
||||
{
|
||||
@@ -245,6 +247,12 @@ public class WikiPageServiceImpl implements WikiPageService
|
||||
// Now do the tags
|
||||
taggingService.setTags(nodeRef, page.getTags());
|
||||
|
||||
// If we re-named, re-create the object
|
||||
if(renamed)
|
||||
{
|
||||
page = buildPage(nodeRef, page.getContainerNodeRef(), page.getTitle(), page.getContents());
|
||||
}
|
||||
|
||||
// All done
|
||||
return page;
|
||||
}
|
||||
|
@@ -166,65 +166,60 @@ public class WikiPageServiceImplTest
|
||||
|
||||
// Fetch it, and check the details
|
||||
page = WIKI_PAGE_SERVICE.getWikiPage(WIKI_SITE.getShortName(), page.getSystemName());
|
||||
if(1==0) { // TODO Fix this
|
||||
assertEquals("Title", page.getTitle());
|
||||
assertEquals("This Is Some Content", page.getContents());
|
||||
assertEquals(ADMIN_USER, page.getCreator());
|
||||
assertEquals(0, page.getTags().size());
|
||||
}
|
||||
|
||||
|
||||
// Mark it as done with
|
||||
testNodesToTidy.add(page.getNodeRef());
|
||||
}
|
||||
|
||||
// @Test public void createUpdateDeleteEntry() throws Exception
|
||||
// {
|
||||
// WikiPageInfo page;
|
||||
//
|
||||
// // Run as the test user instead
|
||||
// AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
|
||||
//
|
||||
//
|
||||
// // Create a link
|
||||
// page = WIKI_PAGE_SERVICE.createWikiPage(
|
||||
// WIKI_SITE.getShortName(), "Title", "This Is Some Content"
|
||||
// );
|
||||
//
|
||||
//
|
||||
// // Check it
|
||||
// assertEquals("Title", page.getTitle());
|
||||
// assertEquals("Description", page.getDescription());
|
||||
// assertEquals("http://www.alfresco.com/", page.getURL());
|
||||
// assertEquals(false, page.isInternal());
|
||||
// assertEquals(TEST_USER, page.getCreator());
|
||||
// assertEquals(0, page.getTags().size());
|
||||
//
|
||||
//
|
||||
// // Change it
|
||||
// page.setTitle("New Title");
|
||||
// page.setURL("http://share.alfresco.com/");
|
||||
// page.setInternal(true);
|
||||
//
|
||||
// WIKI_PAGE_SERVICE.updateLink(page);
|
||||
//
|
||||
//
|
||||
// // Fetch, and check
|
||||
// page = WIKI_PAGE_SERVICE.getLink(WIKI_SITE.getShortName(), page.getSystemName());
|
||||
// assertEquals("New Title", page.getTitle());
|
||||
// assertEquals("Description", page.getDescription());
|
||||
// assertEquals("http://share.alfresco.com/", page.getURL());
|
||||
// assertEquals(true, page.isInternal());
|
||||
// assertEquals(TEST_USER, page.getCreator());
|
||||
// assertEquals(0, page.getTags().size());
|
||||
//
|
||||
//
|
||||
// // Delete it
|
||||
// WIKI_PAGE_SERVICE.deleteLink(page);
|
||||
//
|
||||
// // Check it went
|
||||
// assertEquals(null, WIKI_PAGE_SERVICE.getLink(WIKI_SITE.getShortName(), page.getSystemName()));
|
||||
// }
|
||||
@Test public void createUpdateDeleteEntry() throws Exception
|
||||
{
|
||||
WikiPageInfo page;
|
||||
|
||||
// Run as the test user instead
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
|
||||
|
||||
|
||||
// Create a link
|
||||
page = WIKI_PAGE_SERVICE.createWikiPage(
|
||||
WIKI_SITE.getShortName(), "Title", "This Is Some Content"
|
||||
);
|
||||
|
||||
|
||||
// Check it
|
||||
assertEquals("Title", page.getSystemName());
|
||||
assertEquals("Title", page.getTitle());
|
||||
assertEquals("This Is Some Content", page.getContents());
|
||||
assertEquals(TEST_USER, page.getCreator());
|
||||
assertEquals(0, page.getTags().size());
|
||||
|
||||
|
||||
// Change it
|
||||
page.setTitle("New Title");
|
||||
page.setContents("This is new content");
|
||||
|
||||
page = WIKI_PAGE_SERVICE.updateWikiPage(page);
|
||||
|
||||
|
||||
// Fetch, and check
|
||||
page = WIKI_PAGE_SERVICE.getWikiPage(WIKI_SITE.getShortName(), page.getSystemName());
|
||||
assertEquals("New Title", page.getSystemName());
|
||||
assertEquals("New Title", page.getTitle());
|
||||
assertEquals("This is new content", page.getContents());
|
||||
assertEquals(TEST_USER, page.getCreator());
|
||||
assertEquals(0, page.getTags().size());
|
||||
|
||||
|
||||
// Delete it
|
||||
WIKI_PAGE_SERVICE.deleteWikiPage(page);
|
||||
|
||||
// Check it went
|
||||
assertEquals(null, WIKI_PAGE_SERVICE.getWikiPage(WIKI_SITE.getShortName(), page.getSystemName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that when we try to write an entry to the
|
||||
|
Reference in New Issue
Block a user