Skip to content

Commit b475c0f

Browse files
authored
test: swap expected and actual values in DML returning tests. (#2663)
* test: swap expected and actual values in DML returning tests. * fix: lint errors.
1 parent 57b536a commit b475c0f

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private void executeUpdate(long expectedCount, final String... stmts) {
196196
};
197197
TransactionRunner runner = getClient().readWriteTransaction();
198198
Long rowCount = runner.run(callable);
199-
assertEquals(rowCount, (Long) expectedCount);
199+
assertEquals((Long) expectedCount, rowCount);
200200
}
201201

202202
@Test
@@ -217,7 +217,7 @@ private void executeUpdateAsync(long expectedCount, final String... stmts) {
217217
};
218218
TransactionRunner runner = getClient().readWriteTransaction();
219219
Long rowCount = runner.run(callable);
220-
assertEquals(rowCount, (Long) expectedCount);
220+
assertEquals((Long) expectedCount, rowCount);
221221
}
222222

223223
@Test
@@ -226,36 +226,36 @@ public void dmlReturningWithExecutePartitionedUpdate() {
226226
assertThrows(
227227
SpannerException.class,
228228
() -> getClient().executePartitionedUpdate(Statement.of(updateDmlReturning())));
229-
assertEquals(e.getErrorCode(), ErrorCode.UNIMPLEMENTED);
229+
assertEquals(ErrorCode.UNIMPLEMENTED, e.getErrorCode());
230230
}
231231

232232
@Test
233233
public void dmlReturningWithExecuteQuery() {
234234
List<Struct> rows = executeQuery(DML_COUNT, insertDmlReturning());
235235
assertEquals(
236+
1,
236237
getClient()
237238
.singleUse()
238239
.readRow("T", Key.of(String.format("%d-boo1", id)), Collections.singletonList("V"))
239-
.getLong(0),
240-
1);
240+
.getLong(0));
241241

242242
// Check if keys(K) and V have expected values.
243243
for (int idx = 0; idx < rows.size(); idx++) {
244-
assertEquals(rows.get(idx).getLong("V"), idx + 1);
245-
assertEquals(rows.get(idx).getString("K"), String.format("%d-boo%d", id, idx + 1));
244+
assertEquals(idx + 1, rows.get(idx).getLong("V"));
245+
assertEquals(String.format("%d-boo%d", id, idx + 1), rows.get(idx).getString("K"));
246246
}
247247
rows = executeQuery(DML_COUNT, updateDmlReturning());
248248
assertEquals(
249+
100,
249250
getClient()
250251
.singleUse()
251252
.readRow("T", Key.of(String.format("%d-boo1", id)), Collections.singletonList("V"))
252-
.getLong(0),
253-
100);
253+
.getLong(0));
254254

255255
// Check if keys(K) and V have expected values.
256256
for (int idx = 0; idx < rows.size(); idx++) {
257-
assertEquals(rows.get(idx).getLong("V"), 100);
258-
assertEquals(rows.get(idx).getString("K"), String.format("%d-boo%d", id, idx + 1));
257+
assertEquals(100, rows.get(idx).getLong("V"));
258+
assertEquals(String.format("%d-boo%d", id, idx + 1), rows.get(idx).getString("K"));
259259
}
260260
rows = executeQuery(DML_COUNT, deleteDmlReturning());
261261
assertNull(
@@ -265,8 +265,8 @@ public void dmlReturningWithExecuteQuery() {
265265

266266
// Check if keys(K) and V have expected values.
267267
for (int idx = 0; idx < rows.size(); idx++) {
268-
assertEquals(rows.get(idx).getLong("V"), 100);
269-
assertEquals(rows.get(idx).getString("K"), String.format("%d-boo%d", id, idx + 1));
268+
assertEquals(100, rows.get(idx).getLong("V"));
269+
assertEquals(String.format("%d-boo%d", id, idx + 1), rows.get(idx).getString("K"));
270270
}
271271
}
272272

@@ -296,29 +296,29 @@ private List<Struct> executeQuery(long expectedCount, String stmt) {
296296
public void dmlReturningWithExecuteQueryAsync() {
297297
List<Struct> rows = executeQueryAsync(DML_COUNT, insertDmlReturning());
298298
assertEquals(
299+
1,
299300
getClient()
300301
.singleUse()
301302
.readRow("T", Key.of(String.format("%d-boo1", id)), Collections.singletonList("V"))
302-
.getLong(0),
303-
1);
303+
.getLong(0));
304304

305305
// Check if keys(K) and V have expected values.
306306
for (int idx = 0; idx < rows.size(); idx++) {
307-
assertEquals(rows.get(idx).getLong("V"), idx + 1);
308-
assertEquals(rows.get(idx).getString("K"), String.format("%d-boo%d", id, idx + 1));
307+
assertEquals(idx + 1, rows.get(idx).getLong("V"));
308+
assertEquals(String.format("%d-boo%d", id, idx + 1), rows.get(idx).getString("K"));
309309
}
310310
rows = executeQueryAsync(DML_COUNT, updateDmlReturning());
311311
assertEquals(
312+
100,
312313
getClient()
313314
.singleUse()
314315
.readRow("T", Key.of(String.format("%d-boo1", id)), Collections.singletonList("V"))
315-
.getLong(0),
316-
100);
316+
.getLong(0));
317317

318318
// Check if keys(K) and V have expected values.
319319
for (int idx = 0; idx < rows.size(); idx++) {
320-
assertEquals(rows.get(idx).getLong("V"), 100);
321-
assertEquals(rows.get(idx).getString("K"), String.format("%d-boo%d", id, idx + 1));
320+
assertEquals(100, rows.get(idx).getLong("V"));
321+
assertEquals(String.format("%d-boo%d", id, idx + 1), rows.get(idx).getString("K"));
322322
}
323323
rows = executeQueryAsync(DML_COUNT, deleteDmlReturning());
324324
assertNull(
@@ -328,8 +328,8 @@ public void dmlReturningWithExecuteQueryAsync() {
328328

329329
// Check if keys(K) and V have expected values.
330330
for (int idx = 0; idx < rows.size(); idx++) {
331-
assertEquals(rows.get(idx).getLong("V"), 100);
332-
assertEquals(rows.get(idx).getString("K"), String.format("%d-boo%d", id, idx + 1));
331+
assertEquals(100, rows.get(idx).getLong("V"));
332+
assertEquals(String.format("%d-boo%d", id, idx + 1), rows.get(idx).getString("K"));
333333
}
334334
}
335335

@@ -373,10 +373,10 @@ private List<Struct> executeQueryAsync(long expectedCount, String stmt) {
373373
public void dmlReturningWithBatchUpdate() {
374374
// Check if batchUpdate works well with a mix of Simple DML and DML Returning statements.
375375
long[] rowCounts = batchUpdate(insertDmlReturning(), updateDmlReturning(), deleteDml());
376-
assertEquals(rowCounts.length, 3);
377-
assertEquals(rowCounts[0], DML_COUNT);
378-
assertEquals(rowCounts[1], DML_COUNT);
379-
assertEquals(rowCounts[2], DML_COUNT);
376+
assertEquals(3, rowCounts.length);
377+
assertEquals(DML_COUNT, rowCounts[0]);
378+
assertEquals(DML_COUNT, rowCounts[1]);
379+
assertEquals(DML_COUNT, rowCounts[2]);
380380
}
381381

382382
private long[] batchUpdate(final String... stmts) {
@@ -392,10 +392,10 @@ private long[] batchUpdate(final String... stmts) {
392392
public void dmlReturningWithBatchUpdateAsync() {
393393
// Check if batchUpdateAsync works well with a mix of Simple DML and DML Returning statements.
394394
long[] rowCounts = batchUpdateAsync(insertDmlReturning(), updateDmlReturning(), deleteDml());
395-
assertEquals(rowCounts.length, 3);
396-
assertEquals(rowCounts[0], DML_COUNT);
397-
assertEquals(rowCounts[1], DML_COUNT);
398-
assertEquals(rowCounts[2], DML_COUNT);
395+
assertEquals(3, rowCounts.length);
396+
assertEquals(DML_COUNT, rowCounts[0]);
397+
assertEquals(DML_COUNT, rowCounts[1]);
398+
assertEquals(DML_COUNT, rowCounts[2]);
399399
}
400400

401401
private long[] batchUpdateAsync(final String... stmts) {

0 commit comments

Comments
 (0)