Skip to content

Commit

Permalink
Use AssertJ hasSize method
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Nov 1, 2024
1 parent b58e505 commit c152285
Show file tree
Hide file tree
Showing 149 changed files with 587 additions and 587 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ public void testSimpleQuery()

BufferResult results = sqlTaskManager.getTaskResults(taskId, OUT, 0, DataSize.of(1, Unit.MEGABYTE)).getResultsFuture().get();
assertThat(results.isBufferComplete()).isFalse();
assertThat(results.getSerializedPages().size()).isEqualTo(1);
assertThat(results.getSerializedPages()).hasSize(1);
assertThat(getSerializedPagePositionCount(results.getSerializedPages().get(0))).isEqualTo(1);

for (boolean moreResults = true; moreResults; moreResults = !results.isBufferComplete()) {
results = sqlTaskManager.getTaskResults(taskId, OUT, results.getToken() + results.getSerializedPages().size(), DataSize.of(1, Unit.MEGABYTE)).getResultsFuture().get();
}
assertThat(results.isBufferComplete()).isTrue();
assertThat(results.getSerializedPages().size()).isEqualTo(0);
assertThat(results.getSerializedPages()).hasSize(0);

// complete the task by calling destroy on it
TaskInfo info = sqlTaskManager.destroyTaskResults(taskId, OUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testCommit()
.build();
QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, transactionManager);
assertThat(stateMachine.getSession().getTransactionId()).isPresent();
assertThat(transactionManager.getAllTransactionInfos().size()).isEqualTo(1);
assertThat(transactionManager.getAllTransactionInfos()).hasSize(1);

getFutureValue(new CommitTask(transactionManager).execute(new Commit(new NodeLocation(1, 1)), stateMachine, emptyList(), WarningCollector.NOOP));
assertThat(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void testCreateWithNotNullColumns()
getFutureValue(createTableTask.internalExecute(statement, transactionSession, emptyList(), output -> {}));
assertThat(metadata.getCreateTableCallCount()).isEqualTo(1);
List<ColumnMetadata> columns = metadata.getReceivedTableMetadata().get(0).getColumns();
assertThat(columns.size()).isEqualTo(3);
assertThat(columns).hasSize(3);

assertThat(columns.get(0).getName()).isEqualTo("a");
assertThat(columns.get(0).getType().getDisplayName().toUpperCase(ROOT)).isEqualTo("DATE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void testTopologyAwareScheduling()
}
nonRackLocalSplits = Sets.difference(nonRackLocalSplits, new HashSet<>(assignments.values()));
// Check that 3 of the splits were rejected, since they're non-local
assertThat(nonRackLocalSplits.size()).isEqualTo(3);
assertThat(nonRackLocalSplits).hasSize(3);

// Assign rack-local splits
ImmutableSet.Builder<Split> rackLocalSplits = ImmutableSet.builder();
Expand Down Expand Up @@ -246,7 +246,7 @@ public void testTopologyAwareScheduling()
.build());
}
unassigned = Sets.difference(unassigned, new HashSet<>(assignments.values()));
assertThat(unassigned.size()).isEqualTo(3);
assertThat(unassigned).hasSize(3);
int rack1 = 0;
int rack2 = 0;
for (Split split : unassigned) {
Expand Down Expand Up @@ -297,7 +297,7 @@ public void testBasicAssignment()
splits.add(new Split(TEST_CATALOG_HANDLE, new TestSplitRemote()));
}
Multimap<InternalNode, Split> assignments = nodeSelector.computeAssignments(splits, ImmutableList.copyOf(taskMap.values())).getAssignments();
assertThat(assignments.entries().size()).isEqualTo(assignments.size());
assertThat(assignments.entries()).hasSize(assignments.size());
for (InternalNode node : activeCatalogNodes) {
assertThat(assignments.keySet()).contains(node);
}
Expand Down Expand Up @@ -356,7 +356,7 @@ public void testBasicAssignmentMaxUnacknowledgedSplitsPerTask()
splits.add(new Split(TEST_CATALOG_HANDLE, new TestSplitRemote()));
}
Multimap<InternalNode, Split> assignments = nodeSelector.computeAssignments(splits, ImmutableList.copyOf(taskMap.values())).getAssignments();
assertThat(assignments.entries().size()).isEqualTo(activeCatalogNodes.size());
assertThat(assignments.entries()).hasSize(activeCatalogNodes.size());
for (InternalNode node : activeCatalogNodes) {
assertThat(assignments.keySet()).contains(node);
}
Expand Down Expand Up @@ -399,7 +399,7 @@ public void testMaxSplitsPerNodePerTask()

// no split should be assigned to the newNode, as it already has
// maxSplitsPerNode + maxSplitsPerNodePerTask assigned to it
assertThat(assignments.keySet().size()).isEqualTo(3); // Splits should be scheduled on the other three nodes
assertThat(assignments.keySet()).hasSize(3); // Splits should be scheduled on the other three nodes
assertThat(assignments.keySet().contains(newNode)).isFalse(); // No splits scheduled on the maxed out node

for (RemoteTask task : tasks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void testSplitPageNonDecreasingPageSize()

// the page should only be split in half as the recursion should terminate
// after seeing that the size of the Page doesn't decrease
assertThat(pages.size()).isEqualTo(2);
assertThat(pages).hasSize(2);
Page first = pages.get(0);
Page second = pages.get(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public static void assertExpectedQueryStats(QueryStats actual)
assertThat(actual.getPhysicalWrittenDataSize()).isEqualTo(DataSize.ofBytes(47));
assertThat(actual.getFailedPhysicalWrittenDataSize()).isEqualTo(DataSize.ofBytes(48));

assertThat(actual.getStageGcStatistics().size()).isEqualTo(1);
assertThat(actual.getStageGcStatistics()).hasSize(1);
StageGcStatistics gcStatistics = actual.getStageGcStatistics().get(0);
assertThat(gcStatistics.getStageId()).isEqualTo(101);
assertThat(gcStatistics.getTasks()).isEqualTo(102);
Expand All @@ -389,7 +389,7 @@ public static void assertExpectedQueryStats(QueryStats actual)
assertThat(58).isEqualTo(actual.getLogicalWrittenDataSize().toBytes());

assertThat(DynamicFiltersStats.EMPTY).isEqualTo(actual.getDynamicFiltersStats());
assertThat(actual.getOptimizerRulesSummaries().size()).isEqualTo(optimizerRulesSummaries.size());
assertThat(actual.getOptimizerRulesSummaries()).hasSize(optimizerRulesSummaries.size());
for (int i = 0, end = optimizerRulesSummaries.size(); i < end; i++) {
QueryPlanOptimizerStatistics actualRule = actual.getOptimizerRulesSummaries().get(i);
QueryPlanOptimizerStatistics expectedRule = optimizerRulesSummaries.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testRollback()
.build();
QueryStateMachine stateMachine = createQueryStateMachine("ROLLBACK", session, transactionManager);
assertThat(stateMachine.getSession().getTransactionId()).isPresent();
assertThat(transactionManager.getAllTransactionInfos().size()).isEqualTo(1);
assertThat(transactionManager.getAllTransactionInfos()).hasSize(1);

getFutureValue(new RollbackTask(transactionManager).execute(new Rollback(new NodeLocation(1, 1)), stateMachine, emptyList(), WarningCollector.NOOP));
assertThat(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ public void testSimpleQuery()

BufferResult results = sqlTask.getTaskResults(OUT, 0, DataSize.of(1, MEGABYTE)).get();
assertThat(results.isBufferComplete()).isFalse();
assertThat(results.getSerializedPages().size()).isEqualTo(1);
assertThat(results.getSerializedPages()).hasSize(1);
assertThat(getSerializedPagePositionCount(results.getSerializedPages().get(0))).isEqualTo(1);

for (boolean moreResults = true; moreResults; moreResults = !results.isBufferComplete()) {
results = sqlTask.getTaskResults(OUT, results.getToken() + results.getSerializedPages().size(), DataSize.of(1, MEGABYTE)).get();
}
assertThat(results.getSerializedPages().size()).isEqualTo(0);
assertThat(results.getSerializedPages()).hasSize(0);

// complete the task by calling destroy on it
TaskInfo info = sqlTask.destroyTaskResults(OUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void testGetBasicStageInfo()
assertThat(stageInfo.getState()).isEqualTo(PLANNED);
assertThat(stageInfo.isCoordinatorOnly()).isFalse();
assertThat(stageInfo.getSubStages()).isEmpty();
assertThat(stageInfo.getTasks().size()).isEqualTo(taskInfos.size());
assertThat(stageInfo.getTasks()).hasSize(taskInfos.size());

BasicStageStats stats = stageInfo.getStageStats();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void testStartTransaction()
getFutureValue(new StartTransactionTask(transactionManager).execute(new StartTransaction(new NodeLocation(1, 1), ImmutableList.of()), stateMachine, emptyList(), WarningCollector.NOOP));
assertThat(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()).isFalse();
assertThat(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId()).isPresent();
assertThat(transactionManager.getAllTransactionInfos().size()).isEqualTo(1);
assertThat(transactionManager.getAllTransactionInfos()).hasSize(1);

TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
assertThat(transactionInfo.isAutoCommitContext()).isFalse();
Expand All @@ -160,7 +160,7 @@ public void testStartTransactionExplicitModes()
WarningCollector.NOOP));
assertThat(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()).isFalse();
assertThat(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId()).isPresent();
assertThat(transactionManager.getAllTransactionInfos().size()).isEqualTo(1);
assertThat(transactionManager.getAllTransactionInfos()).hasSize(1);

TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
assertThat(transactionInfo.getIsolationLevel()).isEqualTo(IsolationLevel.SERIALIZABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void testFailStuckSplitTasks()

mockSplitRunner.waitForFinish();
List<TaskInfo> taskInfos = sqlTaskManager.getAllTaskInfo();
assertThat(taskInfos.size()).isEqualTo(1);
assertThat(taskInfos).hasSize(1);

TaskInfo taskInfo = pollTerminatingTaskInfoUntilDone(sqlTaskManager, taskInfos.get(0));
assertThat(taskInfo.taskStatus().getState()).isEqualTo(TaskState.FAILED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public void testResumeFromPreviousPosition()
secondReads.add(buffer.get(completed, result.getNextToken(), sizeOfPages(1)));
}
// Test sanity
assertThat(secondReads.size()).isEqualTo(ids.length);
assertThat(secondReads).hasSize(ids.length);

// Completion order should be identical to the first iteration at this point
for (int i = 0; i < ids.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ public void testGetResourceGroupStateInfo()
assertThat(rootInfo.memoryUsage()).isEqualTo(DataSize.ofBytes(0));
assertThat(rootInfo.cpuUsage().toMillis()).isEqualTo(0);
List<ResourceGroupInfo> subGroups = rootInfo.subGroups().get();
assertThat(subGroups.size()).isEqualTo(2);
assertThat(subGroups).hasSize(2);
assertGroupInfoEquals(subGroups.get(0), rootA.getInfo());
assertThat(subGroups.get(0).id()).isEqualTo(rootA.getId());
assertThat(subGroups.get(0).state()).isEqualTo(CAN_QUEUE);
Expand All @@ -1286,7 +1286,7 @@ public void testGetResourceGroupStateInfo()
assertThat(rootInfo.maxQueuedQueries()).isEqualTo(root.getMaxQueuedQueries());
assertThat(rootInfo.numQueuedQueries()).isEqualTo(19);
List<QueryStateInfo> runningQueries = rootInfo.runningQueries().get();
assertThat(runningQueries.size()).isEqualTo(1);
assertThat(runningQueries).hasSize(1);
QueryStateInfo queryInfo = runningQueries.get(0);
assertThat(queryInfo.getResourceGroupId()).isEqualTo(Optional.of(rootB.getId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testSingleNode()
ScheduleResult result = nodeScheduler.schedule();
assertThat(result.isFinished()).isTrue();
assertThat(result.getBlocked().isDone()).isTrue();
assertThat(result.getNewTasks().size()).isEqualTo(1);
assertThat(result.getNewTasks()).hasSize(1);
assertThat(result.getNewTasks().iterator().next().getNodeId()).isEqualTo("other 0");
}

Expand All @@ -94,8 +94,8 @@ public void testMultipleNodes()
ScheduleResult result = nodeScheduler.schedule();
assertThat(result.isFinished()).isTrue();
assertThat(result.getBlocked().isDone()).isTrue();
assertThat(result.getNewTasks().size()).isEqualTo(5);
assertThat(result.getNewTasks().stream().map(RemoteTask::getNodeId).collect(toImmutableSet()).size()).isEqualTo(5);
assertThat(result.getNewTasks()).hasSize(5);
assertThat(result.getNewTasks().stream().map(RemoteTask::getNodeId).collect(toImmutableSet())).hasSize(5);
}

private static List<InternalNode> generateRandomNodes(int count)
Expand Down
Loading

0 comments on commit c152285

Please sign in to comment.