Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Excavator: Prefer AssertJ
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot committed Jan 12, 2021
1 parent aede5fb commit e4bd6a5
Show file tree
Hide file tree
Showing 23 changed files with 200 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,17 @@ private void whenCalculatingSweepPriorities() {

// Then
private void thenNoTablesToSweep() {
assertThat(priorities.isEmpty()).isEqualTo(true);
assertThat(priorities).isEmpty();
}

private void thenOnlyTablePrioritisedIs(TableReference table) {
assertThat(priorities.size()).isEqualTo(1);
assertThat(priorities.containsKey(table)).isEqualTo(true);
assertThat(priorities).hasSize(1);
assertThat(priorities).containsKey(table);
}

private void thenOnlyTablePrioritisedIs(SweepPriorityHistory sweepPriorityHistory) {
assertThat(priorities.size()).isEqualTo(1);
assertThat(priorities.containsKey(sweepPriorityHistory.tableRef)).isEqualTo(true);
assertThat(priorities).hasSize(1);
assertThat(priorities).containsKey(sweepPriorityHistory.tableRef);
}

private void thenTableHasPriority(TableReference table) {
Expand All @@ -527,7 +527,7 @@ private void thenTableHasZeroPriority(SweepPriorityHistory sweepPriorityHistory)
}

private void thenNumberOfTablesIs(int expectedNumberOfTables) {
assertThat(priorities.size()).isEqualTo(expectedNumberOfTables);
assertThat(priorities).hasSize(expectedNumberOfTables);
}

private void thenFirstTableHasHigherPriorityThanSecond(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void canReadMultipleEntriesInSingleShardSameTransactionMultipleDedicated(
List<WriteInfo> writes = writeCommittedConservativeRowForTimestamp(TS + 1, MAX_CELLS_DEDICATED + 1);

SweepBatch conservativeBatch = readConservative(0, TS_FINE_PARTITION, TS, TS + 2);
assertThat(conservativeBatch.writes()).hasSize(writes.size());
assertThat(conservativeBatch.writes()).hasSameSizeAs(writes);
assertThat(conservativeBatch.writes()).contains(writes.get(0), writes.get(writes.size() - 1));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,6 @@ private static void assertStartTimestampsCanBeDistinguished(long... timestamps)
.boxed()
.map(STRATEGY::encodeStartTimestampAsCell)
.collect(Collectors.toSet());
assertThat(convertedCells).hasSize(timestamps.length);
assertThat(convertedCells).hasSameSizeAs(timestamps);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void refreshSingleCallsRefreshWithMatchingArgument() throws InterruptedEx
@Test
public void refreshSingleReturnsTokenIfCanBeRefreshed() throws InterruptedException {
when(mockClient.refresh(any())).then(REPLY_WITH_FIRST_TOKEN);
assertThat(LOCK_TOKEN).isEqualTo(client.refreshSingle(LOCK_TOKEN));
assertThat(client.refreshSingle(LOCK_TOKEN)).isEqualTo(LOCK_TOKEN);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void partitioningOnlyReordersEvents() {
CheckerResult checkerResult = runPartitionChecker(() -> identityChecker, eventList);

assertThat(checkerResult.valid()).isFalse();
assertThat(checkerResult.errors()).hasSize(eventList.size());
assertThat(checkerResult.errors()).hasSameSizeAs(eventList);
assertThat(checkerResult.errors()).containsOnlyElementsOf(eventList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private void doTestLargerTable(boolean checkIfLatestValueIsEmpty) {
}
}
}
assertThat(expectedCells.size()).isEqualTo((1 + 50) * 50 / 2);
assertThat(expectedCells).hasSize((1 + 50) * 50 / 2);
builder.store();
List<CandidateCellForSweeping> candidates = getAllCandidates(ImmutableCandidateCellForSweepingRequest.builder()
.startRowInclusive(PtBytes.EMPTY_BYTE_ARRAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void testSweepBatchesUpToDeleteBatchSize() {
runSweep(cellsSweeper, spiedSweepRunner, 8, 1, 4);
List<List<Cell>> sweptCells = sweptCellsAndSweepResults.getLhSide();

assertThat(sweptCells.size()).isEqualTo(1);
assertThat(sweptCells).hasSize(1);
assertThat(sweptCells.get(0)).isEqualTo(SMALL_LIST_OF_CELLS);
}

Expand Down Expand Up @@ -215,7 +215,7 @@ public void testSweepManyValuesIncludingUncommittedConservative() {
assertThat(results.getStaleValuesDeleted()).isEqualTo(4);
assertThat(results.getCellTsPairsExamined()).isGreaterThanOrEqualTo(5);
assertThat(getFromDefaultColumn("foo", 200)).isEqualTo("buzz");
assertThat(getFromDefaultColumn("foo", 124)).isEqualTo("");
assertThat(getFromDefaultColumn("foo", 124)).isEmpty();
assertThat(getAllTsFromDefaultColumn("foo")).isEqualTo(ImmutableSet.of(-1L, 125L));
}

Expand Down Expand Up @@ -269,7 +269,7 @@ public void testSweepManyLatestDeletedThoroughIncludingUncommitted1() {
// this check is a nuance of SweepTaskRunner: the value at timestamp 125 is actually eligible for deletion,
// but we don't delete it on the first pass due to the later uncommitted value. below we sweep again and make
// sure it's deleted
assertThat(getFromDefaultColumn("foo", 200)).isEqualTo("");
assertThat(getFromDefaultColumn("foo", 200)).isEmpty();
assertThat(getAllTsFromDefaultColumn("foo")).isEqualTo(ImmutableSet.of(125L));

results = completeSweep(175).get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testSweepOneConservative() {
});

assertThat(getFromDefaultColumn("foo", 150)).isEqualTo("baz");
assertThat(getFromDefaultColumn("foo", 80)).isEqualTo("");
assertThat(getFromDefaultColumn("foo", 80)).isEmpty();
assertThat(getAllTsFromDefaultColumn("foo")).isEqualTo(ImmutableSet.of(-1L, 100L));
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public void testSweepManyValuesConservative() {
});

assertThat(getFromDefaultColumn("foo", 200)).isEqualTo("buzz");
assertThat(getFromDefaultColumn("foo", 124)).isEqualTo("");
assertThat(getFromDefaultColumn("foo", 124)).isEmpty();
assertThat(getAllTsFromDefaultColumn("foo")).isEqualTo(ImmutableSet.of(-1L, 125L));
}

Expand Down Expand Up @@ -268,7 +268,7 @@ public void testSweepLatestDeletedMultiValConservative() {
assertThat(results.getCellTsPairsExamined()).isGreaterThanOrEqualTo(1);
});

assertThat(getFromDefaultColumn("foo", 150)).isEqualTo("");
assertThat(getFromDefaultColumn("foo", 150)).isEmpty();
assertThat(getAllTsFromDefaultColumn("foo")).isEqualTo(ImmutableSet.of(-1L, 50L));
}

Expand Down
Loading

0 comments on commit e4bd6a5

Please sign in to comment.