### Question:
LogServiceImpl implements LogService { @Override public void addBrokerLog(LogDto request) { if (request.getType() >= 3) { Map<String, ConsumerGroupEntity> cache = consumerGroupService.getCache(); if (!StringUtils.isEmpty(request.getConsumerGroupName()) && cache.containsKey(request.getConsumerGroupName())) { if (cache.get(request.getConsumerGroupName()).getTraceFlag() == 1) { log.info(getLog(request)); return; } } } else if (request.getType() == 1) { log.error(getLog(request), request.getThrowable()); } else if (request.getType() == 2) { log.warn(getLog(request)); } }  @Override void addConsumerLog(LogRequest request); @Override void addBrokerLog(LogDto request); @Override void addOpLog(OpLogRequest request);  }### Answer:
@Test public void addBrokerLogTest() { LogDto logDto=new LogDto(); logDto.setConsumerGroupName("Test"); logDto.setType(1); Map<String, ConsumerGroupEntity> map =new HashMap<String, ConsumerGroupEntity>(); ConsumerGroupEntity consumerGroupEntity=new ConsumerGroupEntity(); consumerGroupEntity.setTraceFlag(1); map.put(logDto.getConsumerGroupName(), consumerGroupEntity); when(consumerGroupService.getCache()).thenReturn(map); logServiceImpl.addBrokerLog(logDto); logDto.setType(2); logServiceImpl.addBrokerLog(logDto); logDto.setType(3); logServiceImpl.addBrokerLog(logDto); }