AuthTokenAdapter implements JsonSerializer<AuthToken>, JsonDeserializer<AuthToken> { static String getAuthTypeString(Class<? extends AuthToken> authTokenClass) { for (Map.Entry<String, Class<? extends AuthToken>> entry : authTypeRegistry.entrySet()) { if (entry.getValue().equals(authTokenClass)) { return entry.getKey(); } } return ""; } AuthTokenAdapter(); @Override JsonElement serialize(AuthToken src, Type typeOfSrc, JsonSerializationContext context); @Override AuthToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context);  }
@Test public void testGetAuthTypeString() { assertEquals("oauth1a", AuthTokenAdapter.getAuthTypeString(TwitterAuthToken.class)); }
@Test public void testGetAuthTypeString_unregisteredAuthType() { assertEquals("", AuthTokenAdapter.getAuthTypeString(TestAuthToken.class)); }