@Test
public void testMetricsCacheCommittingWhenFull() throws IOException, SQLException {

  Configuration hbaseConf = new Configuration();
  hbaseConf.setStrings(ZOOKEEPER_QUORUM, "quorum");
  Configuration metricsConf = new Configuration();
  metricsConf.setStrings(TimelineMetricConfiguration.TIMELINE_METRICS_CACHE_SIZE, "1");
  metricsConf.setStrings(TimelineMetricConfiguration.TIMELINE_METRICS_CACHE_COMMIT_INTERVAL, "100");
  final Connection connection = EasyMock.createNiceMock(Connection.class);
  PhoenixHBaseAccessor accessor = new PhoenixHBaseAccessor(hbaseConf, metricsConf) {
    @Override
    public void commitMetrics(Collection<TimelineMetrics> timelineMetricsCollection) {
      try {
        connection.commit();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }
  };
  TimelineMetrics timelineMetrics = EasyMock.createNiceMock(TimelineMetrics.class);
  EasyMock.expect(timelineMetrics.getMetrics()).andReturn(Collections.singletonList(new TimelineMetric())).anyTimes();
  connection.commit();
  EasyMock.expectLastCall().once();
  EasyMock.replay(timelineMetrics, connection);
  accessor.insertMetricRecords(timelineMetrics);
  accessor.insertMetricRecords(timelineMetrics);
  accessor.insertMetricRecords(timelineMetrics);
  EasyMock.verify(timelineMetrics, connection);
}