### Question:
TransactionalSimplePageService extends AbstractTransactionalEntityService<SimplePage, SimplePageDao> implements SimplePageService { @Override public SimplePage getPageByPathName(String pathName) throws NotFoundException { SimplePage simplePage = this.getDao().getPageByPathName(pathName); if (simplePage == null) { String msg = "SimplePage " + pathName + " not found."; logger.info(msg); throw new NotFoundException(msg); } return simplePage; } 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 testGetPageByPathName() throws NotFoundException { SimplePage samplePage = new SimplePage(NAME, CONTENT, PATH_NAME); when(dao.getPageByPathName(PATH_NAME)).thenReturn(samplePage); SimplePage actualSimplePage = simplePageService.getPageByPathName(PATH_NAME); assertNotNull(actualSimplePage); verify(dao).getPageByPathName(PATH_NAME); }
@Test(expectedExceptions = {NotFoundException.class}) void testGetPageByPathNameFailPageNotFound() throws NotFoundException { when(dao.getPageByPathName(PATH_NAME)).thenReturn(null); SimplePage actualSimplePage = simplePageService.getPageByPathName(PATH_NAME); }