Fix test assertions that depend on undefined row ordering (#3007)

* Fix test assertions that depend on undefined row ordering

Several tests use containsExactly() or index-based comparison on query
results that have no ORDER BY clause. SQL does not guarantee row ordering
without explicit ORDER BY, and databases like YugabyteDB return results
in a different (but valid) order than PostgreSQL/H2.

These tests verify set membership (correct targets assigned, correct
actions stored), not ordering. Changed to order-independent assertions:

- AutoAssignTest: containsExactly -> containsExactlyInAnyOrder
- ControllerManagementTest: index-based loop -> containsExactlyInAnyOrderElementsOf
- TargetFilterQueryManagementTest: containsExactly -> containsExactlyInAnyOrder

Verified passing on H2 (default) and YugabyteDB (PostgreSQL-compatible).

* Trigger ECA re-check
This commit is contained in:
clayly
2026-04-21 17:21:38 +03:00
committed by GitHub
parent bdb87a95d9
commit 2e53a66b79
3 changed files with 6 additions and 7 deletions

View File

@@ -76,6 +76,6 @@ class AutoAssignTest extends AbstractAccessControllerManagementTest {
.as("Only updatable targets should be part of the rollout")
// all targets are distribution set type 2 compatible, but since user has UPDATE_TARGET only for targets of type 2
// only target2 and target3 shall be assigned
.containsExactly(target2Type2.getId(), target3Type2.getId());
.containsExactlyInAnyOrder(target2Type2.getId(), target3Type2.getId());
}
}

View File

@@ -1441,10 +1441,9 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
root.get(JpaAction_.externalRef).in(allExternalRef),
cb.equal(root.get(JpaAction_.active), true)
)).stream().map(Action.class::cast).toList();
assertThat(foundAction).isNotNull();
for (int i = 0; i < numberOfActions; i++) {
assertThat(foundAction.get(i).getId()).isEqualTo(allActionId.get(i));
}
assertThat(foundAction).isNotNull().hasSize(numberOfActions);
assertThat(foundAction).extracting(Action::getId)
.containsExactlyInAnyOrderElementsOf(allActionId);
}
/**

View File

@@ -520,7 +520,7 @@ class TargetFilterQueryManagementTest extends AbstractRepositoryManagementTest<T
private void verifyExpectedFilterQueriesInList(final Slice<TargetFilterQuery> tfqList,
final TargetFilterQuery... expectedFilterQueries) {
assertThat(tfqList.map(TargetFilterQuery::getId)).containsExactly(
assertThat(tfqList.map(TargetFilterQuery::getId)).containsExactlyInAnyOrder(
Arrays.stream(expectedFilterQueries).map(TargetFilterQuery::getId).toArray(Long[]::new));
}
@@ -536,7 +536,7 @@ class TargetFilterQueryManagementTest extends AbstractRepositoryManagementTest<T
final TargetFilterQuery... expectedFilterQueries) {
assertThat(expectedFilterQueries).as("Target filter query count").hasSize((int) tfqList.getTotalElements());
assertThat(tfqList.map(TargetFilterQuery::getId)).containsExactly(
assertThat(tfqList.map(TargetFilterQuery::getId)).containsExactlyInAnyOrder(
Arrays.stream(expectedFilterQueries).map(TargetFilterQuery::getId).toArray(Long[]::new));
}