Add test for round-trip AccountsManager JSON serialization

This commit is contained in:
Chris Eager
2023-08-23 14:42:02 -05:00
committed by Chris Eager
parent 708f23a2ee
commit f181397664
4 changed files with 104 additions and 7 deletions

View File

@@ -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 -> {