@Test public void testGetPreferenceValue() throws TasteException { PlusAnonymousConcurrentUserDataModel instance = getTestableWithoutDelegateData(10); Long anonymousUserID = instance.takeAvailableUser(); PreferenceArray tempPrefs = new GenericUserPreferenceArray(1); tempPrefs.setUserID(0, anonymousUserID); long sampleItemID = 1; tempPrefs.setItemID(0, sampleItemID); tempPrefs.setValue(0, Float.MAX_VALUE); instance.setTempPrefs(tempPrefs, anonymousUserID); assertEquals(Float.MAX_VALUE, instance.getPreferenceValue(anonymousUserID, sampleItemID), EPSILON); }
@Override public Float getPreferenceValue(long userID, long itemID) throws TasteException { if (isAnonymousUser(userID)) { PreferenceArray singleUserTempPrefs = tempPrefs.get(userID); for (int i = 0; i < singleUserTempPrefs.length(); i++) { if (singleUserTempPrefs.getItemID(i) == itemID) { return singleUserTempPrefs.getValue(i); } } return null; } return getDelegate().getPreferenceValue(userID, itemID); }
PlusAnonymousConcurrentUserDataModel extends PlusAnonymousUserDataModel { @Override public Float getPreferenceValue(long userID, long itemID) throws TasteException { if (isAnonymousUser(userID)) { PreferenceArray singleUserTempPrefs = tempPrefs.get(userID); for (int i = 0; i < singleUserTempPrefs.length(); i++) { if (singleUserTempPrefs.getItemID(i) == itemID) { return singleUserTempPrefs.getValue(i); } } return null; } return getDelegate().getPreferenceValue(userID, itemID); } }
PlusAnonymousConcurrentUserDataModel extends PlusAnonymousUserDataModel { @Override public Float getPreferenceValue(long userID, long itemID) throws TasteException { if (isAnonymousUser(userID)) { PreferenceArray singleUserTempPrefs = tempPrefs.get(userID); for (int i = 0; i < singleUserTempPrefs.length(); i++) { if (singleUserTempPrefs.getItemID(i) == itemID) { return singleUserTempPrefs.getValue(i); } } return null; } return getDelegate().getPreferenceValue(userID, itemID); } PlusAnonymousConcurrentUserDataModel(DataModel delegate, int maxConcurrentUsers); }
PlusAnonymousConcurrentUserDataModel extends PlusAnonymousUserDataModel { @Override public Float getPreferenceValue(long userID, long itemID) throws TasteException { if (isAnonymousUser(userID)) { PreferenceArray singleUserTempPrefs = tempPrefs.get(userID); for (int i = 0; i < singleUserTempPrefs.length(); i++) { if (singleUserTempPrefs.getItemID(i) == itemID) { return singleUserTempPrefs.getValue(i); } } return null; } return getDelegate().getPreferenceValue(userID, itemID); } 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); }
PlusAnonymousConcurrentUserDataModel extends PlusAnonymousUserDataModel { @Override public Float getPreferenceValue(long userID, long itemID) throws TasteException { if (isAnonymousUser(userID)) { PreferenceArray singleUserTempPrefs = tempPrefs.get(userID); for (int i = 0; i < singleUserTempPrefs.length(); i++) { if (singleUserTempPrefs.getItemID(i) == itemID) { return singleUserTempPrefs.getValue(i); } } return null; } return getDelegate().getPreferenceValue(userID, itemID); } 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);  }