@@ -113,6 +113,17 @@ public class BundleReaderTest {
113
113
"bar" ,
114
114
Value .newBuilder ().setIntegerValue (42 ).build ())),
115
115
Document .DocumentState .SYNCED ));
116
+ public static final BundledDocumentMetadata DOC3_METADATA =
117
+ new BundledDocumentMetadata (
118
+ key ("coll/doc3" ), version (5600002L ), /* exists= */ true , Collections .emptyList ());
119
+ public static final BundleDocument DOC3 =
120
+ new BundleDocument (
121
+ new Document (
122
+ key ("coll/doc3" ),
123
+ version (30004002L ),
124
+ ObjectValue .fromMap (
125
+ map ("unicodeValue" , Value .newBuilder ().setStringValue ("\uD83D \uDE0A " ).build ())),
126
+ Document .DocumentState .SYNCED ));
116
127
117
128
@ Test
118
129
public void testReadsQueryAndDocument () throws IOException , JSONException {
@@ -311,18 +322,20 @@ public void testCombinesMultipleBufferReads() throws IOException, JSONException
311
322
@ Test
312
323
public void testReadsUnicodeData () throws IOException , JSONException {
313
324
TestBundleBuilder bundleBuilder = new TestBundleBuilder (TEST_PROJECT );
325
+ String docMetadata = addDoc3Metadata (bundleBuilder );
326
+ String doc = addDoc3 (bundleBuilder ); // DOC3 contains Unicode data
314
327
String json =
315
- bundleBuilder .build (
316
- "bundle-\uD83D \uDE0A " , /* createTimeMicros= */ 6000000L , /* version= */ 1 );
328
+ bundleBuilder .build ("bundle-1" , /* createTimeMicros= */ 6000000L , /* version= */ 1 );
317
329
318
330
BundleReader bundleReader =
319
331
new BundleReader (
320
332
SERIALIZER , new ByteArrayInputStream (json .getBytes (StandardCharsets .UTF_8 )));
321
333
322
- BundleMetadata expectedMetadata =
323
- new BundleMetadata ("bundle-\uD83D \uDE0A " , 1 , version (6000000L ));
324
- BundleMetadata actualMetadata = bundleReader .getBundleMetadata ();
325
- assertEquals (expectedMetadata , actualMetadata );
334
+ List <BundleElement > bundleElements = verifyAllElements (bundleReader , docMetadata , doc );
335
+
336
+ assertEquals (BUNDLE_METADATA , bundleElements .get (0 ));
337
+ assertEquals (DOC3_METADATA , bundleElements .get (1 ));
338
+ assertEquals (DOC3 , bundleElements .get (2 ));
326
339
}
327
340
328
341
private String addDeletedDocMetadata (TestBundleBuilder bundleBuilder ) {
@@ -351,6 +364,19 @@ private String addDoc2(TestBundleBuilder bundleBuilder) {
351
364
"{ foo: { stringValue: 'value2' }, bar: { integerValue: 42 } }" );
352
365
}
353
366
367
+ private String addDoc3Metadata (TestBundleBuilder bundleBuilder ) {
368
+ return bundleBuilder .addDocumentMetadata (
369
+ "coll/doc3" , /* readTimeMicros= */ 5600002L , /* exists= */ true );
370
+ }
371
+
372
+ private String addDoc3 (TestBundleBuilder bundleBuilder ) {
373
+ return bundleBuilder .addDocument (
374
+ "coll/doc3" ,
375
+ /* createTimeMicros= */ 1200002L ,
376
+ /* updateTimeMicros= */ 30004002L ,
377
+ "{ unicodeValue: { stringValue: '\uD83D \uDE0A ' } }" );
378
+ }
379
+
354
380
private String addDoc2Metadata (TestBundleBuilder bundleBuilder ) {
355
381
return bundleBuilder .addDocumentMetadata ("coll/doc1" , 5600001L , true );
356
382
}
0 commit comments