@Test public void testUpdate() throws TechnicalException { Role role = new Role(); role.setName("testName"); Role roleCreated = roleRepository.create(role).blockingGet(); Role updatedRole = new Role(); updatedRole.setId(roleCreated.getId()); updatedRole.setName("testUpdatedName"); TestObserver<Role> testObserver = roleRepository.update(updatedRole).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(r -> r.getName().equals(updatedRole.getName())); }
@Override public Single<Role> update(Role item) { RoleMongo role = convert(item); return Single.fromPublisher(rolesCollection.replaceOne(eq(FIELD_ID, role.getId()), role)).flatMap(updateResult -> findById(role.getId()).toSingle()); }
MongoRoleRepository extends AbstractManagementMongoRepository implements RoleRepository { @Override public Single<Role> update(Role item) { RoleMongo role = convert(item); return Single.fromPublisher(rolesCollection.replaceOne(eq(FIELD_ID, role.getId()), role)).flatMap(updateResult -> findById(role.getId()).toSingle()); } }
MongoRoleRepository extends AbstractManagementMongoRepository implements RoleRepository { @Override public Single<Role> update(Role item) { RoleMongo role = convert(item); return Single.fromPublisher(rolesCollection.replaceOne(eq(FIELD_ID, role.getId()), role)).flatMap(updateResult -> findById(role.getId()).toSingle()); }  }
MongoRoleRepository extends AbstractManagementMongoRepository implements RoleRepository { @Override public Single<Role> update(Role item) { RoleMongo role = convert(item); return Single.fromPublisher(rolesCollection.replaceOne(eq(FIELD_ID, role.getId()), role)).flatMap(updateResult -> findById(role.getId()).toSingle()); }  @PostConstruct void init(); @Override Flowable<Role> findAll(ReferenceType referenceType, String referenceId); @Override Single<Set<Role>> findByDomain(String domain); @Override Single<Set<Role>> findByIdIn(List<String> ids); @Override Maybe<Role> findById(ReferenceType referenceType, String referenceId, String role); @Override Maybe<Role> findById(String role); @Override Single<Role> create(Role item); @Override Single<Role> update(Role item); @Override Completable delete(String id); @Override Maybe<Role> findByNameAndAssignableType(ReferenceType referenceType, String referenceId, String name, ReferenceType assignableType); }
MongoRoleRepository extends AbstractManagementMongoRepository implements RoleRepository { @Override public Single<Role> update(Role item) { RoleMongo role = convert(item); return Single.fromPublisher(rolesCollection.replaceOne(eq(FIELD_ID, role.getId()), role)).flatMap(updateResult -> findById(role.getId()).toSingle()); }  @PostConstruct void init(); @Override Flowable<Role> findAll(ReferenceType referenceType, String referenceId); @Override Single<Set<Role>> findByDomain(String domain); @Override Single<Set<Role>> findByIdIn(List<String> ids); @Override Maybe<Role> findById(ReferenceType referenceType, String referenceId, String role); @Override Maybe<Role> findById(String role); @Override Single<Role> create(Role item); @Override Single<Role> update(Role item); @Override Completable delete(String id); @Override Maybe<Role> findByNameAndAssignableType(ReferenceType referenceType, String referenceId, String name, ReferenceType assignableType); static final String FIELD_SYSTEM; }