private void assertTwitterConnection(Connection<TestTwitterApi> twitter) { assertEquals(new ConnectionKey("twitter", "1"), twitter.getKey()); assertEquals("@kdonald", twitter.getDisplayName()); assertEquals("http://twitter.com/kdonald", twitter.getProfileUrl()); assertEquals("http://twitter.com/kdonald/picture", twitter.getImageUrl()); TestTwitterApi twitterApi = twitter.getApi(); assertEquals("123456789", twitterApi.getAccessToken()); assertEquals("987654321", twitterApi.getSecret()); twitter.sync(); assertEquals("http://twitter.com/kdonald/a_new_picture", twitter.getImageUrl()); }
private void assertFacebookConnection(Connection<TestFacebookApi> facebook) { assertEquals(new ConnectionKey("facebook", "9"), facebook.getKey()); assertEquals(null, facebook.getDisplayName()); assertEquals(null, facebook.getProfileUrl()); assertEquals(null, facebook.getImageUrl()); TestFacebookApi facebookApi = facebook.getApi(); assertEquals("234567890", facebookApi.getAccessToken()); facebook.sync(); assertEquals("Keith Donald", facebook.getDisplayName()); assertEquals("http://facebook.com/keith.donald", facebook.getProfileUrl()); assertEquals("http://facebook.com/keith.donald/picture", facebook.getImageUrl()); }
@Test public void updateConnectionProfileFields() { connectionFactoryRegistry.addConnectionFactory(new TestTwitterConnectionFactory()); insertTwitterConnection(); Connection<TestTwitterApi> twitter = connectionRepository.getPrimaryConnection(TestTwitterApi.class); assertEquals("http://twitter.com/kdonald/picture", twitter.getImageUrl()); twitter.sync(); assertEquals("http://twitter.com/kdonald/a_new_picture", twitter.getImageUrl()); connectionRepository.updateConnection(twitter); Connection<TestTwitterApi> twitter2 = connectionRepository.getPrimaryConnection(TestTwitterApi.class); assertEquals("http://twitter.com/kdonald/a_new_picture", twitter2.getImageUrl()); }