Package org.encuestame.persistence.domain.survey

Examples of org.encuestame.persistence.domain.survey.Poll


        this.userAccount.getAccount(), this.question, new Date());

    final TweetPoll tweetPoll2 = createPublishedTweetPoll(
        this.userAccount.getAccount(), this.question, new Date());

    final Poll poll = createDefaultPoll(question, this.userAccount);

    final Survey survey = createDefaultSurvey(this.user, " ",
        this.initDate.toDate());

    // SocialAccount
View Full Code Here


         getCommentsOperations().saveOrUpdate(comments);
     }

     /** Test Poll. **/
     public void testPoll(){
         final Poll poll = new Poll();
         final Question question = createQuestion("Where do you live?", "");
         final UserAccount user = createUserAccount("diana", createAccount());
         final PollFolder pollFolder = createPollFolder("My polls", user);
         poll.setPollCompleted(null);
         poll.setCreateDate(Calendar.getInstance().getTime());
         poll.setEndDate(Calendar.getInstance().getTime());
         poll.setUpdatedDate(Calendar.getInstance().getTime());
         poll.setPollHash(RandomStringUtils.randomAlphanumeric(5));
         poll.setQuestion(question);
         poll.setEditorOwner(user);
         poll.setPublish(Boolean.TRUE);
         poll.setPollFolder(pollFolder);
         poll.setUpdatedDate(null);
         getPollDao().saveOrUpdate(poll);
     }
View Full Code Here

    /**
     * Test retrieve Poll By Id.
    **/
    @Test
    public void testGetPollById(){
        final Poll getpoll = getPollDao().getPollById(this.poll.getPollId());
        assertNotNull(getpoll);
    }
View Full Code Here

    /**
    * Test retrieve Results Poll By PollId.
    **/
    @Test
    public void testRetrievePollResultsById(){
        final Poll poll = createPoll(myDate.getTime(), this.question, "FDKdsadsads125", this.userAccount, Boolean.TRUE, Boolean.TRUE);
        final Question quest = createQuestion("Do you like futboll", "Yes/No");
        final QuestionAnswer qansw = createQuestionAnswer("Yes", quest, "2020");
        final QuestionAnswer qansw2 =createQuestionAnswer("No", quest, "2021");
        createPollResults(qansw2, poll);
        createPollResults(qansw2, poll);
        createPollResults(qansw2, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        final List<Object[]> polli = getPollDao().retrieveResultPolls(poll.getPollId(), qansw.getQuestionAnswerId());
        assertEquals("Should be equals", 2, polli.size());
    }
View Full Code Here

     * Test Get Poll By User
     */
    @Test
    public void testGetPollByIdandUserId(){
        assertNotNull(this.poll);
        final Poll poll = getPollDao().getPollById(this.poll.getPollId(), this.userAccount);
        assertNotNull(poll);
        assertEquals("Should be equals", this.poll.getPollId(), poll.getPollId());
    }
View Full Code Here

     */
    @Test
    public void testGetPollsByPollFolderId() throws EnMeNoResultsFoundException{
         assertNotNull(this.pollFolder);
         assertNotNull(poll);
         final Poll addPoll = addPollToFolder(this.pollFolder.getId(), this.userAccount, this.poll.getPollId());
         assertNotNull(addPoll);
         final List<Poll> pfolder = getPollDao().getPollsByPollFolderId(this.userAccount, this.pollFolder);
         assertEquals("Should be equals", 1, pfolder.size());
    }
View Full Code Here

    /**
     * Test get total polls by user.
     */
    @Test
    public void testGetTotalPollsbyUser() {
        final Poll myPoll = createPoll(myDate.getTime(), this.question,
                "FDK445", this.userAccount, Boolean.TRUE, Boolean.TRUE);
        assertNotNull(myPoll);
        final Long totalPolls = getPollDao().getTotalPollsbyUser(
                this.userAccount, Boolean.TRUE);
       Assert.assertEquals("Should be", 2, totalPolls.intValue());
View Full Code Here

    public void testGetTotalPollsByHashTag() {
        final HashTag hashtag1 = createHashTag("roses");
        final HashTag hashtag2 = createHashTag("red");
        final HashTag hashtag3 = createHashTag("flowers");

        final Poll poll1 = createPoll(myDate.getTime(), this.question,
                "DPMU12", this.userAccount, Boolean.TRUE, Boolean.TRUE);
        poll1.getHashTags().add(hashtag1);
        poll1.getHashTags().add(hashtag2);
        poll1.getHashTags().add(hashtag3);
        getPollDao().saveOrUpdate(poll1);

        final Poll poll2 = createPoll(myDate.getTime(), this.question,
                "DPMU13", this.userAccount, Boolean.TRUE, Boolean.TRUE);

        poll2.getHashTags().add(hashtag3);
        poll2.getHashTags().add(hashtag1);
        getPollDao().saveOrUpdate(poll2);

        final Poll poll3 = createPoll(myDate.getTime(), this.question,
                "DPMU14", this.userAccount, Boolean.TRUE, Boolean.TRUE);
        poll3.getHashTags().add(hashtag3);
        getPollDao().saveOrUpdate(poll3);
        final List<Poll> totalUsagePoll = getPollDao().getPollByHashTagName(
                hashtag1.getHashTag(), this.START, this.MAX_RESULTS, TypeSearchResult.HASHTAG, SearchPeriods.ALLTIME);

        Assert.assertEquals("Should be", 2, totalUsagePoll.size());
View Full Code Here

    public void testGetPollsbyHashTagNameAndDateRange(){
        final Calendar myDate = Calendar.getInstance();
        final Question myQuestion = createQuestion("what are your favorite flowers?", this.userAccount.getAccount());
        final HashTag hashtag1 = createHashTag("roses");

        final Poll poll1 = createPoll(myDate.getTime(), myQuestion,
                "DPMU12", this.userAccount, Boolean.TRUE, Boolean.TRUE);
        poll1.getHashTags().add(hashtag1);
        getPollDao().saveOrUpdate(poll1);
        myDate.add(Calendar.DATE, -2);


        final Question myQuestion2 = createQuestion("What was your best gift for valentines day?", this.userAccount.getAccount());
        final Poll poll2 = createPoll(myDate.getTime(), myQuestion2,
                "DPMU19", this.userAccount, Boolean.TRUE, Boolean.TRUE);
        poll2.getHashTags().add(hashtag1);
        getPollDao().saveOrUpdate(poll2);
        final List<Poll> getTotalPollsbyHashTag = getPollDao().getPollsbyHashTagNameAndDateRange(hashtag1.getHashTag(), SearchPeriods.SEVENDAYS);
        Assert.assertEquals("Should be", 2, getTotalPollsbyHashTag.size());
    }
View Full Code Here

    /**
     * Test for recovering all poll results by answer.
     */
    @Test
    public void testRetrievePollResultsByAnswer(){
        final Poll poll = createPoll(myDate.getTime(), this.question, "FDKL1", this.userAccount, Boolean.TRUE, Boolean.TRUE);
        final Question quest = createQuestion("Do you like futboll", "Yes/No");
        final QuestionAnswer qansw = createQuestionAnswer("Yes", quest, "2020");
        final QuestionAnswer qansw2 =createQuestionAnswer("No", quest, "2021");
        // Create poll results for QuestionAnswer2 = 3
        createPollResults(qansw2, poll);
        createPollResults(qansw2, poll);
        createPollResults(qansw2, poll);
        // Create poll results for QuestionAnswer = 3
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);
        createPollResults(qansw, poll);

        final List<Object[]> pollsResultsbyAnswer = getPollDao().retrieveResultPollsbyAnswer(poll.getPollId(), qansw.getQuestionAnswerId());
        assertEquals("Should be equals", 1, pollsResultsbyAnswer.size());


        for (Object[] objects : pollsResultsbyAnswer) {
            if (objects[0] ==  qansw.getQuestionAnswerId()) {
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.survey.Poll

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.