mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 22:38:06 +01:00
Add test for round-trip AccountsManager JSON serialization
This commit is contained in:
@@ -915,7 +915,7 @@ public class AccountsManager {
|
||||
|
||||
private void redisSet(Account account) {
|
||||
try (Timer.Context ignored = redisSetTimer.time()) {
|
||||
final String accountJson = ACCOUNT_REDIS_JSON_WRITER.writeValueAsString(account);
|
||||
final String accountJson = writeRedisAccountJson(account);
|
||||
|
||||
cacheCluster.useCluster(connection -> {
|
||||
final RedisAdvancedClusterCommands<String, String> commands = connection.sync();
|
||||
@@ -936,7 +936,7 @@ public class AccountsManager {
|
||||
final String accountJson;
|
||||
|
||||
try {
|
||||
accountJson = ACCOUNT_REDIS_JSON_WRITER.writeValueAsString(account);
|
||||
accountJson = writeRedisAccountJson(account);
|
||||
} catch (final JsonProcessingException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
@@ -1047,7 +1047,8 @@ public class AccountsManager {
|
||||
.toCompletableFuture();
|
||||
}
|
||||
|
||||
private static Optional<Account> parseAccountJson(@Nullable final String accountJson, final UUID uuid) {
|
||||
@VisibleForTesting
|
||||
static Optional<Account> parseAccountJson(@Nullable final String accountJson, final UUID uuid) {
|
||||
try {
|
||||
if (StringUtils.isNotBlank(accountJson)) {
|
||||
Account account = SystemMapper.jsonMapper().readValue(accountJson, Account.class);
|
||||
@@ -1067,6 +1068,11 @@ public class AccountsManager {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static String writeRedisAccountJson(final Account account) throws JsonProcessingException {
|
||||
return ACCOUNT_REDIS_JSON_WRITER.writeValueAsString(account);
|
||||
}
|
||||
|
||||
private void redisDelete(final Account account) {
|
||||
try (final Timer.Context ignored = redisDeleteTimer.time()) {
|
||||
cacheCluster.useCluster(connection -> {
|
||||
|
||||
Reference in New Issue
Block a user