IdentityApi { void sortUsers(List<MParticleUser> users) { Collections.sort(users, new Comparator<MParticleUser>() { @Override public int compare(MParticleUser user1, MParticleUser user2) { long lst1 = user1.getLastSeenTime(); long lst2 = user2.getLastSeenTime(); if (lst1 > lst2) { return -1; } else if (lst1 < lst2) { return 1; } else { return 0; } } }); } protected  IdentityApi(); @SuppressLint("UnknownNullness")  IdentityApi(Context context, AppStateManager appStateManager, MessageManager messageManager, ConfigManager configManager, KitManager kitManager, MParticle.OperatingSystem operatingSystem); @Nullable MParticleUser getCurrentUser(); @Nullable MParticleUser getUser(@NonNull Long mpid); @NonNull List<MParticleUser> getUsers(); @NonNull String getDeviceApplicationStamp(); void addIdentityStateListener(@NonNull IdentityStateListener listener); void removeIdentityStateListener(@NonNull IdentityStateListener listener); @NonNull MParticleTask<IdentityApiResult> logout(); @NonNull MParticleTask<IdentityApiResult> logout(@Nullable final IdentityApiRequest logoutRequest); @NonNull MParticleTask<IdentityApiResult> login(); @NonNull MParticleTask<IdentityApiResult> login(@Nullable final IdentityApiRequest loginRequest); @NonNull MParticleTask<IdentityApiResult> identify(@Nullable final IdentityApiRequest identifyRequest); @NonNull BaseIdentityTask modify(@NonNull final IdentityApiRequest updateRequest); boolean aliasUsers(@NonNull AliasRequest aliasRequest); @NonNull Internal Internal(); static int UNKNOWN_ERROR; static int THROTTLE_ERROR; static int BAD_REQUEST; static int SERVER_ERROR; }
@Test public void testUserOrder() { IdentityApi identityApi = new IdentityApi(); List<MParticleUser> users = new ArrayList<MParticleUser>(); for (int i = 0; i < 10; i++) { users.add(new MockUser(ran.nextLong(), ran.nextLong())); } identityApi.sortUsers(users); long lastTime = Long.MAX_VALUE; for (MParticleUser user: users) { assertTrue(user.getLastSeenTime() <= lastTime); lastTime = user.getLastSeenTime(); } }