Examples of JTweet


Examples of de.jetwick.data.JTweet

        assertEquals(2, twSearch.findByUserName("peter").getOwnTweets().size());
    }

    @Test
    public void testUpdateAndRemove() throws Exception {
        JTweet tw1 = createTweet(1L, "@karsten hajo", "peter");
        tw1.setCreatedAt(new MyDate().minusDays(2).toDate());

        twSearch.testUpdate(tw1);
        assertEquals(1, twSearch.countAll());
        assertEquals("@karsten hajo", twSearch.search("hajo").iterator().next().getOwnTweets().iterator().next().getText());
        assertEquals(1, twSearch.findByUserName("peter").getOwnTweets().size());

        JTweet tw = createTweet(2L, "test", "peter");
        tw.setCreatedAt(new Date());
        twSearch.setRemoveOlderThanDays(1);
        twSearch.queueObject(tw);
        twSearch.forceEmptyQueueAndRefresh();
        assertEquals(1, twSearch.countAll());
        assertEquals(1, twSearch.search("test").size());
View Full Code Here

Examples of de.jetwick.data.JTweet

        assertEquals(2, twSearch.findByTwitterId(1L).getRetweetCount());
    }

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

        tw.setCreatedAt(new Date());
        twSearch.queueObject(tw);
        twSearch.forceEmptyQueueAndRefresh();
        assertEquals(1, twSearch.getFeededTweets());
    }
View Full Code Here

Examples of de.jetwick.data.JTweet

        assertEquals(1, twSearch.getFeededTweets());
    }

    @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());
        assertEquals(1, twSearch.search("new").size());
    }
View Full Code Here

Examples of de.jetwick.data.JTweet

        assertEquals(1, twSearch.search("new").size());
    }

    @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.data.JTweet

        assertTrue(twSearch.searchTweets(new TweetQuery()).contains(tw1));
    }

    @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.data.JTweet

        assertEquals(0, twSearch.search("bla bli blu").size());
    }

    @Test
    public void testDoNotThrowQueryParserException() {
        JTweet tw = createTweet(1L, "rt @jenny2s: -- Earth, Wind & Fire - September  (From \"Live In Japan\")"
                + " http://www.youtube.com/watch?v=hy-huQAMPQA via @youtube --- HAPPY SEPTEMBER !!", "usera");
        twSearch.testUpdate(tw);
    }
View Full Code Here

Examples of de.jetwick.data.JTweet

        assertEquals(2, twSearch.collectObjects(rsp).size());
    }

    @Test
    public void testReadUrlEntries() throws IOException {
        JTweet tw = new JTweet(1L, "text", new JUser("peter"));
        List<UrlEntry> entries = new ArrayList<UrlEntry>();

        UrlEntry urlEntry = new UrlEntry(2, 18, "http://fulltest.de/bla");
        urlEntry.setResolvedDomain("resolved-domain.de");
        urlEntry.setResolvedTitle("ResolvedTitel");
        entries.add(urlEntry);

        tw.setUrlEntries(entries);

        XContentBuilder iDoc = twSearch.createDoc(tw);
        String str = iDoc.prettyPrint().string();
        assertTrue(str.contains("\"url_pos_1_s\":\"2,18\""));
        assertTrue(str.contains("\"dest_url_1_s\":\"http://fulltest.de/bla\""));
        assertTrue(str.contains("\"dest_domain_1_s\":\"resolved-domain.de\""));
        assertTrue(str.contains("\"dest_title_1_s\":\"ResolvedTitel\""));

        Map<String, Object> map = new LinkedHashMap<String, Object>();
        map.put("user", "peter");
        map.put("tw", "text");
        map.put("url_i", 1);
        map.put("retw_i", 0);
        map.put("repl_i", 0);
        map.put("url_pos_1_s", "2,18");
        map.put("dest_url_1_s", "http://fulltest.de/bla");
        map.put("dest_domain_1_s", "resolved-domain.de");
        map.put("dest_title_1_s", "ResolvedTitel");

        JTweet tw2 = twSearch.readDoc("1", 0L, map);
        assertEquals(1, tw2.getUrlEntries().size());
        Iterator<UrlEntry> iter = tw2.getUrlEntries().iterator();
        urlEntry = iter.next();
        assertEquals("http://fulltest.de/bla", urlEntry.getResolvedUrl());
        assertEquals("resolved-domain.de", urlEntry.getResolvedDomain());
        assertEquals("ResolvedTitel", urlEntry.getResolvedTitle());
        assertEquals(2, urlEntry.getIndex());
View Full Code Here

Examples of de.jetwick.data.JTweet

        assertEquals(18, urlEntry.getLastIndex());
    }

    @Test
    public void testSameUrlTitleButDifferentUrl() throws IOException {
        JTweet tw1 = new JTweet(1L, "text", new JUser("peter"));
        List<UrlEntry> entries = new ArrayList<UrlEntry>();
        UrlEntry urlEntry = new UrlEntry(2, 18, "http://fulltest.de/url2");
        urlEntry.setResolvedDomain("resolved-domain.de");
        urlEntry.setResolvedTitle("ResolvedTitel");
        entries.add(urlEntry);
        tw1.setUrlEntries(entries);

        JTweet tw2 = new JTweet(1L, "text2", new JUser("peter2"));
        entries = new ArrayList<UrlEntry>();
        urlEntry = new UrlEntry(2, 18, "http://fulltest.de/urlNext");
        urlEntry.setResolvedDomain("resolved-domain.de");
        urlEntry.setResolvedTitle("ResolvedTitel");
        entries.add(urlEntry);
        tw2.setUrlEntries(entries);

        twSearch.testUpdate(Arrays.asList(tw1, tw2));
        assertEquals(1, twSearch.query(new TweetQuery()).hits().totalHits());
    }
View Full Code Here

Examples of de.jetwick.data.JTweet

    }

    @Test
    public void testGetMoreTweets() throws IOException {
        // fill index with 2 tweets and 1 user
        JTweet tw2;
        twSearch.testUpdate(Arrays.asList(
                createTweet(1L, "test", "peter"),
                tw2 = createTweet(2L, "text", "peter")));

        Map<Long, JTweet> alreadyExistingTw = new LinkedHashMap<Long, JTweet>();
View Full Code Here

Examples of de.jetwick.data.JTweet

        twSearch.deleteAll(index1, twSearch.getIndexType());
        twSearch.deleteAll(index2, twSearch.getIndexType());
        twSearch.deleteAll(resindex, twSearch.getIndexType());

        twSearch.bulkUpdate(Arrays.asList(
                new JTweet(1L, "hey cool one", new JUser("peter")),
                new JTweet(2L, "two! another one", new JUser("test"))), index1);

        twSearch.bulkUpdate(Arrays.asList(
                new JTweet(3L, "second index. one", new JUser("people")),
                new JTweet(4L, "snd index! two", new JUser("k")),
                new JTweet(5L, "snd index! third", new JUser("k"))), index2);

        twSearch.mergeIndices(Arrays.asList(index1, index2), resindex, 10, true, twSearch, null);

        assertEquals(5, twSearch.countAll(resindex));
    }
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.