### Question:
GenericRecommenderBuilder implements RecommenderBuilder { @Override public Recommender buildRecommender(final DataModel dataModel) throws TasteException { return new RandomRecommender(dataModel); }  @Override Recommender buildRecommender(final DataModel dataModel); Recommender buildRecommender(final DataModel dataModel, final String recType); Recommender buildRecommender(final DataModel dataModel, final String recType, final String simType); Recommender buildRecommender(final DataModel dataModel, final String recType, final String simType, final int nbSize); Recommender buildRecommender(final DataModel dataModel, final String recType, final String facType, final int iterations, final int factors); Recommender buildRecommender(final DataModel dataModel,
            final String recType,
            final String similarityType,
            final int neighborhoodSize,
            final int factors,
            final int iterations,
            final String facType); static final int DEFAULT_N; static final int NO_N; static final int NOITER; static final int NOFACTORS; }### Answer:
@Test public void testBuildDefaultRecommender() { RecommenderBuilder rb = new GenericRecommenderBuilder(); FastByIDMap<PreferenceArray> userData = new FastByIDMap<PreferenceArray>(); userData.put(1, new GenericUserPreferenceArray(Arrays.asList(new GenericPreference(1, 1, 1), new GenericPreference(1, 2, 1), new GenericPreference(1, 3, 1)))); userData.put(2, new GenericUserPreferenceArray(Arrays.asList(new GenericPreference(2, 1, 1), new GenericPreference(2, 2, 1), new GenericPreference(2, 4, 1)))); DataModel dm = new GenericDataModel(userData); Recommender rec = null; try { rec = rb.buildRecommender(dm); } catch (TasteException e) { e.printStackTrace(); } assertTrue(rec instanceof RandomRecommender); }
@Test public void testBuildKNNRecommender() { GenericRecommenderBuilder rb = new GenericRecommenderBuilder(); FastByIDMap<PreferenceArray> userData = new FastByIDMap<PreferenceArray>(); userData.put(1, new GenericUserPreferenceArray(Arrays.asList(new GenericPreference(1, 1, 1), new GenericPreference(1, 2, 1), new GenericPreference(1, 3, 1)))); userData.put(2, new GenericUserPreferenceArray(Arrays.asList(new GenericPreference(2, 1, 1), new GenericPreference(2, 2, 1), new GenericPreference(2, 4, 1)))); DataModel dm = new GenericDataModel(userData); Recommender rec = null; String recommenderType = "org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender"; String similarityType = "org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity"; try { rec = rb.buildRecommender(dm, recommenderType, similarityType); } catch (RecommenderException e) { e.printStackTrace(); } assertTrue(rec instanceof GenericUserBasedRecommender); }