### Question:
ConsumerServiceImpl extends AbstractBaseService<ConsumerEntity> implements ConsumerService { @Override @Transactional(rollbackFor = Exception.class) public ConsumerRegisterResponse register(ConsumerRegisterRequest request) { ConsumerRegisterResponse response = new ConsumerRegisterResponse(); response.setSuc(true); checkVaild(request, response); if (!response.isSuc()) { return response; } addRegisterLog(request); ConsumerEntity consumerEntity = doRegisterConsumer(request); response.setId(consumerEntity.getId()); if (soaConfig.getSdkVersion().compareTo(request.getSdkVersion()) > 0) { response.setMsg( "当前mq3客户端的版本已经落后了，最新版本为:" + soaConfig.getSdkVersion() + ",当前版本为:" + request.getSdkVersion()); } return response; }  @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 registerTest() { ConsumerRegisterRequest request = new ConsumerRegisterRequest(); request.setName("testt"); request.setSdkVersion("1"); consumerServiceImpl.register(request); verify(consumerRepository).register(any(ConsumerEntity.class)); doThrow(new RuntimeException("fa")).when(consumerRepository).register(any(ConsumerEntity.class)); when(consumerRepository.get(anyMapOf(String.class, Object.class))).thenReturn(new ConsumerEntity()); consumerServiceImpl.register(request); verify(consumerRepository).get(anyMapOf(String.class, Object.class)); }