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()