@Test public void testFindById() throws TechnicalException { User user = new User(); user.setReferenceType(ReferenceType.DOMAIN); user.setReferenceId("domainId"); user.setUsername("testsUsername"); User userCreated = userRepository.create(user).blockingGet(); TestObserver<User> testObserver = userRepository.findById(userCreated.getId()).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(u -> u.getUsername().equals("testsUsername")); }
@Override public Maybe<User> findById(ReferenceType referenceType, String referenceId, String userId) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, referenceType.name()), eq(FIELD_REFERENCE_ID, referenceId), eq(FIELD_ID, userId))).first()).firstElement().map(this::convert); }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Maybe<User> findById(ReferenceType referenceType, String referenceId, String userId) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, referenceType.name()), eq(FIELD_REFERENCE_ID, referenceId), eq(FIELD_ID, userId))).first()).firstElement().map(this::convert); } }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Maybe<User> findById(ReferenceType referenceType, String referenceId, String userId) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, referenceType.name()), eq(FIELD_REFERENCE_ID, referenceId), eq(FIELD_ID, userId))).first()).firstElement().map(this::convert); }  }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Maybe<User> findById(ReferenceType referenceType, String referenceId, String userId) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, referenceType.name()), eq(FIELD_REFERENCE_ID, referenceId), eq(FIELD_ID, userId))).first()).firstElement().map(this::convert); }  @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 Maybe<User> findById(ReferenceType referenceType, String referenceId, String userId) { return Observable.fromPublisher(usersCollection.find(and(eq(FIELD_REFERENCE_TYPE, referenceType.name()), eq(FIELD_REFERENCE_ID, referenceId), eq(FIELD_ID, userId))).first()).firstElement().map(this::convert); }  @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);  }