1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-24 11:38:00 +01:00

[sinttest] Refactor MultiResulitSyncPoint TimeoutException message construction for readability

This commit is contained in:
Florian Schmaus 2024-06-27 16:49:23 +02:00
parent 68fa90435e
commit 9254f735c7
2 changed files with 10 additions and 2 deletions

View file

@ -44,7 +44,15 @@ public class MultiResultSyncPoint<R, E extends Exception> {
wait(deadline - now);
now = System.currentTimeMillis();
}
if (now >= deadline) throw new TimeoutException((timeoutMessage != null ? timeoutMessage + " " : "") + "MultiResultSyncPoint timeout waiting " + timeout + " millis. Got " + results.size() + " results of " + expectedResultCount + " results");
if (now >= deadline) {
StringBuilder sb = new StringBuilder();
if (timeoutMessage != null) {
sb.append(timeoutMessage).append(". ");
}
sb.append("MultiResultSyncPoint timeout waiting " + timeout + " ms. Got " + results.size() + " results of " + expectedResultCount + " results");
throw new TimeoutException(sb.toString());
}
if (exception != null) throw exception;
return new ArrayList<>(results);
}

View file

@ -292,7 +292,7 @@ public class MultiUserChatOccupantIntegrationTest extends AbstractMultiUserChatI
try {
mucAsSeenByThree.join(nicknameThree);
List<Presence> results = assertResult(syncPoint, "Expected all occupants of room '" + mucAddress + "' to be notified of '" + conThree.getUser() + "' using nickname '" + nicknameThree + "' joining the room (but one or more did not get notified).");
List<Presence> results = assertResult(syncPoint, "Expected all occupants of room '" + mucAddress + "' to be notified of '" + conThree.getUser() + "' using nickname '" + nicknameThree + "' joining the room (but one or more did not get notified)");
assertTrue(results.stream().allMatch(
result -> JidCreate.fullFrom(mucAddress, nicknameThree).equals(result.getFrom())),
"Expected all occupants of room '" + mucAddress + "' to be notified of '" + conThree.getUser() + "' using nickname '" + nicknameThree + "' joining the room (but one or more got notified for a different user).");