### Question:
MetadataCounterGroup { public void addToCount(long countDelta, String dataType, String rowId, String date) { String hashMapKey = createKey(dataType, rowId, date); CountAndKeyComponents value = counts.get(hashMapKey); if (null == value) { counts.put(hashMapKey, new CountAndKeyComponents(dataType, rowId, date, countDelta)); } else { value.incrementCount(countDelta); } } MetadataCounterGroup(String groupName, Text tableName);  MetadataCounterGroup(Text counterIdentifier); void addToCount(long countDelta, String dataType, String rowId, String date); void clear(); Text getColumnFamily(); Collection<CountAndKeyComponents> getEntries();  }### Answer:
@Test public void testCountsDownCorrectly() { MetadataCounterGroup counters = new MetadataCounterGroup(COLUMN_FAMILY); counters.addToCount(-5, dataType, fieldName, date); counters.addToCount(-5, dataType, fieldName, date); assertOneEntryWithExpectedCount(counters, -10); }
@Test public void testCountsUpAndDownCorrectly() { MetadataCounterGroup counters = new MetadataCounterGroup(COLUMN_FAMILY); counters.addToCount(1, dataType, fieldName, date); counters.addToCount(1, dataType, fieldName, date); counters.addToCount(-1, dataType, fieldName, date); assertOneEntryWithExpectedCount(counters, 1); }
@Test public void testAssignments() { MetadataCounterGroup counters = new MetadataCounterGroup(COLUMN_FAMILY); counters.addToCount(1, dataType, fieldName, date); MetadataCounterGroup.CountAndKeyComponents entry = getOnlyEntry(counters); Assert.assertEquals(dataType, entry.getDataType()); Assert.assertEquals(fieldName, entry.getRowId()); Assert.assertEquals(date, entry.getDate()); }