/**
*
*/
@Test
public void testTpollsByHashTagNameAndDateRange() {
final HashTag myHashTag = createHashTag("preferences");
final Calendar releaseDate = Calendar.getInstance();
final Question myFirstQuestion = createQuestion(
"What is your favorite kind of movie?", secondary.getAccount());
final Question mySecondQuestion = createQuestion(
"What is your favorite kind of song?", secondary.getAccount());
// FIRST TP
final TweetPoll tweetPoll = createPublishedTweetPoll(
this.secondary.getAccount(), myFirstQuestion,
releaseDate.getTime());
tweetPoll.getHashTags().add(myHashTag);
getTweetPoll().saveOrUpdate(tweetPoll);
assertNotNull(tweetPoll);
//SECOND TP
releaseDate.add(Calendar.HOUR, -1);
final TweetPoll tweetPoll2 = createPublishedTweetPoll(
this.secondary.getAccount(), mySecondQuestion,
releaseDate.getTime());
tweetPoll2.getHashTags().add(myHashTag);
getTweetPoll().saveOrUpdate(tweetPoll2);
assertNotNull(tweetPoll2);
// THIRD TP
releaseDate.add(Calendar.HOUR, -4);
final TweetPoll tweetPoll3 = createPublishedTweetPoll(
this.secondary.getAccount(), mySecondQuestion,
releaseDate.getTime());
tweetPoll3.getHashTags().add(myHashTag);
getTweetPoll().saveOrUpdate(tweetPoll3);
assertNotNull(tweetPoll3);
// // FOURTH TP
releaseDate.add(Calendar.DATE, -7);
releaseDate.add(Calendar.HOUR, -5);
final TweetPoll tweetPoll4 = createPublishedTweetPoll(
this.secondary.getAccount(), mySecondQuestion,
releaseDate.getTime());
tweetPoll4.getHashTags().add(myHashTag);
getTweetPoll().saveOrUpdate(tweetPoll4);
assertNotNull(tweetPoll4);
// FIFTH
releaseDate.add(Calendar.WEEK_OF_MONTH, -7);
final TweetPoll tweetPoll5 = createPublishedTweetPoll(
this.secondary.getAccount(), mySecondQuestion,
releaseDate.getTime());
tweetPoll5.getHashTags().add(myHashTag);
getTweetPoll().saveOrUpdate(tweetPoll5);
assertNotNull(tweetPoll5);
// SIXTH
releaseDate.add(Calendar.YEAR, -1);
final TweetPoll tweetPoll6 = createPublishedTweetPoll(
this.secondary.getAccount(), mySecondQuestion,
releaseDate.getTime());
tweetPoll6.getHashTags().add(myHashTag);
getTweetPoll().saveOrUpdate(tweetPoll6);
assertNotNull(tweetPoll6);
// SEVENTH
releaseDate.add(Calendar.YEAR, -2);
final TweetPoll tweetPoll7 = createPublishedTweetPoll(
this.secondary.getAccount(), mySecondQuestion,
releaseDate.getTime());
tweetPoll7.getHashTags().add(myHashTag);
getTweetPoll().saveOrUpdate(tweetPoll7);
assertNotNull(tweetPoll7);
List<Object[]> tweetPollsbyHashTag = null;
tweetPollsbyHashTag = getTweetPoll()
.getTweetPollsRangeStats(myHashTag.getHashTag(), SearchPeriods.ALLTIME);
Assert.assertEquals("Should be", 6, tweetPollsbyHashTag.size());
tweetPollsbyHashTag = getTweetPoll()
.getTweetPollsRangeStats(myHashTag.getHashTag(),
SearchPeriods.TWENTYFOURHOURS);
Assert.assertEquals("Should be", 3, tweetPollsbyHashTag.size());
tweetPollsbyHashTag = getTweetPoll()
.getTweetPollsRangeStats(myHashTag.getHashTag(),
SearchPeriods.THIRTYDAYS);
Assert.assertEquals("Should be", 4, tweetPollsbyHashTag.size());
tweetPollsbyHashTag = getTweetPoll()
.getTweetPollsRangeStats(myHashTag.getHashTag(),
SearchPeriods.ONEYEAR);
Assert.assertEquals("Should be", 5, tweetPollsbyHashTag.size());
}