@Test
@Transactional(readOnly = false)
@Rollback(true)
public void createPersonPageForUser_validUser(){
Page page = repository.createPersonPageForUser(user, defaultPageTemplate);
assertSame(user, page.getOwner());
assertEquals(page.getName(), defaultPageTemplate.getName());
assertNull(page.getParentPage());
assertEquals(2, page.getSubPages().size());
assertNotNull(page.getRenderSequence());
assertNotNull(page.getPageLayout());
assertEquals("person_profile", page.getPageLayout().getCode());
assertEquals(1, page.getRegions().size());
assertEquals(PageType.PERSON_PROFILE, page.getPageType());
Page subPage1 = page.getSubPages().get(0);
Page subPage2 = page.getSubPages().get(1);
assertEquals("Widgets on sub page 1", 2, subPage1.getRegions().get(0).getRegionWidgets().size());
assertEquals("Widgets on sub page 2", 1, subPage2.getRegions().get(0).getRegionWidgets().size());
assertEquals("Regions on sub page 1", 1, subPage1.getRegions().size());
assertEquals("Regions on sub page 2", 1, subPage2.getRegions().size());
assertNull("no sub pages of sub page 1", subPage1.getSubPages());
assertNull("no sub pages of sub page 2", subPage2.getSubPages());
assertEquals("sub page 1 refers to parent page", page.getEntityId(), subPage1.getParentPage().getEntityId());
assertEquals("sub page 2 refers to parent page", page.getEntityId(), subPage2.getParentPage().getEntityId());
assertEquals("sub page 1 regions refers to sub page 1", subPage1.getEntityId(), subPage1.getRegions().get(0).getPage().getEntityId());
assertEquals("sub page 2 regions refers to sub page 2", subPage2.getEntityId(), subPage2.getRegions().get(0).getPage().getEntityId());
assertEquals("sub page 1 has one column layout", "columns_1", subPage1.getPageLayout().getCode());
assertEquals("sub page 2 has one column layout", "columns_1", subPage2.getPageLayout().getCode());
assertEquals(PageType.SUB_PAGE, subPage1.getPageType());
assertEquals(defaultPageTemplate.getSubPageTemplates().get(0).getName(), subPage1.getName());
assertEquals(PageType.SUB_PAGE, subPage2.getPageType());
assertEquals(defaultPageTemplate.getSubPageTemplates().get(1).getName(), subPage2.getName());
assertSame(user, subPage1.getOwner());
assertSame(user, subPage2.getOwner());
assertNotNull(subPage1.getRenderSequence());
assertNotNull(subPage2.getRenderSequence());
}