HistogramStatistics { public void setParameters(double max, double min, int numBins) { if (max <= min) { throw new DQStatisticsRuntimeException("max must be greater than min"); } if (numBins <= 0) { throw new DQStatisticsRuntimeException( "invalid numBins value :" + numBins + " , numBins must be a none zero integer"); } this.max = max; this.min = min; this.numBins = numBins; binSize = BigDecimal.valueOf(max - min).divide(BigDecimal.valueOf(numBins), 10, RoundingMode.UP); result = new long[numBins]; }  void setParameters(double max, double min, int numBins); void add(double d); Map<Range, Long> getHistogram(); boolean isComplete(); long getCountBelowMin(); long getCountAboveMax();  }
@Test public void testSetParameters1() { HistogramStatistics hs = new HistogramStatistics(); try { hs.setParameters(100d, 100d, 1); } catch (DQStatisticsRuntimeException e) { Assert.assertEquals("max must be greater than min", e.getMessage()); } }
@Test public void testSetParameters2() { HistogramStatistics hs = new HistogramStatistics(); try { hs.setParameters(100d, 101d, 1); } catch (DQStatisticsRuntimeException e) { Assert.assertEquals("max must be greater than min", e.getMessage()); } }
@Test public void testSetParameters3() { HistogramStatistics hs = new HistogramStatistics(); try { hs.setParameters(100d, 99d, 0); } catch (DQStatisticsRuntimeException e) { Assert.assertEquals("invalid numBins value :0 , numBins must be a none zero integer", e.getMessage()); } }
@Test public void testSetParameters4() { HistogramStatistics hs = new HistogramStatistics(); try { hs.setParameters(100d, 99d, -100); } catch (DQStatisticsRuntimeException e) { Assert.assertEquals("invalid numBins value :-100 , numBins must be a none zero integer", e.getMessage()); } }