### Question:
ConsumerCommitServiceImpl implements ConsumerCommitService, BrokerTimerService { protected void doCommit() { Map<Long, OffsetVersionEntity> offsetVersionMap = queueOffsetService.getOffsetVersion(); Map<Long, ConsumerQueueVersionDto> map = new HashMap<>(mapAppPolling.get()); if (map.size() > 0) { final int size = map.size(); Transaction transaction = Tracer.newTransaction("Timer-service", "commit"); try { int countSize = map.size() < commitThreadSize ? map.size() : commitThreadSize; if (countSize == 1) { for (Map.Entry<Long, ConsumerQueueVersionDto> entry : map.entrySet()) { doCommitOffset(entry.getValue(), 0, offsetVersionMap, size); } } else { CountDownLatch countDownLatch = new CountDownLatch(countSize); for (Map.Entry<Long, ConsumerQueueVersionDto> entry : map.entrySet()) { executorRun.execute(new Runnable() { @Override public void run() { doCommitOffset(entry.getValue(), 0, offsetVersionMap, size); countDownLatch.countDown(); } }); } countDownLatch.await(); } transaction.setStatus(Transaction.SUCCESS); } catch (Exception e) { transaction.setStatus(e); } finally { transaction.complete(); } } }  @Override void startBroker(); @Override CommitOffsetResponse commitOffset(CommitOffsetRequest request); @Override void stopBroker(); @Override String info(); @Override Map<Long, ConsumerQueueVersionDto> getCache();  }### Answer:
@Test public void doCommitTest() { Map<Long, OffsetVersionEntity> quMap=new HashMap<Long, OffsetVersionEntity>(); OffsetVersionEntity offsetVersionEntity=buildOffsetVersionEntity(); quMap.put(offsetVersionEntity.getId(), offsetVersionEntity); when(queueOffsetService.getOffsetVersion()).thenReturn(quMap); Map<Long, ConsumerQueueVersionDto> mapAppPolling=new HashMap<Long, ConsumerQueueVersionDto>(); List<ConsumerQueueVersionDto> queueOffsets = buildQueueOffsets(); mapAppPolling.put(queueOffsets.get(0).getQueueOffsetId(), queueOffsets.get(0)); consumerCommitServiceImpl.mapAppPolling.set(mapAppPolling); consumerCommitServiceImpl.doCommit(); verify(queueOffsetService,never()).commitOffset(any(QueueOffsetEntity.class)); ConsumerQueueVersionDto consumerQueueVersionDto=JsonUtil.copy(queueOffsets.get(0),ConsumerQueueVersionDto.class); consumerQueueVersionDto.setQueueOffsetId(consumerQueueVersionDto.getQueueOffsetId()+1); mapAppPolling.put(consumerQueueVersionDto.getQueueOffsetId(), consumerQueueVersionDto); consumerCommitServiceImpl.mapAppPolling.set(mapAppPolling); consumerCommitServiceImpl.doCommit(); verify(queueOffsetService,never()).commitOffset(any(QueueOffsetEntity.class)); }