@Test
ublic void testCompleteJobWithFiltering() throws Exception {

  File inputFile = getTestTempFile("prefs.txt");
  File userFile = getTestTempFile("users.txt");
  File filterFile = getTestTempFile("filter.txt");
  File outputDir = getTestTempDir("output");
  outputDir.delete();
  File tmpDir = getTestTempDir("tmp");
  writeLines(inputFile,
      "1,1,5",
      "1,2,5",
      "1,3,2",
      "2,1,2",
      "2,3,3",
      "2,4,5",
      "3,2,5",
      "3,4,3",
      "4,1,3",
      "4,4,5");
  /* only compute recommendations for the donkey */
  writeLines(userFile, "4");
  /* do not recommend the hotdog for the donkey */
  writeLines(filterFile, "4,2");
  RecommenderJob recommenderJob = new RecommenderJob();
  Configuration conf = getConfiguration();
  conf.set("mapred.input.dir", inputFile.getAbsolutePath());
  conf.set("mapred.output.dir", outputDir.getAbsolutePath());
  conf.setBoolean("mapred.output.compress", false);
  recommenderJob.setConf(conf);
  recommenderJob.run(new String[] { "--tempDir", tmpDir.getAbsolutePath(), "--similarityClassname",
     TanimotoCoefficientSimilarity.class.getName(), "--numRecommendations", "1",
     "--usersFile", userFile.getAbsolutePath(), "--filterFile", filterFile.getAbsolutePath() });
  Map<Long,List<RecommendedItem>> recommendations = readRecommendations(new File(outputDir, "part-r-00000"));
  assertEquals(1, recommendations.size());
  assertTrue(recommendations.containsKey(4L));
  assertEquals(1, recommendations.get(4L).size());
  /* berries should have been recommended to the donkey */
  RecommendedItem recommendedItem = recommendations.get(4L).get(0);
  assertEquals(3L, recommendedItem.getItemID());
  assertEquals(3.5, recommendedItem.getValue(), 0.05);
}