@Test public void testSet() throws Exception { ServerRecommender client = getRecommender(); client.setPreference("0", "1"); List<IDValue> recs = client.recommend("0", 1); assertEquals("50", recs.get(0).getID()); client.setPreference("0", "2", 3.0f); recs = client.recommend("0", 1); assertEquals("117", recs.get(0).getID()); client.setPreference("0", "2", -3.0f); recs = client.recommend("0", 1); assertEquals("117", recs.get(0).getID()); client.setPreference("0", "1", -1.0f); // Don't really know/care what will be recommend at this point; the feature vec is nearly 0 assertEquals(1, client.recommend("0", 1).size()); }
@Test public void testSetRemove() throws Exception { ServerRecommender client = getRecommender(); client.setPreference("0", "1"); List<IDValue> recs = client.recommend("0", 1); assertEquals("50", recs.get(0).getID()); client.setPreference("0", "2", 1.0f); recs = client.recommend("0", 1); assertEquals("50", recs.get(0).getID()); client.removePreference("0", "2"); recs = client.recommend("0", 1); assertEquals("50", recs.get(0).getID()); client.removePreference("0", "1"); try { client.recommend("0", 1); fail(); } catch (NoSuchUserException nsue) { // good } }