EmbeddedUserService implements UserService { @Override public boolean containsKey(final UUID key) { return userRepository.exists(key); } @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 testContainsKey() { Mockito.when(mockUserRepository.exists(RANDOM_UUID)).thenReturn(true); assertTrue(userService.containsKey(RANDOM_UUID)); Mockito.verify(mockUserRepository).exists(RANDOM_UUID); }