### Question:
ConsumerServiceImpl extends AbstractBaseService<ConsumerEntity> implements ConsumerService { protected void sendPublishFailMail(PublishMessageRequest request, Exception last, int type) { if (soaConfig.enableSendFailTopicMail(request.getTopicName())) { SendMailRequest request2 = new SendMailRequest(); request2.setServer(true); request2.setSubject("服务端,发送失败,topic:" + request.getTopicName()); request2.setContent(last.getMessage() + " and request json is " + JsonUtil.toJsonNull(request) + ",注意此邮件只是发给管理员注意情况,不代表消息发送最终失败,消息发送最终失败以客户端发送的邮件为准!"); request2.setType(type); request2.setTopicName(request.getTopicName()); request2.setKey("topic:" + request.getTopicName() + "-发送失败！"); emailService.sendProduceMail(request2); } }  @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 sendPublishFailMailTest() { PublishMessageRequest request=new PublishMessageRequest(); Exception last=new RuntimeException("testt"); request.setTopicName("Test"); consumerServiceImpl.sendPublishFailMail(request, last, 1); verify(emailService).sendProduceMail(any(SendMailRequest.class)); }