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 (#5873)
Browse files Browse the repository at this point in the history
* Excavator: Prefer AssertJ

* Excavator: Prefer AssertJ

* lol

Co-authored-by: Grgur Petric Maretic <[email protected]>
  • Loading branch information
svc-excavator-bot and gmaretic authored Feb 21, 2022
1 parent 831c05e commit 71e2ea6
Show file tree
Hide file tree
Showing 55 changed files with 230 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void rowWithNullsParsesAllCombinationsForCells() {
Cell.create(new byte[] {1, 0, 2}, new byte[] {3, 0, 4, 5, 6}),
Cell.create(new byte[] {1, 0, 2, 0, 3}, new byte[] {4, 5, 6}));

assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor)).isEqualTo(expected);
assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor)).containsExactlyElementsOf(expected);
assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor))
.contains(CellReference.of(TABLE, Cell.create(ROW_WITH_ZEROS, NO_ZERO_COL)));
}
Expand All @@ -97,7 +97,7 @@ public void colWithNullsParsesAllCombinationsForCells() {
Cell.create(new byte[] {1, 2, 3, 0, 4}, new byte[] {0, 5, 6}),
Cell.create(new byte[] {1, 2, 3, 0, 4, 0}, new byte[] {5, 6}));

assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor)).isEqualTo(expected);
assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor)).containsExactlyElementsOf(expected);
assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor))
.contains(CellReference.of(TABLE, Cell.create(NO_ZERO_ROW, COL_WITH_ZEROS)));
}
Expand All @@ -110,7 +110,7 @@ public void rowEndingWithZeroIsCorrectlyParsedForCombinationsForCells() {
Cell.create(new byte[] {4, 5, 6}, new byte[] {0, 4, 5, 6}),
Cell.create(new byte[] {4, 5, 6, 0}, new byte[] {4, 5, 6}));

assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor)).isEqualTo(expected);
assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor)).containsExactlyElementsOf(expected);
assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor))
.contains(CellReference.of(TABLE, Cell.create(END_WITH_ZERO, NO_ZERO_COL)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public void testGetRows_manyColumnRows() {
Map<Cell, Value> result = keyValueService.getRows(
tableReference, ImmutableList.of(row1), ColumnSelection.all(), STARTING_ATLAS_TIMESTAMP - 1);

assertThat(result).isEqualTo(tableValues);
assertThat(result).containsExactlyInAnyOrderEntriesOf(tableValues);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void getSizeOfMutationPerTableOnBatchMutate() {
long expectedSize = EMPTY_COLUMN_OR_SUPERCOLUMN_SIZE + NULL_SIZE + TEST_NAME_BYTES_SIZE;

assertThat(ThriftObjectSizeUtils.getSizeOfMutationPerTable(batchMutateMap))
.isEqualTo(ImmutableMap.of(TEST_NAME, expectedSize));
.containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(TEST_NAME, expectedSize));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void canGetValuesFromSelectionResult() {
CqlResult mockResult =
createMockCqlResult(ImmutableList.of(createMockCqlRow(columnList1), createMockCqlRow(columnList2)));
assertThat(CassandraTimestampUtils.getValuesFromSelectionResult(mockResult))
.isEqualTo(ImmutableMap.of(COLUMN_NAME_1, VALUE_1, COLUMN_NAME_2, VALUE_2));
.containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(COLUMN_NAME_1, VALUE_1, COLUMN_NAME_2, VALUE_2));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void freshInstanceSetsStrategyOptions() throws TException {
when(config.replicationFactor()).thenReturn(3);

KsDef ksDef = CassandraVerifier.createKsDefForFresh(client, config);
assertThat(ksDef.strategy_options).isEqualTo(ImmutableMap.of(DC_1, "3", DC_2, "3"));
assertThat(ksDef.strategy_options).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(DC_1, "3", DC_2, "3"));
}

@Test
Expand All @@ -183,7 +183,7 @@ public void simpleStrategyOneDcOneRfSucceedsAndUpdatesKsDef() throws TException

ksDef = CassandraVerifier.checkAndSetReplicationFactor(client, ksDef, config);
assertThat(ksDef.strategy_class).isEqualTo(CassandraConstants.NETWORK_STRATEGY);
assertThat(ksDef.strategy_options).isEqualTo(ImmutableMap.of(DC_1, "1"));
assertThat(ksDef.strategy_options).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(DC_1, "1"));
}

@Test
Expand Down Expand Up @@ -222,7 +222,7 @@ public void returnSameKsDefIfNodeTopologyChecksIgnored() throws TException {

ksDef = CassandraVerifier.checkAndSetReplicationFactor(client, ksDef, config);
assertThat(ksDef.strategy_class).isEqualTo(CassandraConstants.SIMPLE_STRATEGY);
assertThat(ksDef.strategy_options).isEqualTo(strategyOptions);
assertThat(ksDef.strategy_options).containsExactlyInAnyOrderEntriesOf(strategyOptions);
}

@Test
Expand All @@ -239,7 +239,7 @@ public void networkStrategyMultipleDcsSucceeds() throws TException {
ksDef.setStrategy_options(strategyOptions);

ksDef = CassandraVerifier.checkAndSetReplicationFactor(client, ksDef, config);
assertThat(ksDef.strategy_options).isEqualTo(strategyOptions);
assertThat(ksDef.strategy_options).containsExactlyInAnyOrderEntriesOf(strategyOptions);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void handlesNullMultigetSliceResponseFromDelegate() throws TException {
ImmutableList.of(byteBuffer),
new SlicePredicate(),
ConsistencyLevel.QUORUM))
.isEqualTo(resultMap);
.containsExactlyInAnyOrderEntriesOf(resultMap);

verify(delegate)
.multiget_slice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void shouldOnlyReturnLocalHosts() {

cassandra.setLocalHosts(localHosts);

assertThat(cassandra.maybeFilterLocalHosts(hosts)).isEqualTo(localHosts);
assertThat(cassandra.maybeFilterLocalHosts(hosts)).containsExactlyInAnyOrderElementsOf(localHosts);
}

@Test
Expand All @@ -73,7 +73,7 @@ public void shouldReturnAllHostsBySkippingFilter() {

cassandra.setLocalHosts(localHosts);

assertThat(cassandra.maybeFilterLocalHosts(hosts)).isEqualTo(hosts);
assertThat(cassandra.maybeFilterLocalHosts(hosts)).containsExactlyInAnyOrderElementsOf(hosts);
}

@Test
Expand All @@ -85,7 +85,7 @@ public void shouldReturnAllHostsAsNoIntersection() {

cassandra.setLocalHosts(localHosts);

assertThat(cassandra.maybeFilterLocalHosts(hosts)).isEqualTo(hosts);
assertThat(cassandra.maybeFilterLocalHosts(hosts)).containsExactlyInAnyOrderElementsOf(hosts);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void testSelectingHostFromWeightedHostsMatchesWeight() {
numTimesSelected.put(host, numTimesSelected.get(host) + 1);
}

assertThat(numTimesSelected).isEqualTo(hostsToWeight);
assertThat(numTimesSelected).containsExactlyInAnyOrderEntriesOf(hostsToWeight);
}

private static CassandraClientPoolingContainer createMockClientPoolingContainerWithUtilization(int utilization) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void checkKvs(AtlasDbServices services, int numTables, int numEntriesPer
}
Map<Cell, byte[]> expected = expectedBuilder.build();
Map<Cell, byte[]> result = t.get(table, expected.keySet());
assertThat(result.keySet()).isEqualTo(expected.keySet());
assertThat(result.keySet()).containsExactlyInAnyOrderElementsOf(expected.keySet());
for (Map.Entry<Cell, byte[]> e : result.entrySet()) {
assertThat(e.getValue()).isEqualTo(expected.get(e.getKey()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void testScrubQueueMigration() {
scrubStore.getBatchingVisitableScrubQueue(
Long.MAX_VALUE, PtBytes.EMPTY_BYTE_ARRAY, PtBytes.EMPTY_BYTE_ARRAY);
assertThat(Iterables.getOnlyElement(BatchingVisitables.copyToList(visitable)))
.isEqualTo(ImmutableSortedMap.of(
.containsExactlyInAnyOrderEntriesOf(ImmutableSortedMap.of(
10L, ImmutableMultimap.of(foo, cell1, bar, cell1),
20L, ImmutableMultimap.of(baz, cell1),
30L, ImmutableMultimap.of(foo, cell2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ public void testSweepTable() throws Exception {

assertThat(get(kvs, TABLE_ONE, "foo", ts5)).isEqualTo("baz");
assertThat(get(kvs, TABLE_ONE, "foo", mid(ts1, ts3))).isEqualTo(deletedValue("bar"));
assertThat(getAllTs(kvs, TABLE_ONE, "foo")).isEqualTo(ImmutableSet.of(deletedTimestamp(ts1), ts3));
assertThat(getAllTs(kvs, TABLE_ONE, "foo")).containsExactlyInAnyOrder(deletedTimestamp(ts1), ts3);
assertThat(get(kvs, TABLE_TWO, "foo", ts5)).isEqualTo("taz");
assertThat(get(kvs, TABLE_TWO, "foo", mid(ts3, ts4))).isEqualTo("tar");
assertThat(getAllTs(kvs, TABLE_TWO, "foo")).isEqualTo(ImmutableSet.of(ts2, ts4));
assertThat(getAllTs(kvs, TABLE_TWO, "foo")).containsExactlyInAnyOrder(ts2, ts4);
}
}

Expand Down Expand Up @@ -168,13 +168,13 @@ public void testSweepNamespace() throws Exception {

assertThat(get(kvs, TABLE_ONE, "foo", ts7)).isEqualTo("baz");
assertThat(get(kvs, TABLE_ONE, "foo", mid(ts1, ts2))).isEqualTo(deletedValue("bar"));
assertThat(getAllTs(kvs, TABLE_ONE, "foo")).isEqualTo(ImmutableSet.of(deletedTimestamp(ts1), ts4));
assertThat(getAllTs(kvs, TABLE_ONE, "foo")).containsExactlyInAnyOrder(deletedTimestamp(ts1), ts4);
assertThat(get(kvs, TABLE_TWO, "foo", ts7)).isEqualTo("taz");
assertThat(get(kvs, TABLE_TWO, "foo", mid(ts4, ts6))).isEqualTo(deletedValue("tar"));
assertThat(getAllTs(kvs, TABLE_TWO, "foo")).isEqualTo(ImmutableSet.of(deletedTimestamp(ts2), ts6));
assertThat(getAllTs(kvs, TABLE_TWO, "foo")).containsExactlyInAnyOrder(deletedTimestamp(ts2), ts6);
assertThat(get(kvs, TABLE_THREE, "foo", ts7)).isEqualTo("jaz");
assertThat(get(kvs, TABLE_THREE, "foo", mid(ts3, ts5))).isEqualTo("jar");
assertThat(getAllTs(kvs, TABLE_THREE, "foo")).isEqualTo(ImmutableSet.of(ts3, ts5));
assertThat(getAllTs(kvs, TABLE_THREE, "foo")).containsExactlyInAnyOrder(ts3, ts5);
}
}

Expand All @@ -200,13 +200,13 @@ public void testSweepAll() throws Exception {

assertThat(get(kvs, TABLE_ONE, "foo", ts7)).isEqualTo("baz");
assertThat(get(kvs, TABLE_ONE, "foo", mid(ts1, ts2))).isEqualTo(deletedValue("bar"));
assertThat(getAllTs(kvs, TABLE_ONE, "foo")).isEqualTo(ImmutableSet.of(deletedTimestamp(ts1), ts4));
assertThat(getAllTs(kvs, TABLE_ONE, "foo")).containsExactlyInAnyOrder(deletedTimestamp(ts1), ts4);
assertThat(get(kvs, TABLE_TWO, "foo", ts7)).isEqualTo("taz");
assertThat(get(kvs, TABLE_TWO, "foo", mid(ts4, ts6))).isEqualTo(deletedValue("tar"));
assertThat(getAllTs(kvs, TABLE_TWO, "foo")).isEqualTo(ImmutableSet.of(deletedTimestamp(ts2), ts6));
assertThat(getAllTs(kvs, TABLE_TWO, "foo")).containsExactlyInAnyOrder(deletedTimestamp(ts2), ts6);
assertThat(get(kvs, TABLE_THREE, "foo", ts7)).isEqualTo("jaz");
assertThat(get(kvs, TABLE_THREE, "foo", mid(ts3, ts5))).isEqualTo(deletedValue("jar"));
assertThat(getAllTs(kvs, TABLE_THREE, "foo")).isEqualTo(ImmutableSet.of(deletedTimestamp(ts3), ts5));
assertThat(getAllTs(kvs, TABLE_THREE, "foo")).containsExactlyInAnyOrder(deletedTimestamp(ts3), ts5);
}
}

Expand Down Expand Up @@ -236,8 +236,9 @@ public void testSweepStartRow() throws Exception {
assertThat(get(kvs, TABLE_ONE, "foo", mid(ts2, ts4))).isEqualTo(deletedValue("biz"));
assertThat(get(kvs, TABLE_ONE, "boo", mid(ts3, ts5))).isEqualTo("biz");
assertThat(getAllTs(kvs, TABLE_ONE, "foo"))
.isEqualTo(ImmutableSet.of(deletedTimestamp(ts1), deletedTimestamp(ts2), ts4));
assertThat(getAllTs(kvs, TABLE_ONE, "boo")).isEqualTo(ImmutableSet.of(ts3));
.containsExactlyInAnyOrderElementsOf(
ImmutableSet.of(deletedTimestamp(ts1), deletedTimestamp(ts2), ts4));
assertThat(getAllTs(kvs, TABLE_ONE, "boo")).containsExactlyInAnyOrder(ts3);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public void allAtomicTablesHaveExplicitReadConsistencyDecision() {
assertThat(Sets.union(
AtlasDbConstants.NON_SERIAL_CONSISTENCY_ATOMIC_TABLES,
AtlasDbConstants.SERIAL_CONSISTENCY_ATOMIC_TABLES))
.isEqualTo(AtlasDbConstants.ATOMIC_TABLES);
.containsExactlyInAnyOrderElementsOf(AtlasDbConstants.ATOMIC_TABLES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void get() throws Exception {

Map<Cell, Value> result = kvs.get(TABLE_REF, cells);

assertThat(result).isEqualTo(expectedResult);
assertThat(result).containsExactlyInAnyOrderEntriesOf(expectedResult);
checkSpan("atlasdb-kvs.get", ImmutableMap.of("table", "{table}", "cells", "1"));
verify(delegate).get(TABLE_REF, cells);
verifyNoMoreInteractions(delegate);
Expand Down Expand Up @@ -241,7 +241,7 @@ public void getFirstBatchForRanges() {
Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> result =
kvs.getFirstBatchForRanges(TABLE_REF, RANGE_REQUESTS, TIMESTAMP);

assertThat(result).isEqualTo(expectedResult);
assertThat(result).containsExactlyInAnyOrderEntriesOf(expectedResult);
checkSpan("atlasdb-kvs.getFirstBatchForRanges", ImmutableMap.of("table", "{table}", "ranges", "1", "ts", "2"));
verify(delegate).getFirstBatchForRanges(TABLE_REF, RANGE_REQUESTS, TIMESTAMP);
verifyNoMoreInteractions(delegate);
Expand Down Expand Up @@ -279,7 +279,7 @@ public void getMetadataForTables() {

Map<TableReference, byte[]> result = kvs.getMetadataForTables();

assertThat(result).isEqualTo(expectedResult);
assertThat(result).containsExactlyInAnyOrderEntriesOf(expectedResult);
checkSpan("atlasdb-kvs.getMetadataForTables");
verify(delegate).getMetadataForTables();
verifyNoMoreInteractions(delegate);
Expand All @@ -294,7 +294,7 @@ public void getRows() throws Exception {

Map<Cell, Value> result = kvs.getRows(TABLE_REF, rows, ColumnSelection.all(), TIMESTAMP);

assertThat(result).isEqualTo(expectedResult);
assertThat(result).containsExactlyInAnyOrderEntriesOf(expectedResult);
checkSpan("atlasdb-kvs.getRows", ImmutableMap.of("table", "{table}", "rows", "1", "ts", "2"));
verify(delegate).getRows(TABLE_REF, rows, ColumnSelection.all(), TIMESTAMP);
verifyNoMoreInteractions(delegate);
Expand All @@ -310,7 +310,7 @@ public void getRowsColumnRangeBatch() {

Map<byte[], RowColumnRangeIterator> result = kvs.getRowsColumnRange(TABLE_REF, rows, range, TIMESTAMP);

assertThat(result).isEqualTo(expectedResult);
assertThat(result).containsExactlyInAnyOrderEntriesOf(expectedResult);
checkSpan("atlasdb-kvs.getRowsColumnRange", ImmutableMap.of("table", "{table}", "rows", "1", "ts", "2"));
verify(delegate).getRowsColumnRange(TABLE_REF, rows, range, TIMESTAMP);
verifyNoMoreInteractions(delegate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public void testGetMultipleRowsFirstColumn() {

Map<String, Long> result = getMultipleRowsFirstColumn(transaction, Arrays.asList(TEST_ROW_KEY, TEST_ROW_KEY2));

assertThat(result).isEqualTo(ImmutableMap.of(TEST_ROW_KEY, TEST_VALUE_LONG, TEST_ROW_KEY2, TEST_VALUE_LONG2));
assertThat(result)
.containsExactlyInAnyOrderEntriesOf(
ImmutableMap.of(TEST_ROW_KEY, TEST_VALUE_LONG, TEST_ROW_KEY2, TEST_VALUE_LONG2));
ArgumentCaptor<Iterable<byte[]>> argument = ArgumentCaptor.forClass(Iterable.class);
verify(transaction, times(1)).getRows(eq(tableRef), argument.capture(), eq(FIRST_COLUMN_SELECTION));

Expand Down Expand Up @@ -173,7 +175,8 @@ public void testRowRangeSecondColumn() {
Map<String, StringValue> result = getRangeSecondColumn(transaction, TEST_ROW_KEY, RANGE_END_ROW_KEY);

assertThat(result)
.isEqualTo(ImmutableMap.of(TEST_ROW_KEY, TEST_VALUE_STRING, TEST_ROW_KEY2, TEST_VALUE_STRING2));
.containsExactlyInAnyOrderEntriesOf(
ImmutableMap.of(TEST_ROW_KEY, TEST_VALUE_STRING, TEST_ROW_KEY2, TEST_VALUE_STRING2));
verify(transaction, times(1)).getRange(tableRef, expectedRange);
}

Expand Down Expand Up @@ -201,7 +204,8 @@ public void testRowRangeSecondColumnFirstTwoResults() {
getRangeSecondColumnOnlyFirstTwoResults(transaction, TEST_ROW_KEY, RANGE_END_ROW_KEY);

assertThat(result)
.isEqualTo(ImmutableMap.of(TEST_ROW_KEY, TEST_VALUE_STRING, TEST_ROW_KEY2, TEST_VALUE_STRING2));
.containsExactlyInAnyOrderEntriesOf(
ImmutableMap.of(TEST_ROW_KEY, TEST_VALUE_STRING, TEST_ROW_KEY2, TEST_VALUE_STRING2));
verify(transaction, times(1)).getRange(tableRef, expectedRange);
}

Expand Down
Loading

0 comments on commit 71e2ea6

Please sign in to comment.