Skip to content

Commit 3f34b04

Browse files
committed
test: update tests to support mockito 5.x
1 parent ecef64d commit 3f34b04

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@
252252
</dependency>
253253
<dependency>
254254
<groupId>org.mockito</groupId>
255-
<artifactId>mockito-core</artifactId>
256-
<version>5.0.0</version>
255+
<artifactId>mockito-subclass</artifactId>
256+
<version>5.14.2</version>
257257
<scope>test</scope>
258258
</dependency>
259259
</dependencies>

src/test/java/com/google/cloud/spanner/pgadapter/ConnectionHandlerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ public void testListDatabasesOrInstances() {
908908
Spanner spanner = mock(Spanner.class);
909909
DatabaseAdminClient adminClient = mock(DatabaseAdminClient.class);
910910
when(spanner.getDatabaseAdminClient()).thenReturn(adminClient);
911-
when(adminClient.listDatabases(eq("my-instance"), any())).thenReturn(Pages.empty());
911+
when(adminClient.listDatabases("my-instance")).thenReturn(Pages.empty());
912912
StatusRuntimeException exception =
913913
newStatusResourceNotFoundException(
914914
"test-database",

src/test/java/com/google/cloud/spanner/pgadapter/JdbcMockServerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4552,7 +4552,8 @@ public void testSetTimeZoneEST() throws SQLException {
45524552
try (Connection connection = DriverManager.getConnection(createUrl())) {
45534553
// Java considers 'EST' to always be '-05:00'. That is; it is never DST.
45544554
connection.createStatement().execute("set time zone 'EST'");
4555-
verifySettingValue(connection, "timezone", "-05:00");
4555+
verifySettingValue(
4556+
connection, "timezone", java.time.ZoneId.SHORT_IDS.getOrDefault("EST", "-05:00"));
45564557
// 'EST5EDT' is the ID for the timezone that will change with DST.
45574558
connection.createStatement().execute("set time zone 'EST5EDT'");
45584559
verifySettingValue(connection, "timezone", "EST5EDT");

src/test/java/com/google/cloud/spanner/pgadapter/utils/MutationWriterTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void testWriteMutations() throws Exception {
170170
.set("name")
171171
.to("Two")
172172
.build());
173-
verify(databaseClient).writeWithOptions(eq(expectedMutations), any());
173+
verify(databaseClient).writeWithOptions(eq(expectedMutations), any(com.google.cloud.spanner.Options.TransactionOption[].class));
174174
}
175175

176176
@Test
@@ -270,7 +270,7 @@ public void testWriteMutations_NonAtomic_SucceedsForLargeBatch() throws Exceptio
270270
StatementResult updateCount = mutationWriter.call();
271271

272272
assertEquals(5L, updateCount.getUpdateCount().longValue());
273-
verify(databaseClient, times(3)).writeWithOptions(anyIterable(), any());
273+
verify(databaseClient, times(3)).writeWithOptions(anyIterable(), any(com.google.cloud.spanner.Options.TransactionOption[].class));
274274
} finally {
275275
System.getProperties().remove("copy_in_mutation_limit");
276276
}
@@ -372,7 +372,7 @@ public void testWriteMutations_NonAtomic_SucceedsForLargeCommit() throws Excepti
372372
// 4. The second batch contains 28 bytes. (3 - 'Three')
373373
// 5. The third batch contains 24 bytes. (4 - 'Four')
374374
// 6. the fourth batch contains 24 bytes. (5 - 'Five')
375-
verify(databaseClient, times(4)).writeWithOptions(anyIterable(), any());
375+
verify(databaseClient, times(4)).writeWithOptions(anyIterable(), any(com.google.cloud.spanner.Options.TransactionOption[].class));
376376
} finally {
377377
System.getProperties().remove("copy_in_commit_limit");
378378
}
@@ -441,7 +441,7 @@ public void testWritePartials() throws Exception {
441441
.set("name")
442442
.to("Five")
443443
.build());
444-
verify(databaseClient).writeWithOptions(eq(expectedMutations), any());
444+
verify(databaseClient).writeWithOptions(eq(expectedMutations), any(com.google.cloud.spanner.Options.TransactionOption[].class));
445445

446446
executor.shutdown();
447447
}

0 commit comments

Comments
 (0)