### Question:
ConsumerServiceImpl extends AbstractBaseService<ConsumerEntity> implements ConsumerService { protected void addRegisterConsumerGroupLog(ConsumerGroupRegisterRequest request, ConsumerGroupRegisterResponse response) { String json = JsonUtil.toJsonNull(request); if (request != null && request.getConsumerGroupNames() != null) { List<AuditLogEntity> auditLogs = new ArrayList<>(request.getConsumerGroupNames().size()); Map<String, ConsumerGroupEntity> consumerGroupMap = consumerGroupService.getCache(); request.getConsumerGroupNames().keySet().forEach(t1 -> { ConsumerGroupEntity temp = consumerGroupMap.get(t1); if (temp != null) { AuditLogEntity auditLog = new AuditLogEntity(); auditLog.setContent("注册失败！入参是：" + json + ",原因是:" + response.getMsg()); auditLog.setTbName(ConsumerGroupEntity.TABLE_NAME); auditLog.setRefId(temp.getId()); auditLogs.add(auditLog); } }); auditLogService.insertBatch(auditLogs); } else { AuditLogEntity auditLog = new AuditLogEntity(); auditLog.setContent("注册失败！入参是：" + json + ",原因是:" + response.getMsg()); auditLog.setTbName(ConsumerGroupEntity.TABLE_NAME); auditLog.setRefId(0); auditLogService.insert(auditLog); } }  @Override @Transactional(rollbackFor = Exception.class) ConsumerRegisterResponse register(ConsumerRegisterRequest request); @Override @Transactional(rollbackFor = Exception.class) ConsumerDeRegisterResponse deRegister(ConsumerDeRegisterRequest deRegisterRequest); @Override void heartbeat(List<Long> ids); @Override List<ConsumerGroupConsumerEntity> getConsumerGroupByConsumerIds(List<Long> consumerIds); @Override List<ConsumerGroupConsumerEntity> getConsumerGroupByConsumerGroupIds(List<Long> consumerGroupIds); @Override //@Transactional(rollbackFor = Exception.class) ConsumerGroupRegisterResponse registerConsumerGroup(ConsumerGroupRegisterRequest request); @Override PublishMessageResponse publish(PublishMessageRequest request); void notifyClient(QueueEntity queueEntity); @Override PullDataResponse pullData(PullDataRequest request); @Override GetMessageCountResponse getMessageCount(GetMessageCountRequest request); @Override List<ConsumerEntity> findByHeartTimeInterval(long heartTimeInterval); @Override boolean deleteByConsumers(List<ConsumerEntity> consumers); @Override ConsumerEntity getConsumerByConsumerGroupId(Long consumerGroupId); @Override long countBy(Map<String, Object> conditionMap); @Override List<ConsumerEntity> getListBy(Map<String, Object> conditionMap); @Override FailMsgPublishAndUpdateResultResponse publishAndUpdateResultFailMsg(
            FailMsgPublishAndUpdateResultRequest request);  }### Answer:
@Test public void addRegisterConsumerGroupLogTest() { ConsumerGroupRegisterRequest request=new ConsumerGroupRegisterRequest(); ConsumerGroupRegisterResponse response=new ConsumerGroupRegisterResponse(); Map<String, List<String>> consumerGroupNames=new HashMap<String, List<String>>(); consumerGroupNames.put("Test", new ArrayList<String>()); request.setConsumerGroupNames(consumerGroupNames); Map<String, ConsumerGroupEntity> conMap=new HashMap<String, ConsumerGroupEntity>(); conMap.put("Test", new ConsumerGroupEntity()); when(consumerGroupService.getCache()).thenReturn(conMap); consumerServiceImpl.addRegisterConsumerGroupLog(request, response); verify(auditLogService).insertBatch(anyListOf(AuditLogEntity.class)); request.setConsumerGroupNames(null); consumerServiceImpl.addRegisterConsumerGroupLog(request, response); verify(auditLogService).insert(any(AuditLogEntity.class)); }