UserIdContext { public static boolean checkUserIdValidForAppCenter(String userId) { if (userId != null && userId.length() > USER_ID_APP_CENTER_MAX_LENGTH) { AppCenterLog.error(LOG_TAG, "userId is limited to " + USER_ID_APP_CENTER_MAX_LENGTH + " characters."); return false; } return true; }  static synchronized UserIdContext getInstance(); @VisibleForTesting static synchronized void unsetInstance(); static boolean checkUserIdValidForOneCollector(String userId); static boolean checkUserIdValidForAppCenter(String userId); static String getPrefixedUserId(String userId); void addListener(@NonNull Listener listener); void removeListener(@NonNull Listener listener); synchronized String getUserId(); void setUserId(String userId); @VisibleForTesting
    static final int USER_ID_APP_CENTER_MAX_LENGTH; }
@Test public void userIdInvalidForAppCenter() { StringBuilder userId = new StringBuilder(); for (int i = 0; i <= UserIdContext.USER_ID_APP_CENTER_MAX_LENGTH; i++) { userId.append("x"); } assertFalse(UserIdContext.checkUserIdValidForAppCenter(userId.toString())); }
@Test public void userIdValidForAppCenter() { assertTrue(UserIdContext.checkUserIdValidForAppCenter("alice")); assertTrue(UserIdContext.checkUserIdValidForAppCenter(null)); }