UsersInDb implements UsersWritable { @Override public User find(String login) { return new DatashareUser(userRepository.getUser(login)); } @Inject  UsersInDb(Repository userRepository); @Override User find(String login); @Override User find(String login, String password); @Override boolean saveOrUpdate(User user);  }
@Test public void find_user_in_db() { Repository repository = mock(Repository.class); User expected = new User("foo", "bar", "mail", "icij", new HashMap<String, Object>() {{ put("field1", "val1"); }}); when(repository.getUser("foo")).thenReturn(expected); User actual = (User) new UsersInDb(repository).find("foo"); assertThat(actual.id).isEqualTo(expected.id); assertThat(actual.name).isEqualTo(expected.name); assertThat(actual.email).isEqualTo(expected.email); assertThat(actual.details).isEqualTo(expected.details); assertThat(actual.provider).isEqualTo(expected.provider); }