RegionAnalysis { public void close() throws IOException { dataRangeHandler.reset(); for (int regionIndex : regionHandler.remaining()) { this.currentRegionName = regionNameList.get(regionIndex); statisticsWriter.createWriters(currentRegionName); writeEmptyRecords(regionIndex, dataRangeHandler.remaining()); statisticsWriter.closeWriters(currentRegionName); } statisticsWriter.close(); } RegionAnalysis(RADateRanges dateRanges, RAConfig raConfig, boolean binValuesAsRatio, WriterFactory writerFactor); void addData(long time, int numObs, float[][] samples, String... productNames); void startRegion(int regionId, String regionName); void endRegion(); void close();  }
@Test public void test_empty() throws Exception { RADateRanges dateRanges = RADateRanges.create("2010-01-01:2010-01-10"); RegionAnalysis ra = new RegionAnalysis(dateRanges, rac1, false, writer); ra.close(); Set<String> keySet = writer.writerMap.keySet(); assertEquals(2, keySet.size()); assertTrue(keySet.contains("region-statistics.csv")); assertTrue(keySet.contains("region-histogram-b1.csv")); String expected = "RegionId\tTimeWindow_start\tTimeWindow_end\tnumPasses\tnumObs\tb1_numValid\tb1_min\tb1_max\tb1_arithMean\tb1_sigma\tb1_geomMean\tb1_p05\tb1_p25\tb1_p50\tb1_p75\tb1_p95\n" + "r1\t2010-01-01 00:00:00\t2010-01-10 23:59:59\t0\t0\t0\tNaN\tNaN\tNaN\tNaN\tNaN\tNaN\tNaN\tNaN\tNaN\tNaN\n"; String actual = writer.writerMap.get("region-statistics.csv").toString(); assertEquals(expected, actual); expected = "RegionId\tTimeWindow_start\tTimeWindow_end\tnumPasses\tnumObs\tb1_belowHistogram\tb1_aboveHistogram\tb1_numBins\tb1_lowValue\tb1_highValue\tb1_bin_0\tb1_bin_1\tb1_bin_2\tb1_bin_3\tb1_bin_4\n" + "r1\t2010-01-01 00:00:00\t2010-01-10 23:59:59\t0\t0\t0\t0\t5\t0.0\t10.0\t0\t0\t0\t0\t0\n"; actual = writer.writerMap.get("region-histogram-b1.csv").toString(); assertEquals(expected, actual); }