### Question:
MetricsTableConfigHelper extends AbstractTableConfigHelper { @Override public void configure(TableOperations tops) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (MetricsConfiguration.isEnabled(conf)) { try { String table = MetricsConfiguration.getTable(conf); if (!table.equals(this.tableName)) { throw new IllegalArgumentException("Table names did not match. Configuration = " + table + ", Configuration Helper = " + this.tableName); } Collection<MetricsReceiver> receivers = MetricsConfiguration.getReceivers(conf); for (MetricsReceiver receiver : receivers) { logger.info("Configuring metrics receiver " + receiver); receiver.configureTable(table, tops, conf); } } catch (Exception e) { logger.error("An error occurred while configuring ingest metrics, disabling", e); MetricsConfiguration.disable(conf); } } }  @Override void setup(String tableName, Configuration conf, Logger logger); @Override void configure(TableOperations tops);  }### Answer:
@Test public void shouldDisableMetricsWhenConfigFails() throws Exception { String table = MetricsConfiguration.getTable(conf); TableOperations tops = EasyMock.createMock(TableOperations.class); EasyMock.expect(tops.getIteratorSetting(EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyObject(IteratorScope.class))).andThrow( new AccumuloException("")); EasyMock.replay(tops); configHelper.configure(tops); assertFalse(MetricsConfiguration.isEnabled(conf)); }
@Test public void shouldConfigureAggregators() throws Exception { String table = MetricsConfiguration.getTable(conf); configHelper.configure(tops); IteratorSetting is = tops.getIteratorSetting(table, "sum", IteratorScope.scan); assertEquals(SummingCombiner.class.getName(), is.getIteratorClass()); assertEquals(TestKeyValueCountMetricsReceiver.ITER_PRIORITY, is.getPriority()); Map<String,String> options = is.getOptions(); String type = options.get("type"); String columns = options.get("columns"); assertEquals(Metric.KV_PER_TABLE.toString(), columns); assertEquals("STRING", type); }
@Test public void shouldUpdateCombinerIfAlreadyExists() throws Exception { String table = MetricsConfiguration.getTable(conf); Map<String,String> options = new TreeMap<>(); options.put("type", "STRING"); options.put("columns", "COLUMN1"); IteratorSetting is = new IteratorSetting(TestKeyValueCountMetricsReceiver.ITER_PRIORITY, TestKeyValueCountMetricsReceiver.ITER_NAME, SummingCombiner.class.getName(), options); tops.attachIterator(table, is); configHelper.configure(tops); IteratorSetting newIter = tops.getIteratorSetting(table, "sum", IteratorScope.scan); assertEquals(SummingCombiner.class.getName(), newIter.getIteratorClass()); assertEquals(TestKeyValueCountMetricsReceiver.ITER_PRIORITY, newIter.getPriority()); Map<String,String> newOptions = newIter.getOptions(); String type = newOptions.get("type"); String columns = newOptions.get("columns"); assertEquals("COLUMN1," + Metric.KV_PER_TABLE, columns); assertEquals("STRING", type); }