Source:
<code><START> public void ContentFallbackFalse_PageFallbackTrue_PageSpanish_ViewEnglish404_ViewSpanishContent2And3(final Container container, final Template template) throws Exception{ <END> Config.setProperty(contentFallbackProperty,false); Config.setProperty(pageFallbackProperty,true); final String pageName = "test3Page-"+System.currentTimeMillis(); final HTMLPageAsset pageSpanishVersion = createHtmlPageAsset(template, pageName, spanishLanguage.getId()); createMultiTree(pageSpanishVersion.getIdentifier(), container.getIdentifier()); HttpServletRequest mockRequest = new MockSessionRequest( new MockAttributeRequest(new MockHttpRequest("localhost", "/").request()).request()) .request(); mockRequest .setAttribute(WebKeys.HTMLPAGE_LANGUAGE, String.valueOf(spanishLanguage.getId())); HttpServletRequestThreadLocal.INSTANCE.setRequest(mockRequest); final HttpServletResponse mockResponse = mock(HttpServletResponse.class); String html = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageSpanishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); Assert.assertTrue("ESP = "+html , html.contains("content3content2Spa")); mockRequest = new MockSessionRequest( new MockAttributeRequest(new MockHttpRequest("localhost", "/").request()).request()) .request(); Mockito.when(mockRequest.getParameter("host_id")).thenReturn(site.getIdentifier()); mockRequest.setAttribute(WebKeys.HTMLPAGE_LANGUAGE, "1"); HttpServletRequestThreadLocal.INSTANCE.setRequest(mockRequest); html = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageSpanishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); }</code><technical_language>![Codacy](<LINK_0> Issue found: [A method/constructor explicitly throw java.lang.Exception](<LINK_1></technical_language>

Target:
public void ContentFallbackFalse_PageFallbackTrue_PageSpanish_ViewEnglish404_ViewSpanishContent2And3(final Container container, final Template template) throws Exception{ Config.setProperty(contentFallbackProperty,false); Config.setProperty(pageFallbackProperty,true); final String pageName = "test3Page-"+System.currentTimeMillis(); final HTMLPageAsset pageSpanishVersion = createHtmlPageAsset(template, pageName, spanishLanguage.getId()); createMultiTree(pageSpanishVersion.getIdentifier(), container.getIdentifier()); HttpServletRequest mockRequest = new MockSessionRequest( new MockAttributeRequest(new MockHttpRequest("localhost", "/").request()).request()) .request(); mockRequest .setAttribute(WebKeys.HTMLPAGE_LANGUAGE, String.valueOf(spanishLanguage.getId())); HttpServletRequestThreadLocal.INSTANCE.setRequest(mockRequest); final HttpServletResponse mockResponse = mock(HttpServletResponse.class); String html = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageSpanishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); Assert.assertTrue("ESP = "+html , html.contains("content3Spacontent2Spa")); mockRequest = new MockSessionRequest( new MockAttributeRequest(new MockHttpRequest("localhost", "/").request()).request()) .request(); Mockito.when(mockRequest.getParameter("host_id")).thenReturn(site.getIdentifier()); mockRequest.setAttribute(WebKeys.HTMLPAGE_LANGUAGE, "1"); HttpServletRequestThreadLocal.INSTANCE.setRequest(mockRequest); try { APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageSpanishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); throw new AssertionError("HTMLPageAssetNotFoundException expected"); }catch(HTMLPageAssetNotFoundException e) { } }