### Question:
ConsumerServiceImpl extends AbstractBaseService<ConsumerEntity> implements ConsumerService { @Override @Transactional(rollbackFor = Exception.class) public ConsumerDeRegisterResponse deRegister(ConsumerDeRegisterRequest deRegisterRequest) { ConsumerDeRegisterResponse response = new ConsumerDeRegisterResponse(); response.setSuc(true); if (deRegisterRequest == null || deRegisterRequest.getId() == 0) { response.setSuc(false); response.setMsg("ConsumerDeRegisterRequest id 不能为空！"); return response; } ConsumerEntity consumerEntity = get(deRegisterRequest.getId()); if (consumerEntity != null) { doDeleteConsumer(Arrays.asList(consumerEntity), 1); } 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 deRegisterTest() { ConsumerDeRegisterRequest deRegisterRequest = new ConsumerDeRegisterRequest(); assertEquals(false, consumerServiceImpl.deRegister(deRegisterRequest).isSuc()); deRegisterRequest.setId(1); List<ConsumerGroupConsumerEntity> consumerGroupConsumers = new ArrayList<ConsumerGroupConsumerEntity>(); ConsumerGroupConsumerEntity consumerGroupConsumerEntity = new ConsumerGroupConsumerEntity(); consumerGroupConsumerEntity.setConsumerGroupId(1L); consumerGroupConsumers.add(consumerGroupConsumerEntity); when(consumerGroupConsumerService.getByConsumerIds(anyListOf(Long.class))).thenReturn(consumerGroupConsumers); Map<Long, ConsumerGroupEntity> consumerGroupMap = new HashMap<Long, ConsumerGroupEntity>(); ConsumerGroupEntity consumerGroupEntity = new ConsumerGroupEntity(); consumerGroupEntity.setId(2L); consumerGroupEntity.setMode(2); consumerGroupEntity.setName("test"); consumerGroupEntity.setOriginName("test1"); consumerGroupMap.put(1L, consumerGroupEntity); when(consumerGroupService.getIdCache()).thenReturn(consumerGroupMap); Map<String, ConsumerGroupEntity> consumerGroupMap1 = new HashMap<String, ConsumerGroupEntity>(); consumerGroupMap1.put(consumerGroupEntity.getOriginName(), consumerGroupEntity); when(consumerGroupService.getCache()).thenReturn(consumerGroupMap1); consumerServiceImpl.deRegister(deRegisterRequest); verify(consumerGroupService).deleteConsumerGroup(anyLong(), anyBoolean()); verify(consumerGroupConsumerService).deleteByConsumerIds(anyListOf(Long.class)); }