@Test public void createUrl_withId() { final Content content = ContentFixtures.newContent(); Mockito.when(this.contentService.getById(content.getId())).thenReturn(content); final PageUrlParams params = new PageUrlParams().portalRequest(this.portalRequest).id("123456"); final String url = this.service.pageUrl(params); assertEquals("/portal/draft/a/b/mycontent", url); }
@Test public void createUrl_withId_notFound() { final Content content = ContentFixtures.newContent(); Mockito.when(this.contentService.getById(content.getId())) .thenThrow(new ContentNotFoundException(content.getId(), Branch.from("draft"))); final PageUrlParams params = new PageUrlParams().portalRequest(this.portalRequest).id("123456"); final String url = this.service.pageUrl(params); assertEquals( "/portal/draft/context/path/_/error/404?message=Content+with+id+%5B123456%5D+was+not+found+in+branch+%5Bdraft%5D", url); }