@Test
public void addNewDefaultPage() {
final Long EXPECTED_RENDER_SEQUENCE = 1L;
Page expectedPage = new Page();
expectedPage.setName(defaultPageName);
expectedPage.setOwner(user);
expectedPage.setPageLayout(pageLayout);
expectedPage.setRenderSequence(EXPECTED_RENDER_SEQUENCE);
expectedPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));
expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
expect(pageRepository.save(expectedPage)).andReturn(expectedPage);
expect(pageRepository.getAllPages(user.getId())).andReturn(new ArrayList<Page>());
replay(pageLayoutRepository);
replay(pageRepository);
Page newPage = pageService.addNewDefaultPage(user, PAGE_LAYOUT_CODE);
assertThat(newPage.getRenderSequence(), is(EXPECTED_RENDER_SEQUENCE));
assertThat(newPage.getName(), is(defaultPageName));
assertThat(newPage.getRegions().size(), is(pageLayout.getNumberOfRegions().intValue()));
verify(pageLayoutRepository);
verify(pageRepository);
}