EmbeddedUserService implements UserService { @Override public long count() { return userRepository.count(); } @Autowired  EmbeddedUserService(final UserRepository userRepository, final SecureRandom secureRandom); @Override void save(final UserEntity userEntity); @Override UserEntity getById(final UUID key); @Override boolean containsKey(final UUID key); @Override boolean containsName(final String name); @Override UserEntity findByName(final String name); @Override String encrypt(final String raw); @Override boolean matches(final String raw, final String encoded); @Override long count();  }
@Test public void testCount() { Mockito.when(mockUserRepository.count()).thenReturn(COUNT); assertEquals(COUNT, Long.valueOf(userService.count())); Mockito.verify(mockUserRepository).count(); }