@Test public void testCreate() throws TechnicalException { Role role = new Role(); role.setName("testName"); TestObserver<Role> testObserver = roleRepository.create(role).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(r -> r.getName().equals(role.getName())); }
@Override public Single<Role> create(Role item) { RoleMongo role = convert(item); role.setId(role.getId() == null ? RandomString.generate() : role.getId()); return Single.fromPublisher(rolesCollection.insertOne(role)).flatMap(success -> findById(role.getId()).toSingle()); }
MongoRoleRepository extends AbstractManagementMongoRepository implements RoleRepository { @Override public Single<Role> create(Role item) { RoleMongo role = convert(item); role.setId(role.getId() == null ? RandomString.generate() : role.getId()); return Single.fromPublisher(rolesCollection.insertOne(role)).flatMap(success -> findById(role.getId()).toSingle()); } }
MongoRoleRepository extends AbstractManagementMongoRepository implements RoleRepository { @Override public Single<Role> create(Role item) { RoleMongo role = convert(item); role.setId(role.getId() == null ? RandomString.generate() : role.getId()); return Single.fromPublisher(rolesCollection.insertOne(role)).flatMap(success -> findById(role.getId()).toSingle()); }  }
MongoRoleRepository extends AbstractManagementMongoRepository implements RoleRepository { @Override public Single<Role> create(Role item) { RoleMongo role = convert(item); role.setId(role.getId() == null ? RandomString.generate() : role.getId()); return Single.fromPublisher(rolesCollection.insertOne(role)).flatMap(success -> 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> create(Role item) { RoleMongo role = convert(item); role.setId(role.getId() == null ? RandomString.generate() : role.getId()); return Single.fromPublisher(rolesCollection.insertOne(role)).flatMap(success -> 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; }