private void assertNewConnection(Connection<TestFacebookApi> connection) { assertEquals("facebook", connection.getKey().getProviderId()); assertEquals("9", connection.getKey().getProviderUserId()); assertEquals("Keith Donald", connection.getDisplayName()); assertEquals("http://facebook.com/keith.donald", connection.getProfileUrl()); assertEquals("http://facebook.com/keith.donald/picture", connection.getImageUrl()); assertTrue(connection.test()); TestFacebookApi api = connection.getApi(); assertNotNull(api); assertEquals("123456789", api.getAccessToken()); assertEquals("123456789", connection.createData().getAccessToken()); assertEquals("987654321", connection.createData().getRefreshToken()); }
@Test public void updateConnectionAccessFields() { insertFacebookConnection(); Connection<TestFacebookApi> facebook = connectionRepository.getPrimaryConnection(TestFacebookApi.class); assertEquals("234567890", facebook.getApi().getAccessToken()); facebook.refresh(); connectionRepository.updateConnection(facebook); Connection<TestFacebookApi> facebook2 = connectionRepository.getPrimaryConnection(TestFacebookApi.class); assertEquals("765432109", facebook2.getApi().getAccessToken()); ConnectionData data = facebook.createData(); assertEquals("654321098", data.getRefreshToken()); }