use of com.enonic.xp.content.ContentNotFoundException in project xp by enonic.
the class SetPermissionsHandlerTest method testContentNotFoundByPath.
@Test
public void testContentNotFoundByPath() throws Exception {
Mockito.when(this.contentService.getByPath(Mockito.any())).thenThrow(new ContentNotFoundException(ContentPath.ROOT, Branch.from("draft")));
SecurityService securityService = Mockito.mock(SecurityService.class);
addService(SecurityService.class, securityService);
final Optional<? extends Principal> value = Optional.of(User.ANONYMOUS);
Mockito.<Optional<? extends Principal>>when(securityService.getPrincipal(Mockito.any(PrincipalKey.class))).thenReturn(value);
runFunction("/test/SetPermissionsHandlerTest.js", "setPermissionsNotFoundByPath");
}
use of com.enonic.xp.content.ContentNotFoundException in project xp by enonic.
the class GetAttachmentStreamHandlerTest method getByPath_notFound.
@Test
public void getByPath_notFound() throws Exception {
final ContentPath path = ContentPath.from("/a/b/mycontent");
Mockito.when(this.contentService.getByPath(path)).thenThrow(new ContentNotFoundException(path, null));
runFunction("/test/GetAttachmentStreamHandlerTest.js", "getAttachmentStreamByPath_notFound");
}
use of com.enonic.xp.content.ContentNotFoundException in project xp by enonic.
the class GetAttachmentStreamHandlerTest method getById_notFound.
@Test
public void getById_notFound() throws Exception {
final ContentId id = ContentId.from("123456");
Mockito.when(this.contentService.getById(id)).thenThrow(new ContentNotFoundException(id, null));
runFunction("/test/GetAttachmentStreamHandlerTest.js", "getAttachmentStreamById_notFound");
}
use of com.enonic.xp.content.ContentNotFoundException in project xp by enonic.
the class PortalUrlServiceImpl_processHtmlTest method process_unknown_media.
@Test
public void process_unknown_media() {
when(contentService.getById(isA(ContentId.class))).thenAnswer((params) -> {
final ContentId id = params.getArgument(0);
throw new ContentNotFoundException(id, ContextAccessor.current().getBranch());
});
// Process an html text containing a link to an unknown media
final ProcessHtmlParams params = new ProcessHtmlParams().portalRequest(this.portalRequest).value("<a href=\"media://inline/123\">Media</a>");
// Checks that the error 500 page is returned
final String processedHtml = this.service.processHtml(params);
assertEquals("<a href=\"/site/default/draft/context/path/_/error/404?message=Content+with+id+%5B123%5D+was+not+found+in+branch+%5Bdraft%5D\">Media</a>", processedHtml);
}
use of com.enonic.xp.content.ContentNotFoundException in project xp by enonic.
the class PortalUrlServiceImpl_processHtmlTest method process_unknown_image.
@Test
public void process_unknown_image() {
when(contentService.getById(isA(ContentId.class))).thenAnswer((params) -> {
final ContentId id = params.getArgument(0);
throw new ContentNotFoundException(id, ContextAccessor.current().getBranch());
});
// Process an html text containing a link to an unknown media
final ProcessHtmlParams params = new ProcessHtmlParams().portalRequest(this.portalRequest).value("<a href=\"image://123\">Image</a>");
// Checks that the error 500 page is returned
final String processedHtml = this.service.processHtml(params);
assertEquals("<a href=\"/site/default/draft/context/path/_/error/500?message=Image+with+%5B123%5D+id+not+found\">Image</a>", processedHtml);
}
Aggregations