use of com.google.gerrit.server.cache.proto.Cache.OAuthTokenProto in project gerrit by GerritCodeReview.
the class OAuthTokenCacheTest method oAuthTokenSerializerWithNullProvider.
@Test
public void oAuthTokenSerializerWithNullProvider() throws Exception {
OAuthToken tokenWithNull = new OAuthToken("token", "secret", "raw", 12345L, null);
CacheSerializer<OAuthToken> s = new OAuthTokenCache.Serializer();
OAuthTokenProto expectedProto = OAuthTokenProto.newBuilder().setToken("token").setSecret("secret").setRaw("raw").setExpiresAtMillis(12345L).setProviderId("").build();
byte[] serializedWithNull = s.serialize(tokenWithNull);
assertThat(OAuthTokenProto.parseFrom(serializedWithNull)).isEqualTo(expectedProto);
assertThat(s.deserialize(serializedWithNull)).isEqualTo(tokenWithNull);
OAuthToken tokenWithEmptyString = new OAuthToken("token", "secret", "raw", 12345L, "");
assertThat(tokenWithEmptyString).isEqualTo(tokenWithNull);
byte[] serializedWithEmptyString = s.serialize(tokenWithEmptyString);
assertThat(OAuthTokenProto.parseFrom(serializedWithEmptyString)).isEqualTo(expectedProto);
assertThat(s.deserialize(serializedWithEmptyString)).isEqualTo(tokenWithNull);
}
Aggregations