/ShowMeTheBestReply/test/integration/NewsTests.groovy
http://showmethebestreply.googlecode.com/ · Groovy · 70 lines · 51 code · 16 blank · 3 comment · 2 complexity · 26ab587ae4106cde39bc57a136dda88f MD5 · raw file
- import grails.test.*
- class NewsTests extends GrailsUnitTestCase {
- protected void setUp() {
- super.setUp()
- }
- protected void tearDown() {
- super.tearDown()
- }
-
- void testParsingRank() {
- String section = 'all'
- String date = new Date().format('yyyyMMdd').toString()
-
- Date dateParam = Date.parse('yyyyMMdd', date)
- def rankInfo = RankInfo.findBySectionAndDateCreatedBetween(section, new Date(dateParam.time), new Date((dateParam+1).time))
- if(!rankInfo) {
- rankInfo = RankInfo.parseRankInfo(section, date)
- rankInfo.save()
- }
- println "$section, $date"
-
- def sortedListOfArticleRank = rankInfo.listOfArticleRank.sort{ it.rank }
- sortedListOfArticleRank.each{
- println "$it.rank, $it.articleTitle"
- }
- }
-
- // ?? ?? ?? ???
- void testParsingArticle() {
- String articleUrl = 'http://news.nate.com/view/20091203n08304'
- def article = Article.parseArticle(articleUrl)
-
- println "$article.title($article.articleId, $article.url, $article.dateCreated, $article.dateModified, $article.media)"
- println "$article.imageLink, $article.thumbnailLink"
- println "$article.content"
-
- article.save()
- }
-
- // ?? ?? ?? ???
- void testParsingBestReplies() {
- String articleUrl = 'http://news.nate.com/view/20091203n08304'
- def listOfBeple = Reply.parseBestReplies(articleUrl)
-
- for(beple in listOfBeple) {
- println "$beple.username, $beple.content, $beple.dateCreated"
-
- beple.save()
- }
-
- assert Reply.count() > 0
- }
- // ?? ??? ??? ?? ???? ? ?????? ???
- void testArticleBestReplies() {
- String articleUrl = 'http://news.nate.com/view/20091203n08304'
- def article = Article.parseArticle(articleUrl)
- article.listOfBeple = Reply.parseBestReplies(articleUrl)
-
- article.save()
-
- def insertedArticle = Article.findByUrl(articleUrl)
- assert insertedArticle
-
- println insertedArticle
- insertedArticle.listOfBeple.sort{ it.countOfGood }.reverse().each{ beple -> println beple }
- }
- }