lhotari commented on code in PR #24871:
URL: https://github.com/apache/pulsar/pull/24871#discussion_r2514321566
##########
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/PoliciesDataTest.java:
##########
@@ -71,7 +72,11 @@ public void propertyAdmin() {
assertNotEquals(TenantInfo.builder().build(), pa1);
assertNotEquals(TenantInfo.builder().adminRoles(Sets.newHashSet("role1",
"role3"))
.allowedClusters(Sets.newHashSet("usc")).build(), pa1);
- assertEquals(pa1.getAdminRoles(), Lists.newArrayList("role1",
"role2"));
+
+ // Order array results deterministically before comparison because
HashSet makes no guarantees on order
+ List<String> roles = new ArrayList<>(pa1.getAdminRoles());
+ Collections.sort(roles);
+ assertEquals(roles, Lists.newArrayList("role1", "role2"));
Review Comment:
use AssertJ instead.
```
import static org.assertj.core.api.Assertions.assertThat;
...
assertThat(pa1.getAdminRoles()).containsExactlyInAnyOrder("role1", "role2");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]