Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.Topic


        lastReadPostService.markTopicAsRead(newbie.getTopic());
        return new ModelAndView(this.redirectToPageWithPost(newbie.getId()));
    }

    private Post replyToTopicWithLockHandling(PostDto postDto, Long topicId) throws NotFoundException {
        Topic topic = topicFetchService.get(topicId);
        long branchId = topic.getBranch().getId();
        for (int i = 0; i < UserController.LOGIN_TRIES_AFTER_LOCK; i++) {
            try {
                return topicModificationService.replyToTopic(
                        postDto.getTopicId(), postDto.getBodyText(), branchId);
            } catch (HibernateOptimisticLockingFailureException e) {
View Full Code Here


        Assert.assertTrue(!searchResultPage.hasContent(), "Search result must be empty.");
    }

    @Test(dataProvider = "parameterFullPhraseSearch")
    public void testFullPhraseSearch(String content) {
        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.setTitle(content);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));
        configureMocks(content, content);

        Page<Topic> searchResultPage = topicSearchDao.searchByTitleAndContent(
                content, DEFAULT_PAGE_REQUEST, Arrays.asList(expectedTopic.getBranch().getId()));

        Assert.assertTrue(searchResultPage.hasContent(), "Search result must not be empty.");
        for (Topic topic : searchResultPage.getContent()) {
            Assert.assertEquals(expectedTopic.getTitle(), topic.getTitle(),
                    "Content from the index should be the same as in the database.");
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testFullPhraseSearchPageNumberTooLow() {
        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.setTitle(TOPIC_CONTENT);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));
        configureMocks(TOPIC_CONTENT, TOPIC_CONTENT);

        PageRequest pageRequest = new PageRequest("-1", PAGE_SIZE);
        Page<Topic> searchResultPage = topicSearchDao.searchByTitleAndContent(
                TOPIC_CONTENT, pageRequest, Arrays.asList(expectedTopic.getBranch().getId()));

        Assert.assertEquals(searchResultPage.getNumber(), 1);
        Assert.assertTrue(searchResultPage.hasContent(), "Search result must not be empty.");
        for (Topic topic : searchResultPage.getContent()) {
            Assert.assertEquals(expectedTopic.getTitle(), topic.getTitle(),
                    "Content from the index should be the same as in the database.");
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testFullPhraseSearchPageNumberTooBig() {
        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.setTitle(TOPIC_CONTENT);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));
        configureMocks(TOPIC_CONTENT, TOPIC_CONTENT);

        PageRequest pageRequest = new PageRequest("1000", 50);
        Page<Topic> searchResultPage =
                topicSearchDao.searchByTitleAndContent(TOPIC_CONTENT, pageRequest,
                        Arrays.asList(expectedTopic.getBranch().getId()));

        Assert.assertEquals(searchResultPage.getNumber(), 1);
        Assert.assertTrue(searchResultPage.hasContent(), "Search result must not be empty.");
        for (Topic topic : searchResultPage.getContent()) {
            Assert.assertEquals(expectedTopic.getTitle(), topic.getTitle(),
                    "Content from the index should be the same as in the database.");
        }
    }
View Full Code Here

        }
    }

    @Test(dataProvider = "parameterFullPhraseSearch")
    public void testPostContentSearch(String content) {
        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.getLastPost().setPostContent(content);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));
        configureMocks(content, content);

        Page<Topic> searchResultPage = topicSearchDao.searchByTitleAndContent(
                content, DEFAULT_PAGE_REQUEST, Arrays.asList(expectedTopic.getBranch().getId()));

        Assert.assertTrue(searchResultPage.hasContent(), "Search result must not be empty.");
        for (Topic topic : searchResultPage.getContent()) {
            Assert.assertEquals(expectedTopic.getTitle(), topic.getTitle(),
                    "Content from the index should be the same as in the database.");
        }
    }
View Full Code Here

                append(firstPiece).
                append(delimeter).
                append(secondPiece).
                toString();

        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.setTitle(content);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));

        for (String piece : Arrays.asList(firstPiece, secondPiece)) {
            configureMocks(piece, piece);

            Page<Topic> searchResultPage = topicSearchDao.searchByTitleAndContent(
                    piece, DEFAULT_PAGE_REQUEST, Arrays.asList(expectedTopic.getBranch().getId()));

            Assert.assertTrue(searchResultPage.hasContent(), "Search result must not be empty.");
        }
    }
View Full Code Here

        };
    }

    @Test(dataProvider = "parameterIncorrectPhraseSearch")
    public void testIncorrectPhraseSearch(String correct, String incorrect) {
        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.setTitle(correct);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));
        configureMocks(incorrect, incorrect);

        Page<Topic> searchResultPage = topicSearchDao.searchByTitleAndContent(
                incorrect, DEFAULT_PAGE_REQUEST, Arrays.asList(expectedTopic.getBranch().getId()));

        Assert.assertTrue(!searchResultPage.hasContent(), "Search result must be empty.");
    }
View Full Code Here

        };
    }

    @Test(dataProvider = "parameterSearchByRoot")
    public void testSearchByRoot(String word, String wordWithSameRoot) {
        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.setTitle(word);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));
        configureMocks(wordWithSameRoot, wordWithSameRoot);

        Page<Topic> searchResultPage = topicSearchDao.searchByTitleAndContent(
                wordWithSameRoot, DEFAULT_PAGE_REQUEST, Arrays.asList(expectedTopic.getBranch().getId()));
        Assert.assertTrue(searchResultPage.hasContent(), "Search result must not be empty.");
    }
View Full Code Here

        };
    }

    @Test(dataProvider = "parameterSearchByBbCodes")
    public void testSearchByBbCodes(String content, String bbCode) {
        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.getLastPost().setPostContent(content);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));
        configureMocks(bbCode, bbCode);

        Page<Topic> searchResultPage = topicSearchDao.searchByTitleAndContent(
                bbCode, DEFAULT_PAGE_REQUEST, Arrays.asList(expectedTopic.getBranch().getId()));
        Assert.assertTrue(!searchResultPage.hasContent(), "Search result must be empty.");
    }
View Full Code Here

        };
    }

    @Test(dataProvider = "parameterSearchByBbCodesContent")
    public void testSearchByBbCodesContent(String content, String bbCodeContent) {
        Topic expectedTopic = PersistedObjectsFactory.getDefaultTopic();
        expectedTopic.getLastPost().setPostContent(content);

        saveAndFlushIndexes(Arrays.asList(expectedTopic));
        configureMocks(bbCodeContent, bbCodeContent);

        Page<Topic> searchResultPage = topicSearchDao.searchByTitleAndContent(
                bbCodeContent, DEFAULT_PAGE_REQUEST, Arrays.asList(expectedTopic.getBranch().getId()));
        Assert.assertTrue(searchResultPage.hasContent(), "Search result must not be empty.");
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.Topic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.