FriendFactoryTest.java :  » App » psnfriends » se » ramfelt » psn » web » us » Android Open Source

Android Open Source » App » psnfriends 
psnfriends » se » ramfelt » psn » web » us » FriendFactoryTest.java
package se.ramfelt.psn.web.us;

import org.apache.commons.io.IOUtils;
import org.junit.Test;

import se.ramfelt.psn.model.Friend;
import se.ramfelt.psn.model.Friend.Presence;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

public class FriendFactoryTest {

    @Test
    public void assertSimpleFriendIsParsedProperly() throws Exception {
        Friend friend = new FriendFactory().createFriend(IOUtils.toString(FriendFactoryTest.class.getResourceAsStream("friend_simple.json")));
        assertThat(friend.getOnlineId(), is("User"));
        assertThat(friend.getTrophySummary().getBronze(), is(79));
        assertThat(friend.getTrophySummary().getSilver(), is(11));
        assertThat(friend.getTrophySummary().getGold(), is(1));
        assertThat(friend.getTrophySummary().getPlatinum(), is(0));
        assertThat(friend.getPresence(), is(Presence.Unknown));
    }

    @Test
    public void assertOfflineFriendIsParsedProperly() throws Exception {
        Friend friend = new FriendFactory().createFriend(IOUtils.toString(FriendFactoryTest.class.getResourceAsStream("friend_offline.json")));
        assertThat(friend.getOnlineId(), is("User"));
        assertThat(friend.getPresence(), is(Presence.Offline));
        assertThat(friend.getLastSeenTimestamp(), is(1272220483000L));
    }

    @Test
    public void assertGamingFriendIsParsedProperly() throws Exception {
        Friend friend = new FriendFactory().createFriend(IOUtils.toString(FriendFactoryTest.class.getResourceAsStream("friend_gaming.json")));
        assertThat(friend.getOnlineId(), is("User"));
        assertThat(friend.getPresence(), is(Presence.Online));
        assertThat(friend.getCurrentGame(), is("Uncharted 2: Among Thieves"));
    }

    @Test
    public void assertFriendIsUsingVidzoneIsParsedProperly() throws Exception {
        Friend friend = new FriendFactory().createFriend(IOUtils.toString(FriendFactoryTest.class.getResourceAsStream("friend_vidzone.json")));
        assertThat(friend.getOnlineId(), is("User"));
        assertThat(friend.getPresence(), is(Presence.Online));
        assertThat(friend.getCurrentGame(), is("VidZone  Feist  I Feel It All"));
    }

    @Test
    public void assertFriendAtDashboardIsParsedProperly() throws Exception {
        Friend friend = new FriendFactory().createFriend(IOUtils.toString(FriendFactoryTest.class.getResourceAsStream("friend_dashboard.json")));
        assertThat(friend.getOnlineId(), is("User"));
        assertThat(friend.getPresence(), is(Presence.Online));
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.