Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
Fix bug in page importer
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Sep 4, 2013
1 parent 0c63cb6 commit 472892f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
Expand Up @@ -116,6 +116,16 @@ public void perform() throws Exception {
data.getAccessPermissions(),
data.getChildren());

// Remove children
while (true) {
NodeContext<ComponentData, ElementState> first = context.getFirst();
if (first != null) {
first.removeNode();
} else {
break;
}
}

// Then save page layout
layoutService.saveLayout(new ContainerAdapter(container), container, context, null);
}
Expand Down
Expand Up @@ -35,7 +35,7 @@
*/
public class TestPageImporter extends AbstractMopServiceTest {

public void testFoo() throws Exception {
public void testInsert() throws Exception {
createSite(SiteType.PORTAL, "bilto");
sync(true);
Page page = new Page();
Expand Down Expand Up @@ -69,4 +69,19 @@ public void testDuplicateChildName() throws Exception {
assertEquals(HierarchyError.ADD_CONCURRENTLY_ADDED_NODE, e.getError());
}
}

public void testOverwrite() throws Exception {
createSite(SiteType.PORTAL, "overwrite");
Page page = new Page();
page.setOwnerId("overwrite");
page.setOwnerType("portal");
page.setName("the_page");
page.getChildren().add(new Container().setStorageName("foo"));
page.getChildren().add(new Container().setStorageName("bar"));
PageImporter importer = new PageImporter(ImportMode.OVERWRITE, page, context.getLayoutService(), context.getPageService());
importer.perform();
sync(true);
importer = new PageImporter(ImportMode.OVERWRITE, page, context.getLayoutService(), context.getPageService());
importer.perform();
}
}
Expand Up @@ -36,42 +36,16 @@
*/
public class TestSiteImporter extends AbstractMopServiceTest {

public void testFoo() throws Exception {

PortalConfig site = new PortalConfig("portal", "foobarjuu");

public void testOverwrite() throws Exception {
PortalConfig site = new PortalConfig("portal", "overwrite");
Container layout = new Container();
layout.getChildren().add(new Container().setStorageName("foo"));
layout.getChildren().add(new Container().setStorageName("bar"));
site.setPortalLayout(layout);

SiteImporter importer = new SiteImporter(ImportMode.OVERWRITE, site, context.getSiteService(), context.getLayoutService());
importer.perform();

sync(true);

importer = new SiteImporter(ImportMode.OVERWRITE, site, context.getSiteService(), context.getLayoutService());
importer.perform();




/*
createSite(SiteType.PORTAL, "bilto");
sync(true);
Page page = new Page();
page.setOwnerId("bilto");
page.setOwnerType("portal");
page.setName("the_page");
Container container = new Container();
container.setStorageName("foo");
page.getChildren().add(container);
PageImporter importer = new PageImporter(ImportMode.INSERT, page, context.getLayoutService(), getPageService());
importer.perform();
PageContext pageContext = getPageService().loadPage(PageKey.parse("portal::bilto::the_page"));
NodeContext<ComponentData, ElementState> ret = (NodeContext<ComponentData, ElementState>)context.getLayoutService().loadLayout(ElementState.model(), pageContext.getLayoutId(), null);
assertEquals(1, ret.getSize());
assertNotNull(ret.get("foo"));
*/
}
}

0 comments on commit 472892f

Please sign in to comment.