@Test public void testIdNotFound() throws Exception { this.request.setEndpointPath("/_/attachment/download/1/logo.png"); try { this.handler.handle(this.request); fail("Should throw exception"); } catch (final PortalException e) { assertEquals(HttpStatus.NOT_FOUND, e.getStatus()); assertEquals("Content with id [1] not found", e.getMessage()); } }
@Test public void testNameNotFound() throws Exception { this.request.setEndpointPath("/_/attachment/download/123456/other.png"); try { this.handler.handle(this.request); fail("Should throw exception"); } catch (final PortalException e) { assertEquals(HttpStatus.NOT_FOUND, e.getStatus()); assertEquals("Attachment [other.png] not found for [/path/to/content]", e.getMessage()); } }
@Test public void testNotValidUrlPattern() throws Exception { this.request.setEndpointPath("/_/attachment/"); try { this.handler.handle(this.request); fail("Should throw exception"); } catch (final PortalException e) { assertEquals(HttpStatus.NOT_FOUND, e.getStatus()); assertEquals("Not a valid attachment url pattern", e.getMessage()); } }