@Test public void testFindByDomain() throws TechnicalException { User user = new User(); user.setUsername("testsUsername"); user.setReferenceType(ReferenceType.DOMAIN); user.setReferenceId("testDomain"); userRepository.create(user).blockingGet(); TestObserver<Set<User>> testObserver = userRepository.findByDomain("testDomain").test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(users -> users.size() == 1); }
@Override public Single<Set<User>> findByDomain(String domain) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, DOMAIN.name()), eq(FIELD_REFERENCE_ID, domain)))).map(this::convert).collect(HashSet::new, Set::add); }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Single<Set<User>> findByDomain(String domain) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, DOMAIN.name()), eq(FIELD_REFERENCE_ID, domain)))).map(this::convert).collect(HashSet::new, Set::add); } }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Single<Set<User>> findByDomain(String domain) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, DOMAIN.name()), eq(FIELD_REFERENCE_ID, domain)))).map(this::convert).collect(HashSet::new, Set::add); }  }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Single<Set<User>> findByDomain(String domain) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, DOMAIN.name()), eq(FIELD_REFERENCE_ID, domain)))).map(this::convert).collect(HashSet::new, Set::add); }  @PostConstruct void init(); @Override Single<Set<User>> findByDomain(String domain); @Override Single<Page<User>> findAll(ReferenceType referenceType, String referenceId, int page, int size); @Override Single<Page<User>> findByDomain(String domain, int page, int size); @Override Single<Page<User>> search(ReferenceType referenceType, String referenceId, String query, int page, int size); @Override Single<Page<User>> search(String domain, String query, int page, int size); @Override Single<List<User>> findByDomainAndEmail(String domain, String email, boolean strict); @Override Maybe<User> findByUsernameAndDomain(String domain, String username); @Override Maybe<User> findByUsernameAndSource(ReferenceType referenceType, String referenceId, String username, String source); @Override Maybe<User> findByDomainAndUsernameAndSource(String domain, String username, String source); @Override Maybe<User> findByExternalIdAndSource(ReferenceType referenceType, String referenceId, String externalId, String source); @Override Single<List<User>> findByIdIn(List<String> ids); @Override Maybe<User> findById(ReferenceType referenceType, String referenceId, String userId); @Override Maybe<User> findById(String userId); @Override Single<User> create(User item); @Override Single<User> update(User item); @Override Completable delete(String id); @Override Single<Long> countByDomain(String domain); @Override Single<Map<Object, Object>> statistics(AnalyticsQuery query); }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Single<Set<User>> findByDomain(String domain) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, DOMAIN.name()), eq(FIELD_REFERENCE_ID, domain)))).map(this::convert).collect(HashSet::new, Set::add); }  @PostConstruct void init(); @Override Single<Set<User>> findByDomain(String domain); @Override Single<Page<User>> findAll(ReferenceType referenceType, String referenceId, int page, int size); @Override Single<Page<User>> findByDomain(String domain, int page, int size); @Override Single<Page<User>> search(ReferenceType referenceType, String referenceId, String query, int page, int size); @Override Single<Page<User>> search(String domain, String query, int page, int size); @Override Single<List<User>> findByDomainAndEmail(String domain, String email, boolean strict); @Override Maybe<User> findByUsernameAndDomain(String domain, String username); @Override Maybe<User> findByUsernameAndSource(ReferenceType referenceType, String referenceId, String username, String source); @Override Maybe<User> findByDomainAndUsernameAndSource(String domain, String username, String source); @Override Maybe<User> findByExternalIdAndSource(ReferenceType referenceType, String referenceId, String externalId, String source); @Override Single<List<User>> findByIdIn(List<String> ids); @Override Maybe<User> findById(ReferenceType referenceType, String referenceId, String userId); @Override Maybe<User> findById(String userId); @Override Single<User> create(User item); @Override Single<User> update(User item); @Override Completable delete(String id); @Override Single<Long> countByDomain(String domain); @Override Single<Map<Object, Object>> statistics(AnalyticsQuery query);  }