Source:
<code><START> public void shouldRenderUsingOtherSiteContainerAndNotAdvanceTemplate() throws Exception { <END> final Host defaultHost = APILocator.getHostAPI().findDefaultHost(APILocator.systemUser(), true); final FileAssetContainer container = createFileContainer(defaultHost); final TemplateLayout templateLayout = new TemplateLayoutDataGen() .withContainer(" .next(); final Contentlet contentlet = new ThemeDataGen().nextPersisted(); Template template = new TemplateDataGen() .title("PageContextBuilderTemplate"+System.currentTimeMillis()) .host(site) .drawedBody(templateLayout) .theme(contentlet) .nextPersisted(); PublishFactory.publishAsset(template, systemUser, false, false); final String pageName = "testPage-"+System.currentTimeMillis(); final HTMLPageAsset pageEnglishVersion = createHtmlPageAsset(template, pageName, 1); createMultiTree(pageEnglishVersion.getIdentifier(), container.getIdentifier(), "1"); final HttpServletRequest mockRequest = createHttpServletRequest(pageEnglishVersion); Mockito.when(mockRequest.getParameter(WebKeys.PAGE_MODE_PARAMETER)).thenReturn(PageMode.LIVE.toString()); final HttpServletResponse mockResponse = mock(HttpServletResponse.class); final HttpSession session = createHttpSession(mockRequest); Mockito.when(session.getAttribute(WebKeys.VISITOR)).thenReturn(null); Mockito.when(session.getAttribute(WebKeys.CMS_USER)).thenReturn(systemUser); final String html = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageEnglishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); Assert.assertTrue(html.contains("content2content1")); }</code><technical_language>![Codacy](<LINK_0> Issue found: [A method/constructor explicitly throw java.lang.Exception](<LINK_1></technical_language>

Target:
public void shouldRenderUsingOtherSiteContainerAndNotAdvanceTemplate() throws Exception { final Host defaultHost = APILocator.getHostAPI().findDefaultHost(APILocator.systemUser(), true); final FileAssetContainer container = createFileContainer(defaultHost); final TemplateLayout templateLayout = new TemplateLayoutDataGen() .withContainer(" .next(); final Contentlet contentlet = new ThemeDataGen().nextPersisted(); final Template template = new TemplateDataGen() .title("PageContextBuilderTemplate"+System.currentTimeMillis()) .host(site) .drawedBody(templateLayout) .theme(contentlet) .nextPersisted(); PublishFactory.publishAsset(template, systemUser, false, false); final String pageName = "testPage-"+System.currentTimeMillis(); final HTMLPageAsset pageEnglishVersion = createHtmlPageAsset(template, pageName, 1); createMultiTree(pageEnglishVersion.getIdentifier(), container.getIdentifier(), "1"); final HttpServletRequest mockRequest = createHttpServletRequest(pageEnglishVersion); Mockito.when(mockRequest.getParameter(WebKeys.PAGE_MODE_PARAMETER)).thenReturn(PageMode.LIVE.toString()); final HttpServletResponse mockResponse = mock(HttpServletResponse.class); final HttpSession session = createHttpSession(mockRequest); Mockito.when(session.getAttribute(WebKeys.VISITOR)).thenReturn(null); Mockito.when(session.getAttribute(WebKeys.CMS_USER)).thenReturn(systemUser); final String html = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageEnglishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); Assert.assertTrue(html.contains("content2content1")); }