Skip to content

Commit dc1f9a9

Browse files
authored
fix: fix JSON sample test (#1417)
1 parent fb154cd commit dc1f9a9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

samples/snippets/src/main/java/com/example/spanner/QueryWithJsonParameterSample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void queryWithJsonParameter() {
4242
}
4343

4444
static void queryWithJsonParameter(DatabaseClient client) {
45-
String exampleJson = "{rating: 9}";
45+
String exampleJson = "{\"rating\": 9}";
4646
Statement statement =
4747
Statement.newBuilder(
4848
"SELECT VenueId, VenueDetails\n"
@@ -56,7 +56,7 @@ static void queryWithJsonParameter(DatabaseClient client) {
5656
while (resultSet.next()) {
5757
System.out.printf(
5858
"VenueId: %s, VenueDetails: %s%n",
59-
resultSet.getLong("VenueId"), resultSet.getString("VenueDetails"));
59+
resultSet.getLong("VenueId"), resultSet.getJson("VenueDetails"));
6060
}
6161
}
6262
}

samples/snippets/src/test/java/com/example/spanner/SpannerStandaloneExamplesIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public void updateJsonData_shouldWriteData() {
238238
() ->
239239
UpdateJsonDataSample.updateJsonData(
240240
spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId))));
241-
assertThat(out).contains("VenueDetails successfully updated");
241+
assertThat(out).contains("Venues successfully updated");
242242
}
243243

244244
@Test
@@ -274,6 +274,6 @@ public void queryWithJsonParameter_shouldReturnResults() {
274274
+ "\"tags\":[\"large\",\"airy\"]}"))
275275
.build()));
276276
String out = runExample(() -> QueryWithJsonParameterSample.queryWithJsonParameter(client));
277-
assertThat(out).contains("4 35000");
277+
assertThat(out).contains("VenueId: 19, VenueDetails: {\"open\":true,\"rating\":9}");
278278
}
279279
}

0 commit comments

Comments
 (0)