ConsumerService { public Consumer getConsumerByConsumerId(long consumerId) { return consumerRepository.findById(consumerId).orElse(null); } 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 testGetConsumerByConsumerId() throws Exception { long someConsumerId = 1; Consumer someConsumer = mock(Consumer.class); when(consumerRepository.findById(someConsumerId)).thenReturn(Optional.of(someConsumer)); assertEquals(someConsumer, consumerService.getConsumerByConsumerId(someConsumerId)); verify(consumerRepository, times(1)).findById(someConsumerId); }