@Test public void testCreate() { Organization organization = new Organization(); organization.setName("testName"); TestObserver<Organization> obs = organizationRepository.create(organization).test(); obs.awaitTerminalEvent(); obs.assertComplete(); obs.assertNoErrors(); obs.assertValue(o -> o.getName().equals(organization.getName()) && o.getId() != null); }
@Override public Single<Organization> create(Organization organization) { organization.setId(organization.getId() == null ? RandomString.generate() : organization.getId()); return Single.fromPublisher(collection.insertOne(convert(organization))) .flatMap(success -> findById(organization.getId()).toSingle()); }
MongoOrganizationRepository extends AbstractManagementMongoRepository implements OrganizationRepository { @Override public Single<Organization> create(Organization organization) { organization.setId(organization.getId() == null ? RandomString.generate() : organization.getId()); return Single.fromPublisher(collection.insertOne(convert(organization))) .flatMap(success -> findById(organization.getId()).toSingle()); } }
MongoOrganizationRepository extends AbstractManagementMongoRepository implements OrganizationRepository { @Override public Single<Organization> create(Organization organization) { organization.setId(organization.getId() == null ? RandomString.generate() : organization.getId()); return Single.fromPublisher(collection.insertOne(convert(organization))) .flatMap(success -> findById(organization.getId()).toSingle()); }  }
MongoOrganizationRepository extends AbstractManagementMongoRepository implements OrganizationRepository { @Override public Single<Organization> create(Organization organization) { organization.setId(organization.getId() == null ? RandomString.generate() : organization.getId()); return Single.fromPublisher(collection.insertOne(convert(organization))) .flatMap(success -> findById(organization.getId()).toSingle()); }  @PostConstruct void init(); @Override Maybe<Organization> findById(String id); @Override Single<Organization> create(Organization organization); @Override Single<Organization> update(Organization organization); @Override Completable delete(String id); @Override Single<Long> count(); }
MongoOrganizationRepository extends AbstractManagementMongoRepository implements OrganizationRepository { @Override public Single<Organization> create(Organization organization) { organization.setId(organization.getId() == null ? RandomString.generate() : organization.getId()); return Single.fromPublisher(collection.insertOne(convert(organization))) .flatMap(success -> findById(organization.getId()).toSingle()); }  @PostConstruct void init(); @Override Maybe<Organization> findById(String id); @Override Single<Organization> create(Organization organization); @Override Single<Organization> update(Organization organization); @Override Completable delete(String id); @Override Single<Long> count(); static final String FIELD_ID; }