com.google.firebase.database.DatabaseReference Java Examples

The following examples show how to use com.google.firebase.database.DatabaseReference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArchivedConversationsHandler.java    From chat21-android-sdk with GNU Affero General Public License v3.0 6 votes vote down vote up
public void deleteConversation(final String conversationId, final ConversationsListener conversationsListener) {

        // the node of the conversation with conversationId
        DatabaseReference nodeConversation = conversationsNode.child(conversationId);

        nodeConversation.removeValue(new DatabaseReference.CompletionListener() {
            @Override
            public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {

                if (databaseError == null) {
                    deleteConversationFromMemory(conversationId);
                    conversationsListener.onConversationRemoved(null);
                } else {
                    conversationsListener.onConversationRemoved(new ChatRuntimeException(databaseError.toException()));
                }
            }
        });
    }
 
Example #2
Source File: DataTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testNameAndRefForSnapshots()
    throws TestFailure, ExecutionException, TimeoutException, InterruptedException {

  DatabaseReference ref = FirebaseDatabase.getInstance(masterApp).getReference();
  // Clear any data there
  new WriteFuture(ref, MapBuilder.of("foo", 10)).timedGet();

  DataSnapshot snap = TestHelpers.getSnap(ref);
  assertNull(snap.getKey());
  assertEquals(ref.toString(), snap.getRef().toString());
  DataSnapshot childSnap = snap.child("a");
  assertEquals("a", childSnap.getKey());
  assertEquals(ref.child("a").toString(), childSnap.getRef().toString());
  childSnap = childSnap.child("b/c");
  assertEquals("c", childSnap.getKey());
  assertEquals(ref.child("a/b/c").toString(), childSnap.getRef().toString());
}
 
Example #3
Source File: FirebaseCache.java    From white-label-event-app with Apache License 2.0 6 votes vote down vote up
private void warmSpeakers() {
    final DatabaseReference ref = fdb.getReference("/sections/speakers");
    ref.addValueEventListener(new ExecutorValueEventListener(executor) {
        @Override
        public void onDataChangeExecutor(final DataSnapshot data) {
            LOGGER.fine("New Speaker data");
            speakers = FirebaseDatabaseHelpers.toSpeakersSection(data);
            bus.post(speakers);
        }

        @Override
        public void onCancelledExecutor(final DatabaseError databaseError) {
            LOGGER.log(Level.SEVERE, "Error reading speakers", databaseError.toException());
        }
    });
}
 
Example #4
Source File: QueryTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateBasicQueries() {
  DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);

  // Just make sure they don't throw anything
  ref.limitToLast(10);
  ref.startAt("199").limitToLast(10);
  ref.startAt("199", "test").limitToLast(10);
  ref.endAt(199).limitToLast(1);
  ref.startAt(50, "test").endAt(100, "tree");
  ref.startAt(4).endAt(10);
  ref.startAt(null).endAt(10);
  ref.orderByChild("child");
  ref.orderByChild("child/deep/path");
  ref.orderByValue();
  ref.orderByPriority();
}
 
Example #5
Source File: SignInActivity.java    From budgetto with MIT License 6 votes vote down vote up
private void runTransaction(DatabaseReference userReference) {
    showProgressView();
    userReference.runTransaction(new Transaction.Handler() {
        @Override
        public Transaction.Result doTransaction(MutableData mutableData) {
            User user = mutableData.getValue(User.class);
            if (user == null) {
                mutableData.setValue(new User());
                return Transaction.success(mutableData);
            }

            return Transaction.success(mutableData);
        }

        @Override
        public void onComplete(DatabaseError databaseError, boolean committed,
                               DataSnapshot dataSnapshot) {
            if (committed) {
                startActivity(new Intent(SignInActivity.this, MainActivity.class));
                finish();
            } else {
                errorTextView.setText("Firebase create user transaction failed.");
                hideProgressView();
            }
        }
    });
}
 
Example #6
Source File: HomeBaseFragment.java    From kute with Apache License 2.0 6 votes vote down vote up
/********************************* Data Querying Methods *************************/
//Load friends from firebase
public void getFirebaseFriend() {
    /******************** Getting Friends From Firebase *************/
    String ref = "Friends/" + getActivity().getSharedPreferences("user_credentials", 0).getString("Name", null);
    Log.d(TAG, "Firebase Reference :" + ref);
    DatabaseReference friends = FirebaseDatabase.getInstance().getReference(ref);
    friends.keepSynced(true);
    friends.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot k : dataSnapshot.getChildren()) {
                friend_list.add(k.getKey());
                Log.d(TAG, "Debug Firebase data query" + k.getValue().toString());
            }
            
            Log.d(TAG, String.format("The Friend List Size is %d",friend_list.size()));
            getFirstFriendProfile();

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
}
 
Example #7
Source File: RestorePresenter.java    From FastAccess with GNU General Public License v3.0 6 votes vote down vote up
@Override public void onRestore(@NonNull DatabaseReference databaseReference, @Nullable String userId) {
    this.userId = userId;
    FirebaseUser user = getView().user();
    if (InputHelper.isEmpty(userId)) {
        if (user != null) userId = user.getUid();
    }
    if (InputHelper.isEmpty(userId)) {
        getView().onShowMessage(R.string.login_first_msg);
        getView().finishOnError();
    } else {
        getView().onShowProgress();
        Query query = databaseReference
                .child(userId);
        query.keepSynced(true);
        query.addListenerForSingleValueEvent(this);
    }
}
 
Example #8
Source File: QueryTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testAttachingListener() {
  DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);

  ValueEventListener listener = ref.limitToLast(1)
      .addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
          // No-op
        }

        @Override
        public void onCancelled(DatabaseError error) {
        }
      });

  assertNotNull(listener);
}
 
Example #9
Source File: EventTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteLargeLongValueThenIncrement() throws InterruptedException {
  List<DatabaseReference> refs = IntegrationTestUtils.getRandomNode(masterApp, 1);
  DatabaseReference node = refs.get(0);

  final EventHelper readHelper =
      new EventHelper()
          .addValueExpectation(node, Long.MAX_VALUE)
          .addValueExpectation(node, Long.MAX_VALUE * 2.0)
          .startListening(true);

  ZombieVerifier.verifyRepoZombies(refs);
  node.setValueAsync(Long.MAX_VALUE);
  node.setValueAsync(Long.MAX_VALUE * 2.0);

  TestHelpers.waitForRoundtrip(node);
  assertTrue(readHelper.waitForEvents());
  ZombieVerifier.verifyRepoZombies(refs);
  readHelper.cleanup();
}
 
Example #10
Source File: FirebasePostQueryAdapter.java    From friendlypix-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final PostViewHolder holder, int position) {
    DatabaseReference ref = FirebaseUtil.getPostsRef().child(mPostPaths.get(position));
    // TODO: Fix this so async event won't bind the wrong view post recycle.
    ValueEventListener postListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Post post = dataSnapshot.getValue(Post.class);
            Log.d(TAG, "post key: " + dataSnapshot.getKey());
            mOnSetupViewListener.onSetupView(holder, post, holder.getAdapterPosition(),
                    dataSnapshot.getKey());
        }

        @Override
        public void onCancelled(DatabaseError firebaseError) {
            Log.e(TAG, "Error occurred: " + firebaseError.getMessage());
        }
    };
    ref.addValueEventListener(postListener);
    holder.mPostRef = ref;
    holder.mPostListener = postListener;
}
 
Example #11
Source File: QueryTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testEndAtWithTwoArgumentsAndLimit()
    throws TestFailure, ExecutionException, TimeoutException, InterruptedException {
  DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);

  Map<String, Object> toSet = new MapBuilder().put("a", "a")
      .put("b", "b").put("c", "c").put("d", "d").put("e", "e").put("f", "f")
      .put("g", "g").put("h", "h").build();

  new WriteFuture(ref, toSet).timedGet();

  DataSnapshot snap = TestHelpers.getSnap(ref.endAt(null, "f").limitToLast(5));
  Map<String, Object> expected = new MapBuilder().put("b", "b")
      .put("c", "c").put("d", "d").put("e", "e").put("f", "f").build();

  TestHelpers.assertDeepEquals(expected, snap.getValue());
}
 
Example #12
Source File: EventTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteIntegerValueThenChangeToDoubleWithDifferentPriority()
    throws InterruptedException {
  List<DatabaseReference> refs = IntegrationTestUtils.getRandomNode(masterApp, 1);
  DatabaseReference node = refs.get(0);

  final EventHelper readHelper =
      new EventHelper()
          .addValueExpectation(node, 1337)
          .addValueExpectation(node, 1337)
          .startListening(true);

  ZombieVerifier.verifyRepoZombies(refs);

  node.setValueAsync(1337);
  node.setValueAsync(1337.0, 1337);

  TestHelpers.waitForRoundtrip(node);
  assertTrue(readHelper.waitForEvents());
  ZombieVerifier.verifyRepoZombies(refs);
  readHelper.cleanup();
}
 
Example #13
Source File: DriverHome.java    From UberClone with MIT License 6 votes vote down vote up
private void updateFirebaseToken() {
    FirebaseDatabase db=FirebaseDatabase.getInstance();
    final DatabaseReference tokens=db.getReference(Common.token_tbl);

    final Token token=new Token(FirebaseInstanceId.getInstance().getToken());
    if(FirebaseAuth.getInstance().getUid()!=null) tokens.child(FirebaseAuth.getInstance().getUid()).setValue(token);
    else if(account!=null) tokens.child(account.getId()).setValue(token);
    else{
        GraphRequest request = GraphRequest.newMeRequest(
                accessToken,
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        String id = object.optString("id");
                        tokens.child(id).setValue(token);
                    }
                });
        request.executeAsync();
    }
}
 
Example #14
Source File: LoadPersonRoutesAsyncTask.java    From kute with Apache License 2.0 6 votes vote down vote up
@Override
protected ArrayList<Route> doInBackground(String... params) {
    //Return the retrieved list of person's  routes from firebase
    String id=params[0];
    String route_ref="Routes/"+id;
    DatabaseReference routes_ref= FirebaseDatabase.getInstance().getReference(route_ref);
    routes_ref.keepSynced(true);
    routes_ref.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot routes:dataSnapshot.getChildren()){
                Route temp=routes.getValue(Route.class);
                Log.i(TAG,temp.getName());
                routes_list.add(temp);
            }
            messenger_to_activity.onTaskCompleted(routes_list);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
    return null;
}
 
Example #15
Source File: OrderTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testChildEventsOnPriorityChanges() throws InterruptedException {
  DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);

  final EventHelper helper =
      new EventHelper()
          .addChildExpectation(ref, Event.EventType.CHILD_ADDED, "a")
          .addValueExpectation(ref)
          .addChildExpectation(ref, Event.EventType.CHILD_ADDED, "b")
          .addValueExpectation(ref)
          .addChildExpectation(ref, Event.EventType.CHILD_ADDED, "c")
          .addValueExpectation(ref)
          .addChildExpectation(ref, Event.EventType.CHILD_MOVED, "a")
          .addChildExpectation(ref, Event.EventType.CHILD_CHANGED, "a")
          .addValueExpectation(ref)
          .startListening(true);

  ref.child("a").setValueAsync("first", 1);
  ref.child("b").setValueAsync("second", 5);
  ref.child("c").setValueAsync("third", 10);
  ref.child("a").setPriorityAsync(15);

  assertTrue(helper.waitForEvents());
  helper.cleanup();
}
 
Example #16
Source File: PersistenceTest.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void deepUpdateTest() throws Throwable {
  PersistenceManager manager = newTestPersistenceManager();
  DatabaseConfig cfg1 = newFrozenTestConfig();
  DatabaseReference ref1 = refWithConfig(cfg1, manager).push();
  goOffline(cfg1);
  Map<String, Object> updates = new HashMap<String, Object>();
  updates.put("foo/deep/update", "bar");
  ref1.updateChildren(updates);
  waitForQueue(ref1);

  DatabaseConfig cfg2 = newFrozenTestConfig();
  DatabaseReference ref2 = refWithConfig(cfg2, manager);
  ref2 = ref2.child(ref1.getKey());

  Object value = new ReadFuture(ref2).waitForLastValue();
  assertEquals(value, fromSingleQuotedString("{ 'foo': { 'deep': { 'update': 'bar' } } }"));
}
 
Example #17
Source File: PersistenceTest.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void simpleMergeTest() throws Throwable {
  PersistenceManager manager = newTestPersistenceManager();
  DatabaseConfig cfg1 = newFrozenTestConfig();
  DatabaseReference ref1 = refWithConfig(cfg1, manager).push();
  goOffline(cfg1);
  Map<String, Object> updates = new HashMap<String, Object>();
  updates.put("foo", "bar");
  ref1.updateChildren(updates);
  waitForQueue(ref1);

  DatabaseConfig cfg2 = newFrozenTestConfig();
  DatabaseReference ref2 = refWithConfig(cfg2, manager);
  ref2 = ref2.child(ref1.getKey());

  Object value = new ReadFuture(ref2).waitForLastValue();
  assertEquals(updates, value);
}
 
Example #18
Source File: PostInteractor.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
public void getPostListByUser(final OnDataChangedListener<Post> onDataChangedListener, String userId) {
    DatabaseReference databaseReference = databaseHelper.getDatabaseReference().child(DatabaseHelper.POSTS_DB_KEY);
    Query postsQuery;
    postsQuery = databaseReference.orderByChild("authorId").equalTo(userId);

    postsQuery.keepSynced(true);
    postsQuery.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            PostListResult result = parsePostList((Map<String, Object>) dataSnapshot.getValue());
            onDataChangedListener.onListChanged(result.getPosts());
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            LogUtil.logError(TAG, "getPostListByUser(), onCancelled", new Exception(databaseError.getMessage()));
        }
    });
}
 
Example #19
Source File: QueryTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartAtEndAtWithPriority() throws InterruptedException {
  DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);

  ValueExpectationHelper helper = new ValueExpectationHelper();
  helper.add(ref.startAt("w").endAt("y"),
      MapBuilder.of("b", 2L, "c", 3L, "d", 4L));
  helper.add(ref.startAt("w").endAt("w"), MapBuilder.of("d", 4L));
  helper.add(ref.startAt("a").endAt("c"), null);

  ref.setValueAsync(
      new MapBuilder()
          .put("a", MapBuilder.of(".value", 1, ".priority", "z"))
          .put("b", MapBuilder.of(".value", 2, ".priority", "y"))
          .put("c", MapBuilder.of(".value", 3, ".priority", "x"))
          .put("d", MapBuilder.of(".value", 4, ".priority", "w")).build());

  helper.waitForEvents();
}
 
Example #20
Source File: DataTestIT.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateRaisesChildEventsOnNewListener() throws InterruptedException {
  DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp);
  EventHelper helper = new EventHelper().addValueExpectation(ref.child("a"))
      .addValueExpectation(ref.child("d"))
      .addChildExpectation(ref, Event.EventType.CHILD_ADDED, "a")
      .addChildExpectation(ref, Event.EventType.CHILD_ADDED, "d")
      .addValueExpectation(ref.child("c")).addValueExpectation(ref.child("d"))
      .addChildExpectation(ref, Event.EventType.CHILD_ADDED, "c")
      .addChildExpectation(ref, Event.EventType.CHILD_CHANGED, "d").startListening();

  ref.updateChildrenAsync(new MapBuilder().put("a", 11).put("d", 44).build());
  ref.updateChildrenAsync(new MapBuilder().put("c", 33).put("d", 45).build());
  helper.waitForEvents();
  helper.cleanup();
}
 
Example #21
Source File: Repo.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
void callOnComplete(
    final DatabaseReference.CompletionListener onComplete,
    final DatabaseError error,
    final Path path) {
  if (onComplete != null) {
    final DatabaseReference ref;
    ChildKey last = path.getBack();
    if (last != null && last.isPriorityChildName()) {
      ref = InternalHelpers.createReference(this, path.getParent());
    } else {
      ref = InternalHelpers.createReference(this, path);
    }
    postEvent(
        new Runnable() {
          @Override
          public void run() {
            onComplete.onComplete(error, ref);
          }
        });
  }
}
 
Example #22
Source File: ChatStore.java    From AvI with MIT License 6 votes vote down vote up
public static ChatMessage addMessage(
        DatabaseReference firebaseDb,
        String groupId,
        ChatMessage message){

    DatabaseReference pushRef = firebaseDb
            .child("chat")
            .child("messages")
            .child(groupId)
            .push();

    pushRef.setValue(message.toMap());

    message.setId(pushRef.getKey());
    return message;
}
 
Example #23
Source File: MyEmailer.java    From quickstart-java with Apache License 2.0 5 votes vote down vote up
public static void sendWeeklyEmail(Map<String,User> users, List<Post> topPosts) {
    // TODO(developer): send email to each user notifying them about the current top posts
    System.out.println("sendWeeklyEmail: MOCK IMPLEMENTATION");
    System.out.println("sendWeeklyEmail: there are " + users.size() + " total users.");
    System.out.println("sendWeeklyEmail: the top post is " + topPosts.get(0).title + " by " + topPosts.get(0).author);

    for (String userId : users.keySet()) {
        // Mark the last time the weekly email was sent out
        // [START basic_write]
        DatabaseReference userRef = FirebaseDatabase.getInstance().getReference()
                .child("users").child(userId).child("lastSentWeeklyTimestamp");
        userRef.setValue(ServerValue.TIMESTAMP);
        // [END basic_write]
    }
}
 
Example #24
Source File: DoorbellActivity.java    From doorbell with Apache License 2.0 5 votes vote down vote up
/**
 * Upload image data to Firebase as a doorbell event.
 */
private void onPictureTaken(final byte[] imageBytes) {
    if (imageBytes != null) {
        final DatabaseReference log = mDatabase.getReference("logs").push();
        final StorageReference imageRef = mStorage.getReference().child(log.getKey());

        // upload image to storage
        UploadTask task = imageRef.putBytes(imageBytes);
        task.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Uri downloadUrl = taskSnapshot.getDownloadUrl();
                // mark image in the database
                Log.i(TAG, "Image upload successful");
                log.child("timestamp").setValue(ServerValue.TIMESTAMP);
                log.child("image").setValue(downloadUrl.toString());
                // process image annotations
                annotateImage(log, imageBytes);
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                // clean up this entry
                Log.w(TAG, "Unable to upload image to Firebase");
                log.removeValue();
            }
        });
    }
}
 
Example #25
Source File: DataTestIT.java    From firebase-admin-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testNamespacesToStringCaseInsensitiveIn() throws DatabaseException {
  DatabaseReference ref1 = FirebaseDatabase.getInstance(masterApp).getReference();
  String url = "https://" + IntegrationTestUtils.getProjectId().toUpperCase() + ".firebaseio.com";
  DatabaseReference ref2 = FirebaseDatabase.getInstance(masterApp).getReferenceFromUrl(url);

  assertEquals(ref1.toString(), ref2.toString());
}
 
Example #26
Source File: OrderByTestIT.java    From firebase-admin-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueriesOnLeafNodes()
    throws InterruptedException, ExecutionException, TestFailure, TimeoutException {
  DatabaseReference ref = IntegrationTestUtils.getRandomNode(masterApp) ;
  final Semaphore semaphore = new Semaphore(0);
  new WriteFuture(ref, "leaf-node").timedGet();

  final List<DataSnapshot> snapshots = new ArrayList<>();
  Query query = ref.orderByChild("foo").limitToLast(1);
  final ValueEventListener listener =
      query.addValueEventListener(
          new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
              snapshots.add(snapshot);
              semaphore.release();
            }

            @Override
            public void onCancelled(DatabaseError error) {
              Assert.fail();
            }
          });

  TestHelpers.waitFor(semaphore);

  Assert.assertEquals(1, snapshots.size());
  Assert.assertNull(snapshots.get(0).getValue());

  // cleanup
  TestHelpers.waitForRoundtrip(ref);
  ref.removeEventListener(listener);
}
 
Example #27
Source File: UtilitiesTest.java    From firebase-admin-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testWrapOnCompleteExplicit() {
  CompletionListener listener = new CompletionListener() {
    @Override
    public void onComplete(DatabaseError error, DatabaseReference ref) {

    }
  };
  Pair<ApiFuture<Void>, DatabaseReference.CompletionListener> result =
      Utilities.wrapOnComplete(listener);
  assertNull(result.getFirst());
  assertSame(listener, result.getSecond());
}
 
Example #28
Source File: CommentInteractor.java    From social-app-android with Apache License 2.0 5 votes vote down vote up
public void removeComment(String commentId, final String postId, final OnTaskCompleteListener onTaskCompleteListener) {
    DatabaseReference reference = databaseHelper
            .getDatabaseReference()
            .child(DatabaseHelper.POST_COMMENTS_DB_KEY)
            .child(postId)
            .child(commentId);
    reference.removeValue().addOnSuccessListener(aVoid -> decrementCommentsCount(postId, onTaskCompleteListener)).addOnFailureListener(e -> {
        onTaskCompleteListener.onTaskComplete(false);
        LogUtil.logError(TAG, "removeComment()", e);
    });
}
 
Example #29
Source File: DataTestIT.java    From firebase-admin-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetPriorityOfAnObject()
    throws ExecutionException, TimeoutException, InterruptedException, TestFailure {
  List<DatabaseReference> refs = IntegrationTestUtils.getRandomNode(masterApp, 2);
  DatabaseReference ref1 = refs.get(0);
  DatabaseReference ref2 = refs.get(1);

  new WriteFuture(ref1, new MapBuilder().put("a", 5).build(), "991").timedGet();

  DataSnapshot snap = new ReadFuture(ref2).timedGet().get(0).getSnapshot();

  assertEquals("991", snap.getPriority());
}
 
Example #30
Source File: CategoryFirebaseSource.java    From outlay with Apache License 2.0 5 votes vote down vote up
public CategoryFirebaseSource(
        User currentUser,
        DatabaseReference databaseReference
) {
    this.currentUser = currentUser;
    mDatabase = databaseReference;
    adapter = new CategoryAdapter();
}