Commits

Juan Carlos Picado Herrera  committed c494b4e

Fixed bug 107, 2 failures

  • Participants
  • Parent commits 1040b75

Comments (0)

Files changed (5)

File encuestame-core/src/main/java/org/encuestame/core/util/DateUtil.java

         return yearsBetween.getYears();
     }
 
-
     /**
      *  DateTime start = new DateTime(); //Devuelve la fecha actual al estilo Date
         DateTime end = new DateTime(); //Devuelve la fecha actual al estilo Date

File encuestame-persistence/pom.xml

            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
         </dependency>
+        <dependency>
+             <groupId>joda-time</groupId>
+             <artifactId>joda-time</artifactId>
+         </dependency>
     </dependencies>
 </project>

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/AbstractHibernateDaoSupport.java

 package org.encuestame.persistence.dao.imp;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.hibernate.HibernateException;
 import org.hibernate.Session;
 import org.hibernate.criterion.DetachedCriteria;
+import org.joda.time.DateMidnight;
+import org.joda.time.DateTime;
 import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
 
 /**
           }
           return results;
      }
+
+     /**
+     *
+     * @param date
+     * @return
+     */
+    public Date getCurrentMidnightDate(){
+        DateTime midNight = new DateTime();
+        midNight = midNight.plusDays(1);
+        DateMidnight d  = midNight.toDateMidnight();
+        System.out.println("midNight---->"+d.toDate());
+        return d.toDate();
+    }
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/TweetPollDao.java

             final Integer start){
          final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPoll.class);
          criteria.createAlias("tweetOwner","tweetOwner");
-         criteria.add(Restrictions.between("createDate", initDate, new Date()));
+         criteria.add(Restrictions.between("createDate", initDate, getCurrentMidnightDate()));
          criteria.add(Restrictions.eq("tweetOwner.id", userId));
          return (List<TweetPoll>) filterByMaxorStart(criteria, maxResults, start);
     }

File encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestTweetPollDao.java

 import org.encuestame.persistence.domain.survey.TweetPollSwitch;
 import org.encuestame.persistence.exception.EnMeDomainNotFoundException;
 import org.encuestame.test.config.AbstractBase;
+import org.joda.time.DateMidnight;
 import org.junit.Before;
 import org.junit.Test;
 
     @Before
     public void initData(){
       this.secondary = createSecondaryUser("jhon", createUser());
-      final Question question = createQuestion("who I am?", "");
+      final Question question = createQuestion("Who I am?", "");
       this.questionsAnswers1 = createQuestionAnswer("yes", question, "12345");
       this.questionsAnswers2 = createQuestionAnswer("no", question, "12346");
       this.tweetPoll = createPublishedTweetPoll(secondary.getAccount(), question);
       createTweetPollResult(pollSwitch1, "192.168.0.2");
       createTweetPollResult(pollSwitch2, "192.168.0.3");
       createTweetPollResult(pollSwitch2, "192.168.0.4");
-
       this.tweetPollFolder = createTweetPollFolder("First TweetPoll Folder", secondary.getAccount());
 
     }
     @Test
     public void testgetVotesByAnswer(){
         final Long d = getTweetPoll().getTotalVotesByTweetPollId(this.tweetPoll.getTweetPollId());
-        System.out.println(d);
     }
 
 
         assertNotNull(this.secondary);
         assertNotNull(tweetPoll);
         final Long userId = this.secondary.getAccount().getUid();
-        final Date initDate = new Date();
-        final List<TweetPoll> tweetsByDate = getTweetPoll().retrieveTweetPollByDate(userId, initDate, 5, 0);
+        final DateMidnight initDate = new DateMidnight();
+        final List<TweetPoll> tweetsByDate = getTweetPoll().retrieveTweetPollByDate(userId, initDate.toDate(), 5, 0);
         assertEquals("Should be equals", 1, tweetsByDate.size());
     }