Merge "AccountUpdate: Test case for unsetting string values using empty strings" into stable-3.11
diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
index 7804a43..55a2023 100644
--- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
@@ -3157,6 +3157,26 @@
         .isNotEqualTo(updatedUserState.account().metaId());
   }
 
+  @Test
+  public void accountUpdate_emptyStringsToUnset() throws Exception {
+    AccountState preUpdateState = accountCache.get(admin.id()).get();
+    requestScopeOperations.setApiUser(admin.id());
+
+    accountsUpdateProvider
+        .get()
+        .update(
+            "Replace External ID",
+            admin.id(),
+            u -> u.setFullName("").setDisplayName("").setPreferredEmail("").setStatus(""));
+
+    AccountState updatedState = accountCache.get(admin.id()).get();
+    assertThat(accountCache.get(admin.id()).get()).isNotSameInstanceAs(preUpdateState);
+    assertThat(updatedState.account().fullName()).isNull();
+    assertThat(updatedState.account().displayName()).isNull();
+    assertThat(updatedState.account().preferredEmail()).isNull();
+    assertThat(updatedState.account().status()).isNull();
+  }
+
   protected ExternalId createEmailExternalId(Account.Id accountId, String email) {
     return getExternalIdFactory().createWithEmail(SCHEME_MAILTO, email, accountId, email);
   }