ConsumerService { @Transactional public ConsumerToken createConsumerToken(ConsumerToken entity) { entity.setId(0); return consumerTokenRepository.save(entity); } ConsumerService(
      final UserInfoHolder userInfoHolder,
      final ConsumerTokenRepository consumerTokenRepository,
      final ConsumerRepository consumerRepository,
      final ConsumerAuditRepository consumerAuditRepository,
      final ConsumerRoleRepository consumerRoleRepository,
      final PortalConfig portalConfig,
      final RolePermissionService rolePermissionService,
      final UserService userService); Consumer createConsumer(Consumer consumer); ConsumerToken generateAndSaveConsumerToken(Consumer consumer, Date expires); ConsumerToken getConsumerTokenByAppId(String appId); Long getConsumerIdByToken(String token); Consumer getConsumerByConsumerId(long consumerId); List<ConsumerRole> assignNamespaceRoleToConsumer(String token, String appId, String namespaceName); @Transactional List<ConsumerRole> assignNamespaceRoleToConsumer(String token, String appId, String namespaceName, String env); @Transactional ConsumerRole assignAppRoleToConsumer(String token, String appId); @Transactional void createConsumerAudits(Iterable<ConsumerAudit> consumerAudits); @Transactional ConsumerToken createConsumerToken(ConsumerToken entity);  }
@Test public void testCreateConsumerToken() throws Exception { ConsumerToken someConsumerToken = mock(ConsumerToken.class); ConsumerToken savedConsumerToken = mock(ConsumerToken.class); when(consumerTokenRepository.save(someConsumerToken)).thenReturn(savedConsumerToken); assertEquals(savedConsumerToken, consumerService.createConsumerToken(someConsumerToken)); }