use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class SolrPostTests method setupSolr.
@Before
public void setupSolr() {
Query query = new SimpleQuery(new SimpleStringCriteria("doctype:post"));
solrOperations.delete(query);
solrOperations.commit();
List<Post> posts = postService.getAllPublishedPosts();
postDocService.addAllToIndex(posts);
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class SolrPostTests method updatedPost.
private Post updatedPost(String postTitle) throws PostNotFoundException {
Post post = postService.getPostById(10L);
PostDTO postDTO = PostUtils.postToPostDTO(post);
postDTO.setPostTitle(postTitle);
return postService.update(postDTO);
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class AdminSolrPostsControllerTests method updatingPostUpdatesItsSolrPostDocument.
@Test
public void updatingPostUpdatesItsSolrPostDocument() throws Exception {
List<PostDoc> postDocs = postDocService.getAllPostDocuments();
int postDocCount = postDocs.size();
Post post = postService.getPostById(1L);
String originalTitle = post.getPostTitle();
String newTitle = "updatingPostUpdatesItsSolrPostDocument";
mvc.perform(post("/admin/posts/update").param("postId", "1").param("displayType", String.valueOf(post.getDisplayType())).param("postContent", post.getPostContent()).param("postTitle", newTitle).param("twitterCardType", TWITTER_SUMMARY).param("tags", "removingTag1").with(csrf()));
// size of PostDocuments in Solr Index Unchanged
assertEquals(postDocCount, postDocService.getAllPostDocuments().size());
Post verifyPost = postService.getPostById(1L);
assertEquals(verifyPost.getPostTitle(), newTitle);
List<PostDoc> verifyPostDocs = postDocService.getPostsWithUserQuery(newTitle);
assertEquals(verifyPostDocs.size(), 1);
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class AdminSolrPostsControllerTests method setup.
// endregion
// region Before / After
@Before
public void setup() throws ServletException {
// ObjectMapper objectMapper = new ObjectMapper();
// JacksonTester.initFields(this, objectMapper);
mvc = webAppContextSetup(wac).apply(springSecurity()).build();
Query query = new SimpleQuery(new SimpleStringCriteria("doctype:post"));
solrOperations.delete(query);
solrOperations.commit();
List<Post> posts = postService.getAllPublishedPosts();
postDocService.addAllToIndex(posts);
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class PostDocServiceImpl method getMoreLikeThisPostsFromPostDocs.
@Transactional(readOnly = true)
@Override
public List<Post> getMoreLikeThisPostsFromPostDocs(List<PostDoc> postDocs) {
List<Post> posts = new ArrayList<>();
String result = StringUtils.EMPTY;
for (int i = 0; i < applicationSettings.getMoreLikeThisNum(); i++) {
try {
PostDoc postDoc = postDocs.get(i);
posts.add(postService.getPostById(Long.parseLong(postDoc.getPostId())));
} catch (PostNotFoundException | IndexOutOfBoundsException e) {
if (e.getClass().equals(PostNotFoundException.class))
logger.info("MoreLikeThis PostDoc {} to Post with title \"{}\" NOT FOUND", postDocs.get(i).getPostId(), postDocs.get(i).getPostTitle());
else {
logger.info("EXCEPTION: AppSetting.MoreLikeThisNum > post count");
return null;
}
}
}
return posts;
}
Aggregations