Examples of MyDate


Examples of de.jetwick.util.MyDate

    }

    @Test
    public void testDoNotAddOldTweets() {
        JTweet tw = createTweet(2L, "RT @userA: bla bli blu", "userB");
        tw.setCreatedAt(new MyDate().minusDays(2).toDate());
        twSearch.setRemoveOlderThanDays(1);
        twSearch.queueObject(tw);
        twSearch.forceEmptyQueueAndRefresh();
        assertEquals(0, twSearch.getFeededTweets());
View Full Code Here

Examples of de.jetwick.util.MyDate

    }

    @Test
    public void testAddOldTweetsIfPersistent() {
        JTweet tw = createTweet(2L, "RT @userA: bla bli blu", "userB");
        Date dt = new MyDate().minusDays(2).toDate();
        tw.setUpdatedAt(dt);
        tw.setCreatedAt(dt);
        twSearch.testUpdate(tw);
        assertEquals(1, twSearch.getFeededTweets());


        // testOverwriteTweetsIfPersistent
        tw = createTweet(2L, "totally new", "userB");
        dt = new MyDate().minusDays(2).toDate();
        tw.setUpdatedAt(dt);
        tw.setCreatedAt(dt);
        twSearch.testUpdate(tw);
        assertEquals(1, twSearch.getFeededTweets());
        assertEquals(0, twSearch.search("bla").size());
View Full Code Here

Examples of de.jetwick.util.MyDate

    }

    @Test
    public void testDontRemoveOldIfPersistent() throws Exception {
        JTweet tw1 = createTweet(4L, "newbla next", "userc").setRetweetCount(100);
        tw1.setCreatedAt(new MyDate().minusDays(2).toDate());

        JTweet tw2 = createTweet(2L, "RT @userA: bla bli blu", "userB");
        Date dt = new MyDate().minusDays(2).toDate();
        tw2.setUpdatedAt(dt);
        tw2.setCreatedAt(dt);

        // until date is very old to let tweets going through
        twSearch.queueObjects(Arrays.asList(tw2, tw1));
        twSearch.forceEmptyQueueAndRefresh();
        assertEquals(2, twSearch.getFeededTweets());
        assertEquals(2, twSearch.countAll());
        assertEquals(100, twSearch.findByTwitterId(4L).getRetweetCount());
        assertNotNull(twSearch.findByTwitterId(2L).getUpdatedAt());

        JTweet tw3 = createTweet(3L, "another tweet grabbed from search", "userB");
        tw3.setCreatedAt(new MyDate().minusDays(2).toDate());
       
        twSearch.setRemoveOlderThanDays(1);
        twSearch.queueObject(tw3);
        twSearch.forceEmptyQueueAndRefresh();
        assertEquals(0, twSearch.getFeededTweets());
View Full Code Here

Examples of de.jetwick.util.MyDate

    }

    @Test
    public void testComplexUpdate() throws Exception {
        JTweet tw1 = createTweet(1L, "bla bli blu", "userA");
        tw1.setCreatedAt(new MyDate().minusDays(2).toDate());

        JTweet tw2 = createTweet(2L, "rt @usera: bla bli blu", "userB");
        tw2.setCreatedAt(new MyDate().minusDays(2).plusMinutes(1).toDate());

        JTweet tw3 = createTweet(3L, "rt @usera: bla bli blu", "userC");
        tw3.setCreatedAt(new MyDate().minusDays(2).plusMinutes(1).toDate());

        JTweet tw4 = createTweet(4L, "rt @usera: bla bli blu", "userD");
        tw4.setCreatedAt(new MyDate().minusDays(2).plusMinutes(1).toDate());
       
        twSearch.testUpdate(Arrays.asList(tw1, tw2, tw3, tw4));
        assertEquals(1, twSearch.findByUserName("usera").getOwnTweets().size());
        assertEquals(3, twSearch.findByTwitterId(1L).getReplyCount());
        assertEquals(4, twSearch.getFeededTweets());
       

        JTweet tw101 = createTweet(101L, "newtext two", "usera");
        tw101.setCreatedAt(new Date());
        JTweet tw102 = createTweet(102L, "newbla one", "userd");
        tw102.setCreatedAt(new Date());
        JTweet tw103 = createTweet(103L, "newbla two", "userd");
        tw103.setCreatedAt(new Date());
        JTweet tw104 = createTweet(104L, "rt @usera: newtext two", "userc");
        tw104.setCreatedAt(new MyDate(tw101.getCreatedAt()).plusMinutes(1).toDate());

        twSearch.setRemoveOlderThanDays(1);
        twSearch.testUpdate(Arrays.asList(tw101, tw102, tw103, tw104));
        assertEquals(4, twSearch.getFeededTweets());
        assertEquals(4, twSearch.countAll());
View Full Code Here

Examples of de.jetwick.util.MyDate

        assertTrue(coll.contains("abcdxy bluest"));
    }

    @Test
    public void testQueryChoicesWithoutDateRestrictions() {
        twSearch.testUpdate(Arrays.asList(createTweet(new MyDate().minusDays(1).minusMinutes(3), "obama obama", "usera"),
                createTweet(new MyDate().minusDays(1).minusMinutes(2), "bluest obama obama", "usera"),
                createTweet(new MyDate().minusDays(1).minusMinutes(1), "bluest bluest obama", "usera"),
                createTweet(new MyDate().minusDays(1), "obama bluest again and again", "usera")));

        assertEquals(3L, twSearch.query(new TweetQuery().addFilterQuery("tag", "bluest")).getHits().getTotalHits());

        Collection<String> coll = twSearch.getQueryChoices(new TweetQuery().addLatestDateFilter(8), "obama ");
        assertEquals(1, coll.size());
View Full Code Here

Examples of de.jetwick.util.MyDate

        assertEquals(1, twSearch.collectObjects(twSearch.query(new TweetQuery().addFilterQuery(ElasticTweetSearch.USER, "peter"))).size());
    }

    @Test
    public void testSuggestFilterRemoval() {
        MyDate md = new MyDate();
        twSearch.testUpdate(Arrays.asList(
                createTweet(1L, "RT @user3: test this first tweet", "peter").setCreatedAt(md.toDate()),
                createTweet(2L, "test others", "peter2").setCreatedAt(md.toDate()),
                createTweet(3L, "testnot this", "peter3").setCreatedAt(md.minusHours(2).toDate()),
                createTweet(4L, "test this", "peter4").setCreatedAt(md.toDate())));

        JetwickQuery q = new TweetQuery(false).addIsOriginalTweetFilter().
                addLatestDateFilter(1).
                addUserFilter("peter");
        Collection<String> keys = twSearch.suggestRemoval(q);
View Full Code Here

Examples of de.jetwick.util.MyDate

        assertEquals(ElasticTweetSearch.IS_RT, iter.next());
    }

    @Test
    public void testSuggestFilterRemoval2() {
        MyDate md = new MyDate();
        twSearch.testUpdate(Arrays.asList(
                createTweet(1L, "RT @user3: test this first tweet", "peter1").setCreatedAt(md.toDate()),
                createTweet(2L, "test others", "peter2").setCreatedAt(md.toDate()),
                createTweet(3L, "testnot this", "peter3").setCreatedAt(md.minusHours(2).toDate()),
                createTweet(4L, "test this", "peter4").setCreatedAt(md.toDate())));

        JetwickQuery q = new TweetQuery(false).addIsOriginalTweetFilter().
                addLatestDateFilter(1).
                addUserFilter("peter");
        Collection<String> keys = twSearch.suggestRemoval(q);
View Full Code Here

Examples of de.jetwick.util.MyDate

        assertEquals(ElasticTweetSearch.IS_RT, iter.next());
    }

    @Test
    public void testSuggestFilterForceDate() {
        MyDate md = new MyDate();
        twSearch.testUpdate(Arrays.asList(
                createTweet(2L, "test others", "peter2").setCreatedAt(md.minusHours(2).toDate()),
                createTweet(3L, "testnot this", "peter3").setCreatedAt(md.minusHours(2).toDate())));

        JetwickQuery q = new TweetQuery(false).addLatestDateFilter(1);
        Collection<String> keys = twSearch.suggestRemoval(q);
        assertEquals(1, keys.size());
        Iterator<String> iter = keys.iterator();
View Full Code Here

Examples of de.jetwick.util.MyDate

        helper.updateFriendsOf(user);
        assertEquals(1, list.size());

        // force 'aging' of user update
        user.setLastFriendsUpdate(new MyDate().minusDays(4).toDate());
        helper.updateFriendsOf(user);
        assertEquals(2, list.size());

        user.setLastFriendsUpdate(new MyDate().minusDays(3).toDate());
        assertEquals(1, helper.updateFriendsOf(user).size());
        assertEquals(2, list.size());
    }
View Full Code Here

Examples of de.jetwick.util.MyDate

        assertEquals(2, tagSearch.findAll(0, 10).size());
    }

    @Test
    public void testDeleteUntil() {
        JTag tag = new JTag("java OR java OR people").setLastRequest(new MyDate().minusHours(30).toDate());
        tagSearch.queueObject(tag, false);
        assertTrue(tagSearch.forceCleanTagQueueAndRefresh());
        tag = new JTag("people").setLastRequest(new Date());
        tagSearch.queueObject(tag, false);
        assertTrue(tagSearch.forceCleanTagQueueAndRefresh());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.