Skip to content

Commit a44de2e

Browse files
committed
../gradlew googleJavaFormat
1 parent 6e70588 commit a44de2e

File tree

2 files changed

+79
-50
lines changed

2 files changed

+79
-50
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryTest.java

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
import static org.junit.Assert.assertFalse;
3232
import static org.junit.Assert.assertNull;
3333
import static org.junit.Assert.assertTrue;
34-
import static org.junit.Assume.assumeFalse;
3534

3635
import android.os.SystemClock;
37-
3836
import androidx.annotation.Nullable;
3937
import androidx.test.ext.junit.runners.AndroidJUnit4;
4038
import com.google.android.gms.tasks.Task;
@@ -1073,7 +1071,7 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
10731071
.getFirestore()
10741072
.runTransaction(
10751073
transaction -> {
1076-
for (int i = 0; i < createdDocuments.size(); i+=2) {
1074+
for (int i = 0; i < createdDocuments.size(); i += 2) {
10771075
DocumentReference documentToDelete = createdDocuments.get(i);
10781076
transaction.delete(documentToDelete);
10791077
deletedDocumentIds.add(documentToDelete.getId());
@@ -1089,8 +1087,10 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
10891087
// testing hooks to "capture" the existence filter mismatches to verify that Watch sent a
10901088
// bloom filter, and it was used to avert a full requery.
10911089
QuerySnapshot snapshot2;
1092-
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo existenceFilterMismatchInfo;
1093-
ExistenceFilterMismatchAccumulator existenceFilterMismatchAccumulator = new ExistenceFilterMismatchAccumulator();
1090+
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo
1091+
existenceFilterMismatchInfo;
1092+
ExistenceFilterMismatchAccumulator existenceFilterMismatchAccumulator =
1093+
new ExistenceFilterMismatchAccumulator();
10941094
existenceFilterMismatchAccumulator.register();
10951095
try {
10961096
snapshot2 = waitFor(collection.get());
@@ -1099,7 +1099,9 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
10991099
if (isRunningAgainstEmulator()) {
11001100
existenceFilterMismatchInfo = null;
11011101
} else {
1102-
existenceFilterMismatchInfo = existenceFilterMismatchAccumulator.waitForExistenceFilterMismatch(/*timeoutMillis=*/5000);
1102+
existenceFilterMismatchInfo =
1103+
existenceFilterMismatchAccumulator.waitForExistenceFilterMismatch(
1104+
/*timeoutMillis=*/ 5000);
11031105
}
11041106
} finally {
11051107
existenceFilterMismatchAccumulator.unregister();
@@ -1122,7 +1124,9 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
11221124
expectedDocumentIds.add(documentRef.getId());
11231125
}
11241126
}
1125-
assertWithMessage("snapshot2.docs").that(actualDocumentIds).containsExactlyElementsIn(expectedDocumentIds);
1127+
assertWithMessage("snapshot2.docs")
1128+
.that(actualDocumentIds)
1129+
.containsExactlyElementsIn(expectedDocumentIds);
11261130
}
11271131

11281132
// Skip the verification of the existence filter mismatch when testing against the Firestore
@@ -1135,9 +1139,15 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
11351139

11361140
// Verify that Watch sent an existence filter with the correct counts when the query was
11371141
// resumed.
1138-
assertWithMessage("Watch should have sent an existence filter").that(existenceFilterMismatchInfo).isNotNull();
1139-
assertWithMessage("localCacheCount").that(existenceFilterMismatchInfo.localCacheCount()).isEqualTo(100);
1140-
assertWithMessage("existenceFilterCount").that(existenceFilterMismatchInfo.existenceFilterCount()).isEqualTo(50);
1142+
assertWithMessage("Watch should have sent an existence filter")
1143+
.that(existenceFilterMismatchInfo)
1144+
.isNotNull();
1145+
assertWithMessage("localCacheCount")
1146+
.that(existenceFilterMismatchInfo.localCacheCount())
1147+
.isEqualTo(100);
1148+
assertWithMessage("existenceFilterCount")
1149+
.that(existenceFilterMismatchInfo.existenceFilterCount())
1150+
.isEqualTo(50);
11411151

11421152
// Skip the verification of the bloom filter when testing against production because the bloom
11431153
// filter is only implemented in nightly.
@@ -1148,8 +1158,11 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
11481158
}
11491159

11501160
// Verify that Watch sent a valid bloom filter.
1151-
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterBloomFilterInfo bloomFilter = existenceFilterMismatchInfo.bloomFilter();
1152-
assertWithMessage("The bloom filter specified in the existence filter").that(bloomFilter).isNotNull();
1161+
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterBloomFilterInfo bloomFilter =
1162+
existenceFilterMismatchInfo.bloomFilter();
1163+
assertWithMessage("The bloom filter specified in the existence filter")
1164+
.that(bloomFilter)
1165+
.isNotNull();
11531166
assertWithMessage("hashCount").that(bloomFilter.hashCount()).isGreaterThan(0);
11541167
assertWithMessage("bitmapLength").that(bloomFilter.bitmapLength()).isGreaterThan(0);
11551168
assertWithMessage("padding").that(bloomFilter.padding()).isGreaterThan(0);
@@ -1160,24 +1173,28 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
11601173
// are expected to happen occasionally. When a false positive _does_ happen, just retry the
11611174
// test with a different set of documents. If that retry _also_ experiences a false positive,
11621175
// then fail the test because that is so improbable that something must have gone wrong.
1163-
if (attemptNumber == 1 && ! bloomFilter.applied()) {
1176+
if (attemptNumber == 1 && !bloomFilter.applied()) {
11641177
continue;
11651178
}
11661179

1167-
assertWithMessage("bloom filter successfully applied with attemptNumber=" + attemptNumber).that(bloomFilter.applied()).isTrue();
1180+
assertWithMessage("bloom filter successfully applied with attemptNumber=" + attemptNumber)
1181+
.that(bloomFilter.applied())
1182+
.isTrue();
11681183
}
11691184
}
11701185

11711186
private static final class ExistenceFilterMismatchAccumulator {
11721187

1173-
private final ExistenceFilterMismatchListenerImpl listener = new ExistenceFilterMismatchListenerImpl();
1188+
private final ExistenceFilterMismatchListenerImpl listener =
1189+
new ExistenceFilterMismatchListenerImpl();
11741190
private ListenerRegistration listenerRegistration = null;
11751191

11761192
void register() {
11771193
if (listenerRegistration != null) {
11781194
throw new IllegalStateException("already registered");
11791195
}
1180-
listenerRegistration = WatchChangeAggregatorTestingHooksAccessor.addExistenceFilterMismatchListener(listener);
1196+
listenerRegistration =
1197+
WatchChangeAggregatorTestingHooksAccessor.addExistenceFilterMismatchListener(listener);
11811198
}
11821199

11831200
void unregister() {
@@ -1189,27 +1206,33 @@ void unregister() {
11891206
}
11901207

11911208
@Nullable
1192-
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo waitForExistenceFilterMismatch(long timeoutMillis) throws InterruptedException {
1209+
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo
1210+
waitForExistenceFilterMismatch(long timeoutMillis) throws InterruptedException {
11931211
if (listenerRegistration == null) {
1194-
throw new IllegalStateException("must be registered before waiting for an existence filter mismatch");
1212+
throw new IllegalStateException(
1213+
"must be registered before waiting for an existence filter mismatch");
11951214
}
11961215
return listener.waitForExistenceFilterMismatch(timeoutMillis);
11971216
}
11981217

1199-
private final class ExistenceFilterMismatchListenerImpl implements WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchListener {
1218+
private final class ExistenceFilterMismatchListenerImpl
1219+
implements WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchListener {
12001220

1201-
private final ArrayList<WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo> existenceFilterMismatches = new ArrayList<>();
1221+
private final ArrayList<WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo>
1222+
existenceFilterMismatches = new ArrayList<>();
12021223

12031224
@Override
1204-
public void onExistenceFilterMismatch(WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo info) {
1225+
public void onExistenceFilterMismatch(
1226+
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo info) {
12051227
synchronized (existenceFilterMismatches) {
12061228
existenceFilterMismatches.add(info);
12071229
existenceFilterMismatches.notifyAll();
12081230
}
12091231
}
12101232

12111233
@Nullable
1212-
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo waitForExistenceFilterMismatch(long timeoutMillis) throws InterruptedException {
1234+
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo
1235+
waitForExistenceFilterMismatch(long timeoutMillis) throws InterruptedException {
12131236
if (timeoutMillis <= 0) {
12141237
throw new IllegalArgumentException("invalid timeout: " + timeoutMillis);
12151238
}
@@ -1228,7 +1251,6 @@ WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo waitForExi
12281251
}
12291252
}
12301253
}
1231-
12321254
}
12331255

12341256
// TODO(orquery): Enable this test when prod supports OR queries.

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/remote/WatchChangeAggregatorTestingHooksAccessor.java

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
import androidx.annotation.AnyThread;
2020
import androidx.annotation.NonNull;
2121
import androidx.annotation.Nullable;
22-
2322
import com.google.firebase.firestore.ListenerRegistration;
2423

2524
/**
2625
* Provides access to the {@link WatchChangeAggregatorTestingHooks} class and its methods.
2726
*
28-
* The {@link WatchChangeAggregatorTestingHooks} class has default visibility, and, therefore, is
27+
* <p>The {@link WatchChangeAggregatorTestingHooks} class has default visibility, and, therefore, is
2928
* only visible to other classes declared in the same package. This class effectively "re-exports"
3029
* the functionality from {@link WatchChangeAggregatorTestingHooks} in a class with {@code public}
3130
* visibility so that tests written in other packages can access its functionality.
@@ -34,47 +33,48 @@ public final class WatchChangeAggregatorTestingHooksAccessor {
3433

3534
private WatchChangeAggregatorTestingHooksAccessor() {}
3635

37-
/**
38-
* @see WatchChangeAggregatorTestingHooks#addExistenceFilterMismatchListener
39-
*/
36+
/** @see WatchChangeAggregatorTestingHooks#addExistenceFilterMismatchListener */
4037
public static ListenerRegistration addExistenceFilterMismatchListener(
41-
@NonNull ExistenceFilterMismatchListener listener) {
38+
@NonNull ExistenceFilterMismatchListener listener) {
4239
checkNotNull(listener, "a null listener is not allowed");
43-
return WatchChangeAggregatorTestingHooks.addExistenceFilterMismatchListener(new ExistenceFilterMismatchListenerWrapper(listener));
40+
return WatchChangeAggregatorTestingHooks.addExistenceFilterMismatchListener(
41+
new ExistenceFilterMismatchListenerWrapper(listener));
4442
}
4543

46-
/**
47-
* @see WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchListener
48-
*/
44+
/** @see WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchListener */
4945
public interface ExistenceFilterMismatchListener {
5046
@AnyThread
5147
void onExistenceFilterMismatch(ExistenceFilterMismatchInfo info);
5248
}
5349

54-
/**
55-
* @see WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchInfo
56-
*/
50+
/** @see WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchInfo */
5751
public interface ExistenceFilterMismatchInfo {
5852
int localCacheCount();
53+
5954
int existenceFilterCount();
60-
@Nullable ExistenceFilterBloomFilterInfo bloomFilter();
55+
56+
@Nullable
57+
ExistenceFilterBloomFilterInfo bloomFilter();
6158
}
6259

63-
/**
64-
* @see WatchChangeAggregatorTestingHooks.ExistenceFilterBloomFilterInfo
65-
*/
60+
/** @see WatchChangeAggregatorTestingHooks.ExistenceFilterBloomFilterInfo */
6661
public interface ExistenceFilterBloomFilterInfo {
6762
boolean applied();
63+
6864
int hashCount();
65+
6966
int bitmapLength();
67+
7068
int padding();
7169
}
7270

73-
private static final class ExistenceFilterMismatchInfoImpl implements ExistenceFilterMismatchInfo {
71+
private static final class ExistenceFilterMismatchInfoImpl
72+
implements ExistenceFilterMismatchInfo {
7473

7574
private final WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchInfo info;
7675

77-
ExistenceFilterMismatchInfoImpl(@NonNull WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchInfo info) {
76+
ExistenceFilterMismatchInfoImpl(
77+
@NonNull WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchInfo info) {
7878
this.info = info;
7979
}
8080

@@ -91,16 +91,21 @@ public int existenceFilterCount() {
9191
@Nullable
9292
@Override
9393
public ExistenceFilterBloomFilterInfo bloomFilter() {
94-
WatchChangeAggregatorTestingHooks.ExistenceFilterBloomFilterInfo bloomFilterInfo = info.bloomFilter();
95-
return bloomFilterInfo == null ? null : new ExistenceFilterBloomFilterInfoImpl(bloomFilterInfo);
94+
WatchChangeAggregatorTestingHooks.ExistenceFilterBloomFilterInfo bloomFilterInfo =
95+
info.bloomFilter();
96+
return bloomFilterInfo == null
97+
? null
98+
: new ExistenceFilterBloomFilterInfoImpl(bloomFilterInfo);
9699
}
97100
}
98101

99-
private static final class ExistenceFilterBloomFilterInfoImpl implements ExistenceFilterBloomFilterInfo {
102+
private static final class ExistenceFilterBloomFilterInfoImpl
103+
implements ExistenceFilterBloomFilterInfo {
100104

101105
private final WatchChangeAggregatorTestingHooks.ExistenceFilterBloomFilterInfo info;
102106

103-
ExistenceFilterBloomFilterInfoImpl(@NonNull WatchChangeAggregatorTestingHooks.ExistenceFilterBloomFilterInfo info) {
107+
ExistenceFilterBloomFilterInfoImpl(
108+
@NonNull WatchChangeAggregatorTestingHooks.ExistenceFilterBloomFilterInfo info) {
104109
this.info = info;
105110
}
106111

@@ -125,18 +130,20 @@ public int padding() {
125130
}
126131
}
127132

128-
private static final class ExistenceFilterMismatchListenerWrapper implements WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchListener {
133+
private static final class ExistenceFilterMismatchListenerWrapper
134+
implements WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchListener {
129135

130136
private final ExistenceFilterMismatchListener wrappedListener;
131137

132-
ExistenceFilterMismatchListenerWrapper(@NonNull ExistenceFilterMismatchListener listenerToWrap) {
138+
ExistenceFilterMismatchListenerWrapper(
139+
@NonNull ExistenceFilterMismatchListener listenerToWrap) {
133140
this.wrappedListener = listenerToWrap;
134141
}
135142

136143
@Override
137-
public void onExistenceFilterMismatch(WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchInfo info) {
144+
public void onExistenceFilterMismatch(
145+
WatchChangeAggregatorTestingHooks.ExistenceFilterMismatchInfo info) {
138146
this.wrappedListener.onExistenceFilterMismatch(new ExistenceFilterMismatchInfoImpl(info));
139147
}
140148
}
141-
142149
}

0 commit comments

Comments
 (0)