### Question:
TransactionalSimplePageService extends AbstractTransactionalEntityService<SimplePage, SimplePageDao> implements SimplePageService { @Override @PreAuthorize("hasPermission(#simplePageInfoContainer.getId(), 'USER', 'ProfilePermission.CREATE_FORUM_FAQ')") public void updatePage(SimplePageInfoContainer simplePageInfoContainer) throws NotFoundException { SimplePage simplePage = get(simplePageInfoContainer.getId()); if (simplePage == null) { String message = "Simple page with id = " + simplePageInfoContainer.getId() + " not found."; logger.info(message); throw new NotFoundException(message); } simplePage.setName(simplePageInfoContainer.getName()); simplePage.setContent(simplePageInfoContainer.getContent()); this.getDao().saveOrUpdate(simplePage); logger.info("Simple page with id = " + simplePage.getId() + " update."); } TransactionalSimplePageService(SimplePageDao simplePageDao,
                                          GroupDao groupDao,
                                          SecurityService securityService); @Override @PreAuthorize("hasPermission(#simplePageInfoContainer.getId(), 'USER', 'ProfilePermission.CREATE_FORUM_FAQ')") void updatePage(SimplePageInfoContainer simplePageInfoContainer); @Override SimplePage getPageByPathName(String pathName); @PreAuthorize("hasPermission(#userCreator.id, 'USER', 'ProfilePermission.CREATE_FORUM_FAQ')") @Override SimplePage createPage(SimplePage simplePage, JCUser userCreator);  }### Answer:
@Test void testUpdate() throws NotFoundException { SimplePage simplePage = new SimplePage(NAME, CONTENT, PATH_NAME); simplePage.setId(ID); String updatedName = "new name"; String updatedContent = "new content"; SimplePageInfoContainer simplePageInfoContainer = new SimplePageInfoContainer(ID, updatedName, updatedContent); when(dao.isExist(simplePage.getId())).thenReturn(true); when(dao.get(simplePage.getId())).thenReturn(simplePage); simplePageService.updatePage(simplePageInfoContainer); assertEquals(simplePage.getName(), updatedName); assertEquals(simplePage.getContent(), updatedContent); verify(dao).get(ID); verify(dao).isExist(ID); }
@Test(expectedExceptions = {NotFoundException.class}) void testUpdateFailPageNotFound() throws NotFoundException { String updatedName = "new name"; String updatedContent = "new content"; SimplePageInfoContainer simplePageInfoContainer = new SimplePageInfoContainer(ID, updatedName, updatedContent); when(dao.isExist(ID)).thenReturn(false); when(dao.get(ID)).thenReturn(null); simplePageService.updatePage(simplePageInfoContainer); }