Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 351f8f6

Browse files
committed
snippets
1 parent d211719 commit 351f8f6

2 files changed

Lines changed: 91 additions & 11 deletions

File tree

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,12 +1121,12 @@ public void testStringReplaceAll() throws Exception {
11211121
.isEqualTo(
11221122
Lists.newArrayList(
11231123
map(
1124-
"replacedAll", "ThX HitchhikXr's GuidX to thX Galaxy",
1125-
"replacedAllStatic", "ThX HitchhikXr's GuidX to thX Galaxy",
1126-
"replacedMultipleBytes", Blob.fromBytes(new byte[] {0x01, 0x03, 0x03})
1127-
)
1128-
)
1129-
);
1124+
"replacedAll",
1125+
"ThX HitchhikXr's GuidX to thX Galaxy",
1126+
"replacedAllStatic",
1127+
"ThX HitchhikXr's GuidX to thX Galaxy",
1128+
"replacedMultipleBytes",
1129+
Blob.fromBytes(new byte[] {0x01, 0x03, 0x03}))));
11301130
}
11311131

11321132
@Test
@@ -1150,11 +1150,13 @@ public void testStringReplaceOne() throws Exception {
11501150
assertThat(data(results))
11511151
.isEqualTo(
11521152
Lists.newArrayList(
1153-
map("replacedOne", "ThX Hitchhiker's Guide to the Galaxy",
1154-
"replacedOneStatic", "ThX Hitchhiker's Guide to the Galaxy",
1155-
"replacedOneByte", Blob.fromBytes(new byte[] {0x01, 0x03, 0x02}))
1156-
)
1157-
);
1153+
map(
1154+
"replacedOne",
1155+
"ThX Hitchhiker's Guide to the Galaxy",
1156+
"replacedOneStatic",
1157+
"ThX Hitchhiker's Guide to the Galaxy",
1158+
"replacedOneByte",
1159+
Blob.fromBytes(new byte[] {0x01, 0x03, 0x02}))));
11581160
}
11591161

11601162
@Test

samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,84 @@ void strTrimFunction() throws ExecutionException, InterruptedException {
13921392
System.out.println(result.getResults());
13931393
}
13941394

1395+
void strLTrimFunction() throws ExecutionException, InterruptedException {
1396+
// [START ltrim_function]
1397+
Pipeline.Snapshot result =
1398+
firestore
1399+
.pipeline()
1400+
.collection("books")
1401+
.select(ltrim(field("name")).as("ltrimmedName"))
1402+
.execute()
1403+
.get();
1404+
// [END ltrim_function]
1405+
System.out.println(result.getResults());
1406+
}
1407+
1408+
void strRTrimFunction() throws ExecutionException, InterruptedException {
1409+
// [START rtrim_function]
1410+
Pipeline.Snapshot result =
1411+
firestore
1412+
.pipeline()
1413+
.collection("books")
1414+
.select(rtrim(field("name")).as("rtrimmedName"))
1415+
.execute()
1416+
.get();
1417+
// [END rtrim_function]
1418+
System.out.println(result.getResults());
1419+
}
1420+
1421+
void strRepeatFunction() throws ExecutionException, InterruptedException {
1422+
// [START string_repeat_function]
1423+
Pipeline.Snapshot result =
1424+
firestore
1425+
.pipeline()
1426+
.collection("books")
1427+
.select(stringRepeat(field("title"), 2).as("repeatedTitle"))
1428+
.execute()
1429+
.get();
1430+
// [END string_repeat_function]
1431+
System.out.println(result.getResults());
1432+
}
1433+
1434+
void strReplaceAllFunction() throws ExecutionException, InterruptedException {
1435+
// [START string_replace_all_function]
1436+
Pipeline.Snapshot result =
1437+
firestore
1438+
.pipeline()
1439+
.collection("books")
1440+
.select(stringReplaceAll(field("title"), "The", "A").as("replacedTitle"))
1441+
.execute()
1442+
.get();
1443+
// [END string_replace_all_function]
1444+
System.out.println(result.getResults());
1445+
}
1446+
1447+
void strReplaceOneFunction() throws ExecutionException, InterruptedException {
1448+
// [START string_replace_one_function]
1449+
Pipeline.Snapshot result =
1450+
firestore
1451+
.pipeline()
1452+
.collection("books")
1453+
.select(stringReplaceOne(field("title"), "The", "A").as("replacedTitle"))
1454+
.execute()
1455+
.get();
1456+
// [END string_replace_one_function]
1457+
System.out.println(result.getResults());
1458+
}
1459+
1460+
void strIndexOfFunction() throws ExecutionException, InterruptedException {
1461+
// [START string_index_of_function]
1462+
Pipeline.Snapshot result =
1463+
firestore
1464+
.pipeline()
1465+
.collection("books")
1466+
.select(stringIndexOf(field("title"), "The").as("indexOfThe"))
1467+
.execute()
1468+
.get();
1469+
// [END string_index_of_function]
1470+
System.out.println(result.getResults());
1471+
}
1472+
13951473
void unixMicrosToTimestampFunction() throws ExecutionException, InterruptedException {
13961474
// [START unix_micros_timestamp]
13971475
Pipeline.Snapshot result =

0 commit comments

Comments
 (0)