### Question:
LogServiceImpl implements LogService { @Override public void addOpLog(OpLogRequest request) { if (request == null || StringUtils.isEmpty(request.getConsumerGroupName())) { return; } Map<String, ConsumerGroupEntity> cache = consumerGroupService.getCache(); if (!cache.containsKey(request.getConsumerGroupName())) { return; } AuditLogEntity auditLog = new AuditLogEntity(); auditLog.setContent(request.getContent()); auditLog.setTbName(ConsumerGroupEntity.TABLE_NAME); auditLog.setRefId(cache.get(request.getConsumerGroupName()).getId()); auditLog.setInsertBy(request.getConsumerName()); auditLogService.insert(auditLog); }  @Override void addConsumerLog(LogRequest request); @Override void addBrokerLog(LogDto request); @Override void addOpLog(OpLogRequest request);  }### Answer:
@Test public void addOpLogTest() { OpLogRequest logRequest=new OpLogRequest(); logServiceImpl.addOpLog(logRequest); verify(auditLogService,times(0)).insert(any(AuditLogEntity.class)); logServiceImpl.addOpLog(null); verify(auditLogService,times(0)).insert(any(AuditLogEntity.class)); logRequest.setConsumerGroupName("test"); logServiceImpl.addOpLog(logRequest); verify(auditLogService,times(0)).insert(any(AuditLogEntity.class)); Map<String, ConsumerGroupEntity> map =new HashMap<String, ConsumerGroupEntity>(); ConsumerGroupEntity consumerGroupEntity=new ConsumerGroupEntity(); consumerGroupEntity.setTraceFlag(1); map.put(logRequest.getConsumerGroupName(), consumerGroupEntity); when(consumerGroupService.getCache()).thenReturn(map); logServiceImpl.addOpLog(logRequest); verify(auditLogService,times(1)).insert(any(AuditLogEntity.class)); }