@Test public void testFindById() { Membership membership = new Membership(); membership.setRoleId("role#1"); membership.setReferenceType(ReferenceType.ORGANIZATION); membership.setReferenceId(ORGANIZATION_ID); membership.setMemberType(MemberType.USER); membership.setMemberId("user#1"); Membership createdMembership = membershipRepository.create(membership).blockingGet(); TestObserver<Membership> obs = membershipRepository.findById(createdMembership.getId()).test(); obs.awaitTerminalEvent(); obs.assertComplete(); obs.assertValue(m -> m.getId().equals(createdMembership.getId()) && m.getRoleId().equals(membership.getRoleId()) && m.getReferenceType() == membership.getReferenceType() && m.getReferenceId().equals(membership.getReferenceId()) && m.getMemberType() == membership.getMemberType() && m.getMemberId().equals(membership.getMemberId())); }
@Override public Maybe<Membership> findById(String id) { return Observable.fromPublisher(membershipsCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); }
MongoMembershipRepository extends AbstractManagementMongoRepository implements MembershipRepository { @Override public Maybe<Membership> findById(String id) { return Observable.fromPublisher(membershipsCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); } }
MongoMembershipRepository extends AbstractManagementMongoRepository implements MembershipRepository { @Override public Maybe<Membership> findById(String id) { return Observable.fromPublisher(membershipsCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); }  }
MongoMembershipRepository extends AbstractManagementMongoRepository implements MembershipRepository { @Override public Maybe<Membership> findById(String id) { return Observable.fromPublisher(membershipsCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); }  @PostConstruct void init(); @Override Single<List<Membership>> findByReference(String referenceId, ReferenceType referenceType); @Override Flowable<Membership> findByCriteria(ReferenceType referenceType, String referenceId, MembershipCriteria criteria); @Override Maybe<Membership> findByReferenceAndMember(ReferenceType referenceType, String referenceId, MemberType memberType, String memberId); @Override Maybe<Membership> findById(String id); @Override Single<Membership> create(Membership item); @Override Single<Membership> update(Membership item); @Override Completable delete(String id); }
MongoMembershipRepository extends AbstractManagementMongoRepository implements MembershipRepository { @Override public Maybe<Membership> findById(String id) { return Observable.fromPublisher(membershipsCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); }  @PostConstruct void init(); @Override Single<List<Membership>> findByReference(String referenceId, ReferenceType referenceType); @Override Flowable<Membership> findByCriteria(ReferenceType referenceType, String referenceId, MembershipCriteria criteria); @Override Maybe<Membership> findByReferenceAndMember(ReferenceType referenceType, String referenceId, MemberType memberType, String memberId); @Override Maybe<Membership> findById(String id); @Override Single<Membership> create(Membership item); @Override Single<Membership> update(Membership item); @Override Completable delete(String id); static final String FIELD_MEMBER_TYPE; static final String FIELD_ROLE; }