@Test public void testUpdate() throws TechnicalException { User user = new User(); user.setReferenceType(ReferenceType.DOMAIN); user.setReferenceId("domainId"); user.setUsername("testsUsername"); User userCreated = userRepository.create(user).blockingGet(); User updatedUser = new User(); updatedUser.setReferenceType(ReferenceType.DOMAIN); updatedUser.setReferenceId("domainId"); updatedUser.setId(userCreated.getId()); updatedUser.setUsername("testUpdatedUsername"); TestObserver<User> testObserver = userRepository.update(updatedUser).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(u -> u.getUsername().equals(updatedUser.getUsername())); }
@Override public Single<User> update(User item) { UserMongo user = convert(item); return Single.fromPublisher(usersCollection.replaceOne(eq(FIELD_ID, user.getId()), user)).flatMap(updateResult -> findById(user.getId()).toSingle()); }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Single<User> update(User item) { UserMongo user = convert(item); return Single.fromPublisher(usersCollection.replaceOne(eq(FIELD_ID, user.getId()), user)).flatMap(updateResult -> findById(user.getId()).toSingle()); } }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Single<User> update(User item) { UserMongo user = convert(item); return Single.fromPublisher(usersCollection.replaceOne(eq(FIELD_ID, user.getId()), user)).flatMap(updateResult -> findById(user.getId()).toSingle()); }  }
MongoUserRepository extends AbstractManagementMongoRepository implements UserRepository { @Override public Single<User> update(User item) { UserMongo user = convert(item); return Single.fromPublisher(usersCollection.replaceOne(eq(FIELD_ID, user.getId()), user)).flatMap(updateResult -> findById(user.getId()).toSingle()); }  @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<User> update(User item) { UserMongo user = convert(item); return Single.fromPublisher(usersCollection.replaceOne(eq(FIELD_ID, user.getId()), user)).flatMap(updateResult -> findById(user.getId()).toSingle()); }  @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);  }