Skip to content

Commit ef0869a

Browse files
Brian ChenBenWhitehead
andauthored
chore: make BulkWriter package-private (#330)
Co-authored-by: BenWhitehead <BenWhitehead@users.noreply.github.com>
1 parent a2d27df commit ef0869a

File tree

5 files changed

+4
-120
lines changed

5 files changed

+4
-120
lines changed

google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import javax.annotation.Nonnull;
4343
import javax.annotation.Nullable;
4444

45-
public final class BulkWriter implements AutoCloseable {
45+
final class BulkWriter implements AutoCloseable {
4646
/** The maximum number of writes that can be in a single batch. */
4747
public static final int MAX_BATCH_SIZE = 500;
4848

google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import javax.annotation.Nonnull;
2020

2121
/** Options used to disable request throttling in BulkWriter. */
22-
public final class BulkWriterOptions {
22+
final class BulkWriterOptions {
2323

2424
private final boolean enableThrottling;
2525

google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,6 @@ void getAll(
168168
@Nonnull
169169
WriteBatch batch();
170170

171-
@Nonnull
172-
BulkWriter bulkWriter();
173-
174-
@Nonnull
175-
BulkWriter bulkWriter(BulkWriterOptions options);
176-
177171
/**
178172
* Closes the gRPC channels associated with this instance and frees up their resources. This
179173
* method blocks until all channels are closed. Once this method is called, this Firestore client

google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,12 @@ public WriteBatch batch() {
9393
}
9494

9595
@Nonnull
96-
@Override
97-
public BulkWriter bulkWriter() {
96+
BulkWriter bulkWriter() {
9897
return new BulkWriter(this, /* enableThrottling= */ true);
9998
}
10099

101100
@Nonnull
102-
@Override
103-
public BulkWriter bulkWriter(BulkWriterOptions options) {
101+
BulkWriter bulkWriter(BulkWriterOptions options) {
104102
return new BulkWriter(this, options.isThrottlingEnabled());
105103
}
106104

google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import com.google.api.core.SettableApiFuture;
3535
import com.google.api.gax.rpc.ApiStreamObserver;
3636
import com.google.cloud.Timestamp;
37-
import com.google.cloud.firestore.BulkWriter;
3837
import com.google.cloud.firestore.CollectionReference;
3938
import com.google.cloud.firestore.DocumentReference;
4039
import com.google.cloud.firestore.DocumentSnapshot;
@@ -1316,113 +1315,6 @@ public void deleteNestedFieldUsingFieldPath() throws Exception {
13161315
assertNull(documentSnapshots.getData().get("c.d"));
13171316
}
13181317

1319-
@Test
1320-
public void bulkWriterCreate() throws Exception {
1321-
DocumentReference docRef = randomColl.document();
1322-
1323-
BulkWriter writer = firestore.bulkWriter();
1324-
ApiFuture<WriteResult> result =
1325-
writer.create(docRef, Collections.singletonMap("foo", (Object) "bar"));
1326-
writer.close();
1327-
1328-
assertNotNull(result.get().getUpdateTime());
1329-
DocumentSnapshot snapshot = docRef.get().get();
1330-
assertEquals("bar", snapshot.get("foo"));
1331-
}
1332-
1333-
@Test
1334-
public void bulkWriterCreateAddsPrecondition() throws Exception {
1335-
DocumentReference docRef = randomColl.document();
1336-
docRef.set(Collections.singletonMap("foo", (Object) "bar")).get();
1337-
1338-
BulkWriter writer = firestore.bulkWriter();
1339-
ApiFuture<WriteResult> result =
1340-
writer.create(docRef, Collections.singletonMap("foo", (Object) "bar"));
1341-
writer.close();
1342-
1343-
try {
1344-
result.get();
1345-
fail("Create operation should have thrown exception");
1346-
} catch (Exception e) {
1347-
assertTrue(e.getMessage().contains("Document already exists"));
1348-
}
1349-
}
1350-
1351-
@Test
1352-
public void bulkWriterSet() throws Exception {
1353-
DocumentReference docRef = randomColl.document();
1354-
1355-
BulkWriter writer = firestore.bulkWriter();
1356-
ApiFuture<WriteResult> result =
1357-
writer.set(docRef, Collections.singletonMap("foo", (Object) "bar"));
1358-
writer.close();
1359-
1360-
assertNotNull(result.get().getUpdateTime());
1361-
DocumentSnapshot snapshot = docRef.get().get();
1362-
assertEquals("bar", snapshot.get("foo"));
1363-
}
1364-
1365-
@Test
1366-
public void bulkWriterUpdate() throws Exception {
1367-
DocumentReference docRef = randomColl.document();
1368-
docRef.set(Collections.singletonMap("foo", "oldValue")).get();
1369-
1370-
BulkWriter writer = firestore.bulkWriter();
1371-
ApiFuture<WriteResult> result = writer.update(docRef, "foo", "newValue");
1372-
writer.close();
1373-
1374-
assertNotNull(result.get().getUpdateTime());
1375-
DocumentSnapshot snapshot = docRef.get().get();
1376-
assertEquals("newValue", snapshot.get("foo"));
1377-
}
1378-
1379-
@Test
1380-
public void bulkWriterUpdateAddsPrecondition() throws Exception {
1381-
DocumentReference docRef = randomColl.document();
1382-
1383-
BulkWriter writer = firestore.bulkWriter();
1384-
ApiFuture<WriteResult> result = writer.update(docRef, "foo", "newValue");
1385-
writer.close();
1386-
1387-
try {
1388-
result.get();
1389-
fail("Update operation should have thrown exception");
1390-
} catch (Exception e) {
1391-
assertTrue(e.getMessage().contains("No document to update"));
1392-
}
1393-
}
1394-
1395-
@Test
1396-
public void bulkWriterDelete() throws Exception {
1397-
DocumentReference docRef = randomColl.document();
1398-
docRef.set(Collections.singletonMap("foo", "oldValue")).get();
1399-
1400-
BulkWriter writer = firestore.bulkWriter();
1401-
ApiFuture<WriteResult> result = writer.delete(docRef);
1402-
writer.close();
1403-
1404-
assertNotNull(result.get().getUpdateTime());
1405-
// TODO(b/158502664): Remove this check once we can get write times.
1406-
assertEquals(Timestamp.ofTimeSecondsAndNanos(0, 0), result.get().getUpdateTime());
1407-
DocumentSnapshot snapshot = docRef.get().get();
1408-
assertNull(snapshot.get("foo"));
1409-
}
1410-
1411-
@Test
1412-
public void bulkWriterWritesInOrder() throws Exception {
1413-
DocumentReference docRef = randomColl.document();
1414-
docRef.set(Collections.singletonMap("foo", "oldValue")).get();
1415-
1416-
BulkWriter writer = firestore.bulkWriter();
1417-
writer.set(docRef, Collections.singletonMap("foo", (Object) "bar1"));
1418-
writer.set(docRef, Collections.singletonMap("foo", (Object) "bar2"));
1419-
writer.set(docRef, Collections.singletonMap("foo", (Object) "bar3"));
1420-
writer.close();
1421-
1422-
ApiFuture<DocumentSnapshot> result = docRef.get();
1423-
assertEquals(Collections.singletonMap("foo", "bar3"), result.get().getData());
1424-
}
1425-
14261318
@Test
14271319
public void readOnlyTransaction_successfulGet()
14281320
throws ExecutionException, InterruptedException, TimeoutException {

0 commit comments

Comments
 (0)