### Question:
PhoenixHBaseAccessor { public void insertMetricRecords(TimelineMetrics metrics, boolean skipCache) throws SQLException, IOException { insertMetricRecordsWithMetadata(null, metrics, skipCache); } PhoenixHBaseAccessor(PhoenixConnectionProvider dataSource);   PhoenixHBaseAccessor(TimelineMetricConfiguration configuration, PhoenixConnectionProvider dataSource); boolean isInsertCacheEmpty(); void commitMetricsFromCache(); void commitMetrics(TimelineMetrics timelineMetrics); void commitMetrics(Collection<TimelineMetrics> timelineMetricsCollection); @SuppressWarnings("unchecked") static TreeMap<Long, Double> readMetricFromJSON(String json); Connection getConnectionRetryingOnException(); Connection getConnection(); void insertContainerMetrics(List<ContainerMetric> metrics); void insertMetricRecordsWithMetadata(TimelineMetricMetadataManager metadataManager,
                                              TimelineMetrics metrics, boolean skipCache); void insertMetricRecords(TimelineMetrics metrics, boolean skipCache); void insertMetricRecords(TimelineMetrics metrics); @SuppressWarnings("unchecked") TimelineMetrics getMetricRecords(
    final Condition condition, Multimap<String, List<Function>> metricFunctions); TimelineMetrics getAggregateMetricRecords(final Condition condition,
      Multimap<String, List<Function>> metricFunctions); void saveHostAggregateRecords(Map<TimelineMetric, MetricHostAggregate> hostAggregateMap,
                                       String phoenixTableName); void saveClusterAggregateRecords(Map<TimelineClusterMetric, MetricClusterAggregate> records); void saveClusterAggregateRecordsSecond(Map<TimelineClusterMetric, MetricHostAggregate> records,
                                                String tableName); boolean isSkipBlockCacheForAggregatorsEnabled(); void saveHostAppsMetadata(Map<String, TimelineMetricHostMetadata> hostMetadata); void saveInstanceHostsMetadata(Map<String, Set<String>> instanceHostsMap); void saveMetricMetadata(Collection<TimelineMetricMetadata> metricMetadata); Map<String, TimelineMetricHostMetadata> getHostedAppsMetadata(); Map<String, Set<String>> getInstanceHostsMetdata(); Map<TimelineMetricMetadataKey, TimelineMetricMetadata> getTimelineMetricMetadata(); List<TimelineMetricMetadata> scanMetricMetadataForWildCardRequest(Collection<String> metricNames,
                                                                           String appId,
                                                                           String instanceId); List<byte[]> scanHostMetadataForWildCardRequest(List<String> hostnames); Map<TimelineMetricMetadataKey, TimelineMetricMetadata> getTimelineMetricMetadataV1(); void setMetadataInstance(TimelineMetricMetadataManager metadataManager); static int RESULTSET_LIMIT; static int hostMinuteAggregatorDataInterval; static int clusterMinuteAggregatorDataInterval; static int clusterSecondAggregatorDataInterval; }### Answer:
@Test public void testMetricsCacheCommittingWhenFull() throws IOException, SQLException { Configuration hbaseConf = new Configuration(); hbaseConf.setStrings(ZOOKEEPER_QUORUM, "quorum"); final Connection connection = EasyMock.createNiceMock(Connection.class); accessor = new PhoenixHBaseAccessor(connectionProvider) { @Override public void commitMetrics(Collection<TimelineMetrics> timelineMetricsCollection) { try { connection.commit(); } catch (SQLException e) { e.printStackTrace(); } } }; TimelineMetrics timelineMetrics = EasyMock.createNiceMock(TimelineMetrics.class); 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); }