template=APILocator.getTemplateAPI().saveTemplate(template, host, sysuser, false);
Folder folder=APILocator.getFolderAPI().createFolders(
"/test_junit/test_"+UUIDGenerator.generateUuid().replaceAll("-", "_"), host, sysuser, false);
HTMLPage page=new HTMLPage();
page.setPageUrl("testpage"+ext);
page.setFriendlyName("testpage"+ext);
page.setTitle("testpage"+ext);
page=APILocator.getHTMLPageAPI().saveHTMLPage(page, template, folder, sysuser, false);
assertTrue(page!=null);
assertTrue(UtilMethods.isSet(page.getInode()));
assertTrue(UtilMethods.isSet(page.getIdentifier()));
List<HTMLPage> pages = APILocator.getHTMLPageAPI().findWorkingHTMLPages(folder);
assertTrue(pages.size()==1);
// now with existing inode/identifier
String existingInode=UUIDGenerator.generateUuid();
String existingIdentifier=UUIDGenerator.generateUuid();
folder=APILocator.getFolderAPI().createFolders(
"/test_junit/test_"+UUIDGenerator.generateUuid().replaceAll("-", "_"), host, sysuser, false);
page=new HTMLPage();
page.setPageUrl("testpage"+ext);
page.setFriendlyName("testpage"+ext);
page.setTitle("testpage"+ext);
page.setInode(existingInode);
page.setIdentifier(existingIdentifier);
page=APILocator.getHTMLPageAPI().saveHTMLPage(page, template, folder, sysuser, false);
assertEquals(existingInode,page.getInode());
assertEquals(existingIdentifier,page.getIdentifier());
pages = APILocator.getHTMLPageAPI().findWorkingHTMLPages(folder);
assertTrue(pages.size()==1);
page=pages.get(0);
assertEquals(existingInode,page.getInode());
assertEquals(existingIdentifier,page.getIdentifier());
// now with existing inode but this time with an update
HibernateUtil.getSession().clear();
String newInode=UUIDGenerator.generateUuid();
page.setInode(newInode);
page.setTitle("other title");
page=APILocator.getHTMLPageAPI().saveHTMLPage(page, template, folder, sysuser, false);
assertEquals(newInode,page.getInode());
assertEquals(existingIdentifier,page.getIdentifier());
assertEquals("other title",page.getTitle());
}