@Test public void testObserveChildEventMoved() { TestSubscriber<RxFirebaseChildEvent<ChildData>> testObserver = RxFirebaseDatabase .observeChildEvent(databaseReference, ChildData.class) .test(); ArgumentCaptor<ChildEventListener> argument = ArgumentCaptor.forClass(ChildEventListener.class); verify(databaseReference).addChildEventListener(argument.capture()); argument.getValue().onChildMoved(dataSnapshot, PREVIOUS_CHILD_NAME); testObserver.assertNoErrors() .assertValueCount(1) .assertValueSet(Collections.singletonList(childEventMoved)) .assertNotComplete() .dispose(); }
@NonNull public static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent( @NonNull final Query query, @NonNull BackpressureStrategy strategy) { return Flowable.create(new FlowableOnSubscribe<RxFirebaseChildEvent<DataSnapshot>>() { @Override public void subscribe(final FlowableEmitter<RxFirebaseChildEvent<DataSnapshot>> emitter) throws Exception { final ChildEventListener childEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.ADDED)); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.CHANGED)); } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { emitter.onNext(new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, RxFirebaseChildEvent.EventType.REMOVED)); } @Override public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.MOVED)); } @Override public void onCancelled(DatabaseError error) { if (!emitter.isCancelled()) emitter.onError(new RxFirebaseDataException(error)); } }; emitter.setCancellable(new Cancellable() { @Override public void cancel() throws Exception { query.removeEventListener(childEventListener); } }); query.addChildEventListener(childEventListener); } }, strategy); }
RxFirebaseDatabase { @NonNull public static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent( @NonNull final Query query, @NonNull BackpressureStrategy strategy) { return Flowable.create(new FlowableOnSubscribe<RxFirebaseChildEvent<DataSnapshot>>() { @Override public void subscribe(final FlowableEmitter<RxFirebaseChildEvent<DataSnapshot>> emitter) throws Exception { final ChildEventListener childEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.ADDED)); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.CHANGED)); } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { emitter.onNext(new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, RxFirebaseChildEvent.EventType.REMOVED)); } @Override public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.MOVED)); } @Override public void onCancelled(DatabaseError error) { if (!emitter.isCancelled()) emitter.onError(new RxFirebaseDataException(error)); } }; emitter.setCancellable(new Cancellable() { @Override public void cancel() throws Exception { query.removeEventListener(childEventListener); } }); query.addChildEventListener(childEventListener); } }, strategy); } }
RxFirebaseDatabase { @NonNull public static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent( @NonNull final Query query, @NonNull BackpressureStrategy strategy) { return Flowable.create(new FlowableOnSubscribe<RxFirebaseChildEvent<DataSnapshot>>() { @Override public void subscribe(final FlowableEmitter<RxFirebaseChildEvent<DataSnapshot>> emitter) throws Exception { final ChildEventListener childEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.ADDED)); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.CHANGED)); } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { emitter.onNext(new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, RxFirebaseChildEvent.EventType.REMOVED)); } @Override public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.MOVED)); } @Override public void onCancelled(DatabaseError error) { if (!emitter.isCancelled()) emitter.onError(new RxFirebaseDataException(error)); } }; emitter.setCancellable(new Cancellable() { @Override public void cancel() throws Exception { query.removeEventListener(childEventListener); } }); query.addChildEventListener(childEventListener); } }, strategy); }  }
RxFirebaseDatabase { @NonNull public static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent( @NonNull final Query query, @NonNull BackpressureStrategy strategy) { return Flowable.create(new FlowableOnSubscribe<RxFirebaseChildEvent<DataSnapshot>>() { @Override public void subscribe(final FlowableEmitter<RxFirebaseChildEvent<DataSnapshot>> emitter) throws Exception { final ChildEventListener childEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.ADDED)); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.CHANGED)); } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { emitter.onNext(new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, RxFirebaseChildEvent.EventType.REMOVED)); } @Override public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.MOVED)); } @Override public void onCancelled(DatabaseError error) { if (!emitter.isCancelled()) emitter.onError(new RxFirebaseDataException(error)); } }; emitter.setCancellable(new Cancellable() { @Override public void cancel() throws Exception { query.removeEventListener(childEventListener); } }); query.addChildEventListener(childEventListener); } }, strategy); }  @NonNull static Flowable<DataSnapshot> observeValueEvent(@NonNull final Query query,
                                                           @NonNull BackpressureStrategy strategy); @NonNull static Maybe<DataSnapshot> observeSingleValueEvent(@NonNull final Query query); @NonNull static Single<DataSnapshot> runTransaction(@NonNull final DatabaseReference ref,
                                                      @NonNull final boolean fireLocalEvents,
                                                      @NonNull final long transactionValue); @NonNull static Completable setValue(@NonNull final DatabaseReference ref,
                                       final Object value); @NonNull static Completable updateChildren(@NonNull final DatabaseReference ref,
                                             @NonNull final Map<String, Object> updateData); @NonNull static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent(
        @NonNull final Query query, @NonNull BackpressureStrategy strategy); @NonNull static Flowable<DataSnapshot> observeMultipleSingleValueEvent(@NonNull DatabaseReference... whereRefs); @NonNull static Maybe<DatabaseReference[]> requestFilteredReferenceKeys(@NonNull final DatabaseReference from,
                                                                          @NonNull Query whereRef); @NonNull static Flowable<T> observeValueEvent(@NonNull final Query query,
                                                    @NonNull final Class<T> clazz,
                                                    @NonNull BackpressureStrategy strategy); @NonNull static Maybe<T> observeSingleValueEvent(@NonNull final Query query,
                                                       @NonNull final Class<T> clazz); @NonNull static Flowable<RxFirebaseChildEvent<T>> observeChildEvent(
        @NonNull final Query query, @NonNull final Class<T> clazz,
        @NonNull BackpressureStrategy strategy); @NonNull static Flowable<T> observeValueEvent(@NonNull final Query query,
                                                    @NonNull final Function<? super DataSnapshot, ? extends T> mapper,
                                                    @NonNull BackpressureStrategy strategy); @NonNull static Maybe<T> observeSingleValueEvent(@NonNull final Query query,
                                                       @NonNull final Function<? super DataSnapshot, ? extends T> mapper); @NonNull static Flowable<RxFirebaseChildEvent<T>> observeChildEvent(
        @NonNull final Query query, @NonNull final Function<? super RxFirebaseChildEvent<DataSnapshot>,
        ? extends RxFirebaseChildEvent<T>> mapper, @NonNull BackpressureStrategy strategy); @NonNull static Flowable<DataSnapshot> observeValueEvent(@NonNull final Query query); @NonNull static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent(
        @NonNull final Query query); @NonNull static Single<DataSnapshot> runTransaction(@NonNull final DatabaseReference ref,
                                                      @NonNull final long transactionValue); @NonNull static Flowable<T> observeValueEvent(@NonNull final Query query,
                                                    @NonNull final Class<T> clazz); @NonNull static Flowable<RxFirebaseChildEvent<T>> observeChildEvent(
        @NonNull final Query query, @NonNull final Class<T> clazz); @NonNull static Flowable<T> observeValueEvent(@NonNull final Query query,
                                                    @NonNull final Function<? super DataSnapshot, ? extends T> mapper); @NonNull static Flowable<RxFirebaseChildEvent<T>> observeChildEvent(
        @NonNull final Query query, @NonNull final Function<? super RxFirebaseChildEvent<DataSnapshot>,
        ? extends RxFirebaseChildEvent<T>> mapper); }
RxFirebaseDatabase { @NonNull public static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent( @NonNull final Query query, @NonNull BackpressureStrategy strategy) { return Flowable.create(new FlowableOnSubscribe<RxFirebaseChildEvent<DataSnapshot>>() { @Override public void subscribe(final FlowableEmitter<RxFirebaseChildEvent<DataSnapshot>> emitter) throws Exception { final ChildEventListener childEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.ADDED)); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.CHANGED)); } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { emitter.onNext(new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, RxFirebaseChildEvent.EventType.REMOVED)); } @Override public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) { emitter.onNext( new RxFirebaseChildEvent<>(dataSnapshot.getKey(), dataSnapshot, previousChildName, RxFirebaseChildEvent.EventType.MOVED)); } @Override public void onCancelled(DatabaseError error) { if (!emitter.isCancelled()) emitter.onError(new RxFirebaseDataException(error)); } }; emitter.setCancellable(new Cancellable() { @Override public void cancel() throws Exception { query.removeEventListener(childEventListener); } }); query.addChildEventListener(childEventListener); } }, strategy); }  @NonNull static Flowable<DataSnapshot> observeValueEvent(@NonNull final Query query,
                                                           @NonNull BackpressureStrategy strategy); @NonNull static Maybe<DataSnapshot> observeSingleValueEvent(@NonNull final Query query); @NonNull static Single<DataSnapshot> runTransaction(@NonNull final DatabaseReference ref,
                                                      @NonNull final boolean fireLocalEvents,
                                                      @NonNull final long transactionValue); @NonNull static Completable setValue(@NonNull final DatabaseReference ref,
                                       final Object value); @NonNull static Completable updateChildren(@NonNull final DatabaseReference ref,
                                             @NonNull final Map<String, Object> updateData); @NonNull static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent(
        @NonNull final Query query, @NonNull BackpressureStrategy strategy); @NonNull static Flowable<DataSnapshot> observeMultipleSingleValueEvent(@NonNull DatabaseReference... whereRefs); @NonNull static Maybe<DatabaseReference[]> requestFilteredReferenceKeys(@NonNull final DatabaseReference from,
                                                                          @NonNull Query whereRef); @NonNull static Flowable<T> observeValueEvent(@NonNull final Query query,
                                                    @NonNull final Class<T> clazz,
                                                    @NonNull BackpressureStrategy strategy); @NonNull static Maybe<T> observeSingleValueEvent(@NonNull final Query query,
                                                       @NonNull final Class<T> clazz); @NonNull static Flowable<RxFirebaseChildEvent<T>> observeChildEvent(
        @NonNull final Query query, @NonNull final Class<T> clazz,
        @NonNull BackpressureStrategy strategy); @NonNull static Flowable<T> observeValueEvent(@NonNull final Query query,
                                                    @NonNull final Function<? super DataSnapshot, ? extends T> mapper,
                                                    @NonNull BackpressureStrategy strategy); @NonNull static Maybe<T> observeSingleValueEvent(@NonNull final Query query,
                                                       @NonNull final Function<? super DataSnapshot, ? extends T> mapper); @NonNull static Flowable<RxFirebaseChildEvent<T>> observeChildEvent(
        @NonNull final Query query, @NonNull final Function<? super RxFirebaseChildEvent<DataSnapshot>,
        ? extends RxFirebaseChildEvent<T>> mapper, @NonNull BackpressureStrategy strategy); @NonNull static Flowable<DataSnapshot> observeValueEvent(@NonNull final Query query); @NonNull static Flowable<RxFirebaseChildEvent<DataSnapshot>> observeChildEvent(
        @NonNull final Query query); @NonNull static Single<DataSnapshot> runTransaction(@NonNull final DatabaseReference ref,
                                                      @NonNull final long transactionValue); @NonNull static Flowable<T> observeValueEvent(@NonNull final Query query,
                                                    @NonNull final Class<T> clazz); @NonNull static Flowable<RxFirebaseChildEvent<T>> observeChildEvent(
        @NonNull final Query query, @NonNull final Class<T> clazz); @NonNull static Flowable<T> observeValueEvent(@NonNull final Query query,
                                                    @NonNull final Function<? super DataSnapshot, ? extends T> mapper); @NonNull static Flowable<RxFirebaseChildEvent<T>> observeChildEvent(
        @NonNull final Query query, @NonNull final Function<? super RxFirebaseChildEvent<DataSnapshot>,
        ? extends RxFirebaseChildEvent<T>> mapper);  }