PlusAnonymousConcurrentUserDataModel extends PlusAnonymousUserDataModel { @Override public LongPrimitiveIterator getUserIDs() throws TasteException { return getDelegate().getUserIDs(); } PlusAnonymousConcurrentUserDataModel(DataModel delegate, int maxConcurrentUsers); Long takeAvailableUser(); boolean releaseUser(Long userID); void setTempPrefs(PreferenceArray prefs, long anonymousUserID); void clearTempPrefs(long anonymousUserID); @Override LongPrimitiveIterator getUserIDs(); @Override PreferenceArray getPreferencesFromUser(long userID); @Override FastIDSet getItemIDsFromUser(long userID); @Override PreferenceArray getPreferencesForItem(long itemID); @Override Float getPreferenceValue(long userID, long itemID); @Override Long getPreferenceTime(long userID, long itemID); @Override int getNumUsers(); @Override int getNumUsersWithPreferenceFor(long itemID); @Override int getNumUsersWithPreferenceFor(long itemID1, long itemID2); @Override void setPreference(long userID, long itemID, float value); @Override void removePreference(long userID, long itemID);  }
@Test public void testGetUserIDs() throws TasteException { PreferenceArray prefs = new GenericUserPreferenceArray(1); long sampleUserID = 1; prefs.setUserID(0, sampleUserID); long sampleItemID = 11; prefs.setItemID(0, sampleItemID); FastByIDMap<PreferenceArray> delegatePreferences = new FastByIDMap<PreferenceArray>(); delegatePreferences.put(sampleUserID, prefs); PlusAnonymousConcurrentUserDataModel instance = getTestableWithDelegateData(10, delegatePreferences); Long anonymousUserID = instance.takeAvailableUser(); PreferenceArray tempPrefs = new GenericUserPreferenceArray(1); tempPrefs.setUserID(0, anonymousUserID); tempPrefs.setItemID(0, 22); instance.setTempPrefs(tempPrefs, anonymousUserID); Iterator<Long> userIDs = instance.getUserIDs(); assertSame(sampleUserID, userIDs.next()); assertFalse(userIDs.hasNext()); }
@Test public void testGetUserIDs() throws TasteException { PreferenceArray prefs = new GenericUserPreferenceArray(1); long sampleUserID = 1; prefs.setUserID(0, sampleUserID); long sampleItemID = 11; prefs.setItemID(0, sampleItemID); FastByIDMap<PreferenceArray> delegatePreferences = new FastByIDMap<>(); delegatePreferences.put(sampleUserID, prefs); PlusAnonymousConcurrentUserDataModel instance = getTestableWithDelegateData(10, delegatePreferences); Long anonymousUserID = instance.takeAvailableUser(); PreferenceArray tempPrefs = new GenericUserPreferenceArray(1); tempPrefs.setUserID(0, anonymousUserID); tempPrefs.setItemID(0, 22); instance.setTempPrefs(tempPrefs, anonymousUserID); Iterator<Long> userIDs = instance.getUserIDs(); assertSame(sampleUserID, userIDs.next()); assertFalse(userIDs.hasNext()); }