@Test public void getContentWithTemplateNotFound() throws Exception { setupContentAndSite(); this.request.setContentPath(ContentPath.from("/site/somepath/content")); try { this.handler.handle(this.request); fail("Should throw exception"); } catch (final PortalException e) { assertEquals(HttpStatus.NOT_FOUND, e.getStatus()); assertEquals("Page template [my-page] not found", e.getMessage()); } }
@Test public void getContentFound() throws Exception { setupContentAndSite(); setupTemplates(); final PortalResponse portalResponse = PortalResponse.create() .body("component rendered") .header("some-header", "some-value") .status(HttpStatus.OK) .build(); setRendererResult(portalResponse); this.request.setContentPath(ContentPath.from("/site/somepath/content")); final PortalResponse res = this.handler.handle(this.request); assertNotNull(res); assertEquals(HttpStatus.OK, res.getStatus()); assertEquals(MediaType.PLAIN_TEXT_UTF_8, res.getContentType()); assertEquals("some-value", res.getHeaders().get("some-header")); assertEquals("component rendered", res.getBody()); }