use of com.nixmash.blog.jpa.dto.PostQueryDTO in project nixmash-blog by mintster.
the class PostsRestController method getFullSearchPosts.
// endregion
// region Full Search
@RequestMapping(value = "/search/page/{pageNumber}", produces = "text/html;charset=UTF-8")
public String getFullSearchPosts(@PathVariable int pageNumber, HttpServletRequest request, CurrentUser currentUser) {
PostQueryDTO postQueryDTO = (PostQueryDTO) WebUtils.getSessionAttribute(request, SESSION_POSTQUERYDTO);
String result = null;
List<PostDoc> postDocs = null;
if (postQueryDTO != null) {
try {
postDocs = postDocService.doFullSearch(postQueryDTO);
} catch (UncategorizedSolrException ex) {
logger.info(MessageFormat.format("Bad Query: {0}", postQueryDTO.getQuery()));
return fmService.getNoResultsMessage(postQueryDTO.getQuery());
}
if (postDocs.size() == 0) {
result = fmService.getNoResultsMessage(postQueryDTO.getQuery());
} else {
Slice<PostDoc> postDocSlice = postDocService.doPagedFullSearch(postQueryDTO, pageNumber, POST_PAGING_SIZE);
result = populatePostDocStream(postDocSlice.getContent(), currentUser);
WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_FULLSEARCH_POSTS, postDocSlice.getContent());
}
}
return result;
}
use of com.nixmash.blog.jpa.dto.PostQueryDTO in project nixmash-blog by mintster.
the class SolrPostTests method badSimpleQueryThrowsUncategorizedSolrException.
@Test
public void badSimpleQueryThrowsUncategorizedSolrException() {
int i = 0;
try {
postDocService.doFullSearch(new PostQueryDTO("bad:field"));
} catch (Exception ex) {
i++;
Assert.assertTrue(ex instanceof UncategorizedSolrException);
}
try {
postDocService.doFullSearch(new PostQueryDTO("bad::format"));
} catch (Exception ex) {
i++;
Assert.assertTrue(ex instanceof UncategorizedSolrException);
}
try {
postDocService.doFullSearch(new PostQueryDTO("title:goodquery"));
} catch (UncategorizedSolrException ex) {
i++;
}
Assert.assertEquals(2, i);
}
use of com.nixmash.blog.jpa.dto.PostQueryDTO in project nixmash-blog by mintster.
the class SolrPostTests method fullSearchWithPostType_LINK_ReturnsNone.
@Test
public void fullSearchWithPostType_LINK_ReturnsNone() throws Exception {
PostQueryDTO postQueryDTO = new PostQueryDTO("body:begins", PostType.LINK);
List<PostDoc> postDocs = postDocService.doFullSearch(postQueryDTO);
assertEquals(postDocs.size(), 0);
}
use of com.nixmash.blog.jpa.dto.PostQueryDTO in project nixmash-blog by mintster.
the class SolrPostTests method fullSearchWithPostType_POST_ReturnsAll.
@Test
public void fullSearchWithPostType_POST_ReturnsAll() throws Exception {
PostQueryDTO postQueryDTO = new PostQueryDTO("body:begins", PostType.POST);
List<PostDoc> postDocs = postDocService.doFullSearch(postQueryDTO);
assertEquals(postDocs.size(), 3);
}
use of com.nixmash.blog.jpa.dto.PostQueryDTO in project nixmash-blog by mintster.
the class SolrPostTests method fullSearch.
// region fullSearch tests
// fullSearch tests use the following PostDocument objects
// 100 Ways To Title Something
// This post title begins with 100 : POST
// ------------------------
// 200 Ways To Title Something
// This post title begins with 200 : POST
// ------------------------
// 1000 Ways To Title Something
// This post title begins with 1000 : POST
@Test
public void fullSearch() throws Exception {
PostQueryDTO postQueryDTO = new PostQueryDTO("body:begins", PostType.UNDEFINED);
List<PostDoc> postDocs = postDocService.doFullSearch(postQueryDTO);
assertEquals(postDocs.size(), 3);
}
Aggregations