Package de.jetwick.data

Examples of de.jetwick.data.JUser


    @Test
    public void testDelete() throws Exception {
        // do not throw exception
        twSearch.delete(Collections.EMPTY_LIST);

        JUser otherUser = new JUser("otherUser");
        JTweet tw2 = new JTweet(2L, "java is cool and stable!", otherUser);
        twSearch.store(tw2, false);
        twSearch.refresh();
        assertEquals(1, twSearch.search("java").size());
View Full Code Here


        assertEquals(0, twSearch.search("java").size());
    }

    @Test
    public void testGeo() throws Exception {
        JUser otherUser = new JUser("otherUser");
        JTweet tw2 = new JTweet(2L, "java is cool and stable!", otherUser);
        twSearch.store(tw2.setGeoLocation(123, 321), false);
        twSearch.refresh();

        assertEquals(1, twSearch.search("java").size());
View Full Code Here

        assertEquals(0, twSearch.searchGeo(123, 100, 1).size());
    }

    @Test
    public void testGetReplies() {
        JUser usera = new JUser("usera");
        JTweet tw = new JTweet(1L, "this is a Test ", usera);
        JUser userb = new JUser("userb");
        JTweet tw2 = new JTweet(2L, "this is a Test ", userb);
        tw2.addReply(tw);
        twSearch.store(tw, true);
        twSearch.store(tw2, true);
View Full Code Here

        assertEquals(1L, (long) tw.getTwitterId());
    }

    @Test
    public void testGetRetweets() {
        JUser usera = new JUser("usera");
        JTweet tw = new JTweet(1L, "this is a Test ", usera);
        JUser userb = new JUser("userb");
        JTweet tw2 = new JTweet(2L, "rt @usera: this is a Test ", userb);
        tw.addReply(tw2);
        twSearch.store(tw, false);
        twSearch.store(tw2, true);
View Full Code Here

        assertEquals(2L, (long) twSearch.searchReplies(1L, true).iterator().next().getTwitterId());
    }

    @Test
    public void testFindDuplicates() {
        twSearch.store(new JTweet(1L, "wikileaks is not a wtf", new JUser("userA")), false);
        twSearch.store(new JTweet(2L, "news about wikileaks", new JUser("userB")), false);

        // find dup is restricted to the last hour so use a current date
        MyDate dt = new MyDate();
        JTweet tw3 = new JTweet(3L, "wtf means wikileaks task force", new JUser("userC")).setCreatedAt(dt.toDate());
        JTweet tw4 = new JTweet(4L, "wtf wikileaks task force", new JUser("userD")).setCreatedAt(dt.plusMinutes(1).toDate());
        JTweet tw5 = new JTweet(5L, "RT @userC: wtf means wikileaks task force", new JUser("userE")).setCreatedAt(dt.plusMinutes(1).toDate());       
        twSearch.queueObjects(Arrays.asList(tw3, tw4, tw5));
        twSearch.forceEmptyQueueAndRefresh();
        assertEquals("should be empty. should NOT find tweet 4 because it is younger", 0, tw3.getDuplicates().size());
        assertEquals("should find tweet 3", 1, tw4.getDuplicates().size());

        Map<Long, JTweet> map = new LinkedHashMap<Long, JTweet>();
        JTweet tw = new JTweet(10L, "wtf wikileaks task force", new JUser("peter")).setCreatedAt(dt.plusMinutes(1).toDate());
        map.put(10L, tw);
        twSearch.findDuplicates(map);
        assertEquals("should find tweets 3 and 4", 2, tw.getDuplicates().size());
    }
View Full Code Here

    }
   
    @Test
    public void testSpamDuplicates() {
        MyDate dt = new MyDate();
        JTweet tw1 = new JTweet(1L, "2488334. Increase your twitter followers now! Buy Twitter Followers", new JUser("userA")).setCreatedAt(dt.plusMinutes(1).toDate());
        JTweet tw2 = new JTweet(2L, "349366. Increase your twitter followers now! Buy Twitter Followers", new JUser("userB")).setCreatedAt(dt.plusMinutes(1).toDate());
        JTweet tw3 = new JTweet(31L, "2040312. Increase your twitter followers now! Buy Twitter Followers", new JUser("userC")).setCreatedAt(dt.plusMinutes(1).toDate());       
        twSearch.queueObjects(Arrays.asList(tw1, tw2, tw3));
        twSearch.forceEmptyQueueAndRefresh();

        assertEquals(0, tw1.getDuplicates().size());
        assertEquals(1, tw2.getDuplicates().size());
View Full Code Here

        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");
View Full Code Here

        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);
View Full Code Here

                tw2 = createTweet(2L, "text", "peter")));

        Map<Long, JTweet> alreadyExistingTw = new LinkedHashMap<Long, JTweet>();
        alreadyExistingTw.put(2L, tw2);
        Map<String, JUser> users = new LinkedHashMap<String, JUser>();
        JUser u = new JUser("peter");
        users.put("peter", u);

        // return the tweet (1L) which is not already in the map!
        twSearch.fetchMoreTweets(alreadyExistingTw, users);
        assertEquals(1, u.getOwnTweets().size());
        assertEquals(1L, (long) u.getOwnTweets().iterator().next().getTwitterId());
    }
View Full Code Here

        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

Related Classes of de.jetwick.data.JUser

Copyright © 2018 www.massapicom. 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.