### Question:
TableCountTask implements ReconOmTask { @Override public Pair<String, Boolean> process(OMUpdateEventBatch events) { Iterator<OMDBUpdateEvent> eventIterator = events.getIterator(); HashMap<String, Long> objectCountMap = initializeCountMap(); while (eventIterator.hasNext()) { OMDBUpdateEvent<String, Object> omdbUpdateEvent = eventIterator.next(); String rowKey = getRowKeyFromTable(omdbUpdateEvent.getTable()); try{ switch (omdbUpdateEvent.getAction()) { case PUT: objectCountMap.computeIfPresent(rowKey, (k, count) -> count + 1L); break; case DELETE: if (omdbUpdateEvent.getValue() != null) { String key = getRowKeyFromTable(omdbUpdateEvent.getTable()); objectCountMap.computeIfPresent(key, (k, count) -> count > 0 ? count - 1L : 0L); } break; default: LOG.trace("Skipping DB update event : Table: {}, Action: {}", omdbUpdateEvent.getTable(), omdbUpdateEvent.getAction()); } } catch (Exception e) { LOG.error("Unexpected exception while processing the table {}, " + "Action: {}", omdbUpdateEvent.getTable(), omdbUpdateEvent.getAction(), e); return new ImmutablePair<>(getTaskName(), false); } } for (Entry<String, Long> entry: objectCountMap.entrySet()) { ReconUtils.upsertGlobalStatsTable(sqlConfiguration, globalStatsDao, entry.getKey(), entry.getValue()); } LOG.info("Completed a 'process' run of TableCountTask."); return new ImmutablePair<>(getTaskName(), true); } @Inject  TableCountTask(GlobalStatsDao globalStatsDao,
                        Configuration sqlConfiguration,
                        ReconOMMetadataManager reconOMMetadataManager); @Override Pair<String, Boolean> reprocess(OMMetadataManager omMetadataManager); @Override String getTaskName(); @Override Collection<String> getTaskTables(); @Override Pair<String, Boolean> process(OMUpdateEventBatch events); static String getRowKeyFromTable(String tableName);  }### Answer:
@Test public void testProcess() { ArrayList<OMDBUpdateEvent> events = new ArrayList<>(); for (String tableName: tableCountTask.getTaskTables()) { for (int i=0; i<5; i++) { events.add(getOMUpdateEvent("item" + i, null, tableName, PUT)); } events.add(getOMUpdateEvent("item0", mock(OmKeyInfo.class), tableName, DELETE)); events.add(getOMUpdateEvent("item1", null, tableName, UPDATE)); } OMUpdateEventBatch omUpdateEventBatch = new OMUpdateEventBatch(events); tableCountTask.process(omUpdateEventBatch); assertEquals(4L, getCountForTable(KEY_TABLE)); assertEquals(4L, getCountForTable(VOLUME_TABLE)); assertEquals(4L, getCountForTable(BUCKET_TABLE)); assertEquals(4L, getCountForTable(OPEN_KEY_TABLE)); assertEquals(4L, getCountForTable(DELETED_TABLE)); ArrayList<OMDBUpdateEvent> newEvents = new ArrayList<>(); for (String tableName: tableCountTask.getTaskTables()) { newEvents.add(getOMUpdateEvent("item5", null, tableName, PUT)); newEvents.add(getOMUpdateEvent("item0", null, tableName, DELETE)); } omUpdateEventBatch = new OMUpdateEventBatch(newEvents); tableCountTask.process(omUpdateEventBatch); assertEquals(5L, getCountForTable(KEY_TABLE)); assertEquals(5L, getCountForTable(VOLUME_TABLE)); assertEquals(5L, getCountForTable(BUCKET_TABLE)); assertEquals(5L, getCountForTable(OPEN_KEY_TABLE)); assertEquals(5L, getCountForTable(DELETED_TABLE)); }