Package org.encuestame.persistence.domain.tweetpoll

Examples of org.encuestame.persistence.domain.tweetpoll.TweetPoll


            throws NoSuchAlgorithmException, UnsupportedEncodingException {
        int j = 0;
        final String randomTweetContent = RandomStringUtils
                .randomAlphanumeric(6);
        final Question tpollQuestion = createQuestionRandom();
        final TweetPoll tweetPoll = createPublishedTweetPoll(tweetOwner,
                tpollQuestion);
        tweetPoll.setCompleted(isCompleted);
        tweetPoll.setFavourites(isFavourites);
        tweetPoll.setScheduleTweetPoll(isScheduled);
        tweetPoll.setPublishTweetPoll(isPublished);
        tweetPoll.setCreateDate(randomDate);
        getTweetPoll().saveOrUpdate(tweetPoll);
        return tweetPoll;
    }
View Full Code Here


        request = new MockHttpServletRequest();
        request.addPreferredLocale(Locale.ENGLISH);
        this.question = createDefaultQuestion("Default Question ");

    final TweetPoll tp = createDefaultTweetPollPublicated(Boolean.TRUE,
        Boolean.TRUE, Boolean.FALSE,
        getSpringSecurityLoggedUserAccount(), question,
        DateUtil.getCalendarDate().getTime());

    createNotification2(tp.getQuestion().getQuestion(),
        getSpringSecurityLoggedUserAccount().getAccount(),
        NotificationEnum.TWEETPOL_CREATED, false,
        DateUtil.getCalendarDate().getTime());

    DateUtil.getCalendarDate().add(Calendar.HOUR, -3);
    final TweetPoll tp1 = createDefaultTweetPollPublicated(Boolean.TRUE,
        Boolean.TRUE, Boolean.FALSE,
        getSpringSecurityLoggedUserAccount(), question, DateUtil
            .getCalendarDate().getTime());

    createNotification2(tp1.getQuestion().getQuestion(),
        getSpringSecurityLoggedUserAccount().getAccount(),
        NotificationEnum.TWEETPOL_CREATED, false,
        DateUtil.getCurrentCalendarDate());

    DateUtil.getCalendarDate().add(Calendar.DATE, -1);
View Full Code Here

        Assert.assertEquals(4, list.size());
        // Parameter onlyReaded is false.. so return all notifications(readed or not).
        final List<UtilNotification> list2 = this.streamService.retrieveLastNotifications(10, false, this.request);
        //TODO: review, this method should retrieve 0 items.
        Assert.assertEquals(list2.size(), 4);
    final TweetPoll tp4 = createDefaultTweetPollPublicated(Boolean.TRUE,
        Boolean.TRUE, Boolean.FALSE,
        getSpringSecurityLoggedUserAccount(), question, DateUtil
            .getCalendarDate().getTime());

    createNotification2(tp4.getQuestion().getQuestion(),
        getSpringSecurityLoggedUserAccount().getAccount(),
        NotificationEnum.TWEETPOL_CREATED, true, DateUtil
            .getCalendarDate().getTime());

    final List<UtilNotification> list3 = this.streamService.retrieveLastNotifications(10, true, this.request);
View Full Code Here

      final SearchPeriods periods, final TypeSearchResult itemType) {
    ItemGeoLocationBean itemGeoBean = new ItemGeoLocationBean();
    List<ItemGeoLocationBean> itemsGeoBeanList = new ArrayList<ItemGeoLocationBean>();
    for (Object[] objects : itemsByGeo) {

      final TweetPoll pollchecked = getTweetPollDao()
          .checkIfTweetPollHasHashTag(tagName, periods,
              (Long) objects[0]);
      if (pollchecked == null) {
        log.debug("Tweetpoll with this hashtag has not been found."
                + objects[0]);
View Full Code Here

    final double latitudeInRadians = EnMeUtils
        .convertDegreesToRadians(latitude);
    final double longitudeInRadians = EnMeUtils
        .convertDegreesToRadians(longitude);
    List<TweetPollSavedPublishedStatus> tpSavedPublished = new ArrayList<TweetPollSavedPublishedStatus>();
    TweetPoll itemTweetPoll;
    Poll itemPoll;

    if (itemType.equals(TypeSearchResult.ALL)) {
      // POLL
      List<Object[]> distanceFromOriginTweetPoll = this
          .getItemsByDistanceFromOrigin(range, maxItem,
              TypeSearchResult.TWEETPOLL, longitudeInRadians,
              latitudeInRadians, this.earth_radius, period);
      log.debug("Retrieved items by distance -->"
          + distanceFromOriginTweetPoll.size());

      for (Object[] objects : distanceFromOriginTweetPoll) {
        itemTweetPoll = this.getTweetPollById((Long) objects[0]);
        tpSavedPublished = getTweetPollDao().getLinksByTweetPoll(
            itemTweetPoll, null, null, TypeSearchResult.TWEETPOLL);

        log.debug("Tweetpolls published on social networks -->"
            + itemTweetPoll.getTweetPollId());

        socialGeoBean.addAll(ConvertDomainBean
            .convertTweetPollSavedPublishedToSocialGeoLocationBean(
                tpSavedPublished,
                itemTweetPoll.getTweetPollId(), itemType,
                (Float) objects[1], (Float) objects[2],
                objects[3].toString(), (Double) objects[4]));
      }
      // POLL
      List<Object[]> distanceFromOriginPoll = this
View Full Code Here

        "html");

    final Question question2 = createQuestion("Why the sea is blue ?",
        "html");
    final DateTime dt = new DateTime();
    final TweetPoll tp = createTweetPollPublicated(true, true, dt.toDate(),
        this.userAccount, question1);
    tp.setScheduleTweetPoll(Boolean.TRUE);
    getTweetPoll().saveOrUpdate(tp);
    final TweetPoll tp2 = createTweetPollPublicated(true, true,
        dt.toDate(), this.userAccount, question2);
    tp2.setScheduleTweetPoll(Boolean.TRUE);
    getTweetPoll().saveOrUpdate(tp2);
    final TweetPollSearchBean tpbean = createTweetpollSearchBean(
        Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, " ",
        "7", 10, 0, TypeSearch.LASTWEEK);
    final List<SearchBean> tpLastWeek = getTweetPollService()
View Full Code Here

  public void testUpdateTweetPoll() throws EnMeNoResultsFoundException {

    final Question question1 = createQuestion("Why the sea is salad? 3",
        "html");
    final DateTime dt = new DateTime();
    final TweetPoll tp = createTweetPollPublicated(true, true, dt.toDate(),
        this.userAccount, question1);

    final QuestionBean questionBean = createUnitQuestionBean(
        " Mi nueva pregunta", null, null, null);
    final TweetPollBean tpBeanToUpdate = createTweetPoll(Boolean.FALSE,
        Boolean.FALSE, Boolean.FALSE, new Date(), Boolean.FALSE,
        Boolean.FALSE, Boolean.FALSE, new Date(), " ",
        this.userAccount.getUid(), questionBean, "twitterAccoint",
        tp.getTweetPollId());

    final TweetPoll tpupdate = getTweetPollService().updateTweetPoll(
        tpBeanToUpdate);

  }
View Full Code Here

    final HashTag tag2 = createHashTag("suspense");
    final String tagName = tag1.getHashTag();
    final Long questionId = myFirstQuestion.getQid();

    // FIRST TP
    final TweetPoll tweetPoll1 = createPublishedTweetPoll(
        this.userAccount.getAccount(), myFirstQuestion, new Date());
    tweetPoll1.setTweetPollFolder(tpFolder);
    tweetPoll1.getHashTags().add(tag1);
    tweetPoll1.getHashTags().add(tag2);

    getTweetPoll().saveOrUpdate(tweetPoll1);

    // Create QuestionsAnswers
    final TweetPoll myTweetpoll = tweetPoll1;

    final QuestionAnswer questAns1 = createQuestionAnswer("yes",
        myFirstQuestion, "1234555");
    final QuestionAnswer questAns2 = createQuestionAnswer("no",
        myFirstQuestion, "12346666");
    final QuestionAnswer questAns3 = createQuestionAnswer("no",
        myFirstQuestion, "123466667");

    // Tweetpoll switch
    final TweetPollSwitch tps1 = createTweetPollSwitch(questAns1,
        tweetPoll1);
    final TweetPollSwitch tps2 = createTweetPollSwitch(questAns2,
        tweetPoll1);

    // TweetPoll Result
    createTweetPollResult(tps1, "192.168.0.1");
    createTweetPollResult(tps1, "192.168.0.2");
    createTweetPollResult(tps2, "192.168.0.3");

    // Social Accounts & Providers
    final SocialAccount socialAccount = createDefaultSettedSocialAccount(this.userAccount);

    final List<SocialProvider> providers = new ArrayList<SocialProvider>();
    providers.add(SocialProvider.FACEBOOK);
    providers.add(SocialProvider.LINKEDIN);

    // Create TweetPollSavedPublished - Social Links
    createTweetPollSavedPublishStatus(tweetPoll1, socialAccount,
        SocialProvider.FACEBOOK);
    createTweetPollSavedPublishStatus(tweetPoll1, socialAccount,
        SocialProvider.TWITTER);

    /* ***** BEFORE ***** */

    // Retrieve all TwweetpollSwitch associated
    final List<TweetPollSwitch> tpSwitchs = getTweetPoll()
        .getListAnswersByTweetPollAndDateRange(tweetPoll1);

    for (TweetPollSwitch tweetPollSwitch : tpSwitchs) {
      final List<TweetPollResult> tpollsResult = getTweetPoll()
          .getTweetPollResultsByTweetPollSwitch(tweetPollSwitch);

    }

    final List<TweetPollSavedPublishedStatus> TpollSaved = getTweetPoll()
        .getLinksByTweetPoll(tweetPoll1, null, null,
            TypeSearchResult.TWEETPOLL);

    /* Retrieve Tweetpolls folders by Folder ID */
    Assert.assertEquals(tweetPoll1.getHashTags().size(), 2);

    /* Retrieve Question Answers * */
    Assert.assertEquals(tweetPoll1.getHashTags().size(), 2);

    // Check total Answers
    final List<QuestionAnswer> totalAnswers = getQuestionDaoImp()
        .getAnswersByQuestionId(tweetPoll1.getQuestion().getQid());

    Assert.assertEquals(totalAnswers.size(), 3);

    // Check if exist TweetPoll
    Assert.assertNotNull(getTweetPoll().getTweetPollById(
        myTweetpoll.getTweetPollId()));

    Assert.assertNotNull(getQuestionDaoImp().retrieveQuestionById(
        myTweetpoll.getQuestion().getQid()));

    /*
     *  **************************** REMOVE
     * ************************************
     */
    this.getTweetPollService().removeTweetPoll(tweetPoll1);

    List<TweetPollSwitch> tpSwitchsAfter = getTweetPoll()
        .getListAnswersByTweetPollAndDateRange(myTweetpoll);
    Assert.assertEquals(tpSwitchsAfter.size(), 0);

    // Check Tweetpollresult
    for (TweetPollSwitch tweetPollSwitch : tpSwitchsAfter) {
      final List<TweetPollResult> tpollsResult = getTweetPoll()
          .getTweetPollResultsByTweetPollSwitch(tweetPollSwitch);
    }

    // Check TweetpollSaved
    final List<TweetPollSavedPublishedStatus> TpollSavedAfter = getTweetPoll()
        .getLinksByTweetPoll(myTweetpoll, null, null,
            TypeSearchResult.TWEETPOLL);
    Assert.assertEquals(TpollSavedAfter.size(), 0);

    // Check Hashtag
    final List<TweetPoll> tpollsbyHashtag = getTweetPoll()
        .getTweetpollByHashTagName(tagName, 0, 10,
            TypeSearchResult.HASHTAG, SearchPeriods.ALLTIME);
    Assert.assertEquals(tpollsbyHashtag.size(), 0);

    // Check QuestionAnswer
    final List<QuestionAnswer> totalAnswersAfter = getQuestionDaoImp()
        .getAnswersByQuestionId(tweetPoll1.getQuestion().getQid());
    Assert.assertEquals(totalAnswersAfter.size(), 0);

    // Check TweetPoll
    final TweetPoll tpollAfter = getTweetPoll().getTweetPollById(
        myTweetpoll.getTweetPollId());
    Assert.assertNull(tpollAfter);

    // Check Question
    final Question questionAfter = getQuestionDaoImp()
View Full Code Here

   */
  @Test
  @Category(InternetTest.class)
  public void testPublishScheduled() throws EnMeNoResultsFoundException {
    // Tweetpoll
    final TweetPoll tweetPoll1 = createPublishedTweetPoll(
        this.userAccount.getAccount(), this.question, new Date());

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

    // SocialAccount
    final SocialAccount socialAcc = createDefaultSettedSocialAccount(this.userAccount);

View Full Code Here

   */
  @Test
  @Category(DefaultTest.class)
  public void testRemoveScheduledItems() {
    // Tweetpoll
    final TweetPoll tweetPoll1 = createPublishedTweetPoll(
        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, " ",
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.tweetpoll.TweetPoll

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.