@Test
public void toyIntegration() throws Exception {

  File inputFile = getTestTempFile("rows");
  File outputDir = getTestTempDir("output");
  outputDir.delete();
  File tmpDir = getTestTempDir("tmp");
  Configuration conf = getConfiguration();
  Path inputPath = new Path(inputFile.getAbsolutePath());
  FileSystem fs = FileSystem.get(inputPath.toUri(), conf);
  MathHelper.writeDistributedRowMatrix(new double[][] {
      new double[] { 1, 0, 1, 1, 0 },
      new double[] { 0, 0, 1, 1, 0 },
      new double[] { 0, 0, 0, 0, 1 } },
      fs, conf, inputPath);
  RowSimilarityJob rowSimilarityJob = new RowSimilarityJob();
  rowSimilarityJob.setConf(conf);
  rowSimilarityJob.run(new String[] { "--input", inputFile.getAbsolutePath(), "--output", outputDir.getAbsolutePath(),
      "--numberOfColumns", String.valueOf(5), "--similarityClassname", TanimotoCoefficientSimilarity.class.getName(),
      "--tempDir", tmpDir.getAbsolutePath() });
  OpenIntIntHashMap observationsPerColumn =
      Vectors.readAsIntMap(new Path(tmpDir.getAbsolutePath(), "observationsPerColumn.bin"), conf);
  assertEquals(4, observationsPerColumn.size());
  assertEquals(1, observationsPerColumn.get(0));
  assertEquals(2, observationsPerColumn.get(2));
  assertEquals(2, observationsPerColumn.get(3));
  assertEquals(1, observationsPerColumn.get(4));
  Matrix similarityMatrix = MathHelper.readMatrix(conf, new Path(outputDir.getAbsolutePath(), "part-r-00000"), 3, 3);
  assertNotNull(similarityMatrix);
  assertEquals(3, similarityMatrix.numCols());
  assertEquals(3, similarityMatrix.numRows());
  assertEquals(1.0, similarityMatrix.get(0, 0), EPSILON);
  assertEquals(1.0, similarityMatrix.get(1, 1), EPSILON);
  assertEquals(1.0, similarityMatrix.get(2, 2), EPSILON);
  assertEquals(0.0, similarityMatrix.get(2, 0), EPSILON);
  assertEquals(0.0, similarityMatrix.get(2, 1), EPSILON);
  assertEquals(0.0, similarityMatrix.get(0, 2), EPSILON);
  assertEquals(0.0, similarityMatrix.get(1, 2), EPSILON);
  assertEquals(0.666666, similarityMatrix.get(0, 1), EPSILON);
  assertEquals(0.666666, similarityMatrix.get(1, 0), EPSILON);
}