Skip to content

Commit ee0a49a

Browse files
SUPERCILEXsamtstern
authored andcommitted
Fix broken database tests (#705)
1 parent 5d114a6 commit ee0a49a

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

database/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.library'
22
apply from: '../library/quality/quality.gradle'
3+
check.dependsOn 'compileDebugAndroidTestJavaWithJavac'
34

45
android {
56
compileSdkVersion compileSdk

database/src/androidTest/java/com/firebase/ui/database/FirebaseArrayTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
public class FirebaseArrayTest {
3737
private static final int INITIAL_SIZE = 3;
3838
private DatabaseReference mRef;
39-
private FirebaseArray mArray;
39+
private FirebaseArray<Integer> mArray;
4040
private ChangeEventListener mListener;
4141

4242
@Before
4343
public void setUp() throws Exception {
4444
FirebaseApp app = getAppInstance(InstrumentationRegistry.getContext());
4545
mRef = FirebaseDatabase.getInstance(app).getReference().child("firebasearray");
46-
mArray = new FirebaseArray(mRef);
46+
mArray = new FirebaseArray<>(mRef, Integer.class);
4747
mRef.removeValue();
4848
mListener = runAndWaitUntil(mArray, new Runnable() {
4949
@Override
@@ -91,7 +91,7 @@ public void run() {
9191
}, new Callable<Boolean>() {
9292
@Override
9393
public Boolean call() throws Exception {
94-
return mArray.get(3).getValue(Integer.class).equals(4);
94+
return mArray.getObject(3).equals(4);
9595
}
9696
});
9797
}
@@ -106,8 +106,8 @@ public void run() {
106106
}, new Callable<Boolean>() {
107107
@Override
108108
public Boolean call() throws Exception {
109-
return mArray.get(3).getValue(Integer.class).equals(3)
110-
&& mArray.get(0).getValue(Integer.class).equals(4);
109+
return mArray.getObject(3).equals(3)
110+
&& mArray.getObject(0).equals(4);
111111
}
112112
});
113113
}

database/src/androidTest/java/com/firebase/ui/database/FirebaseIndexArrayTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class FirebaseIndexArrayTest {
3737

3838
private DatabaseReference mRef;
3939
private DatabaseReference mKeyRef;
40-
private ObservableSnapshotArray<?> mArray;
40+
private ObservableSnapshotArray<Integer> mArray;
4141
private ChangeEventListener mListener;
4242

4343
@Before
@@ -47,7 +47,7 @@ public void setUp() throws Exception {
4747
mRef = databaseInstance.getReference().child("firebasearray");
4848
mKeyRef = databaseInstance.getReference().child("firebaseindexarray");
4949

50-
mArray = new FirebaseIndexArray(mKeyRef, mRef);
50+
mArray = new FirebaseIndexArray<>(mKeyRef, mRef, Integer.class);
5151
mRef.removeValue();
5252
mKeyRef.removeValue();
5353

@@ -97,7 +97,7 @@ public void run() {
9797
}, new Callable<Boolean>() {
9898
@Override
9999
public Boolean call() throws Exception {
100-
return mArray.get(3).getValue(Integer.class).equals(4);
100+
return mArray.getObject(3).equals(4);
101101
}
102102
});
103103
}
@@ -112,8 +112,8 @@ public void run() {
112112
}, new Callable<Boolean>() {
113113
@Override
114114
public Boolean call() throws Exception {
115-
return mArray.get(3).getValue(Integer.class).equals(3)
116-
&& mArray.get(0).getValue(Integer.class).equals(4);
115+
return mArray.getObject(3).equals(3)
116+
&& mArray.getObject(0).equals(4);
117117
}
118118
});
119119
}

database/src/androidTest/java/com/firebase/ui/database/TestUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ public void onCancelled(DatabaseError error) {
7474
return listener;
7575
}
7676

77-
public static boolean isValuesEqual(ObservableSnapshotArray<?> array, int[] expected) {
77+
public static boolean isValuesEqual(ObservableSnapshotArray<Integer> array, int[] expected) {
7878
if (array.size() != expected.length) return false;
7979
for (int i = 0; i < array.size(); i++) {
80-
if (!array.get(i).getValue(Integer.class).equals(expected[i])) {
80+
if (!array.getObject(i).equals(expected[i])) {
8181
return false;
8282
}
8383
}

0 commit comments

Comments
 (0)