Skip to content

Commit

Permalink
Merge 582e2e9 into 78814d2
Browse files Browse the repository at this point in the history
  • Loading branch information
guusdk committed Apr 10, 2024
2 parents 78814d2 + 582e2e9 commit 5a4af2b
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.Set;
import java.util.concurrent.TimeoutException;

import org.jivesoftware.smack.SmackException;
Expand Down Expand Up @@ -794,23 +795,27 @@ public void mucTestDefaultRoleForAffiliationInMembersOnlyRoom() throws Exception

createMembersOnlyMuc(mucAsSeenByOne, nicknameOne);

final SimpleResultSyncPoint adminResultSyncPoint = new SimpleResultSyncPoint();
final SimpleResultSyncPoint allOccupantsDetectedSyncPoint = new SimpleResultSyncPoint();
final Set<EntityFullJid> expectedOccupants = Set.of(jidOne, jidTwo, jidThree);
mucAsSeenByOne.addParticipantStatusListener(new ParticipantStatusListener() {
@Override
public void adminGranted(EntityFullJid participant) {
adminResultSyncPoint.signal();
public void joined(EntityFullJid participant) {
if (mucAsSeenByOne.getOccupants().containsAll(expectedOccupants)) {
allOccupantsDetectedSyncPoint.signal();
}
}
});

try {
mucAsSeenByOne.grantMembership(conTwo.getUser().asBareJid());
mucAsSeenByOne.grantMembership(conThree.getUser().asBareJid());
mucAsSeenByOne.grantAdmin(conTwo.getUser().asBareJid());

mucAsSeenByTwo.join(nicknameTwo);
mucAsSeenByThree.join(nicknameThree);
mucAsSeenByOne.grantAdmin(conTwo.getUser().asBareJid());
adminResultSyncPoint.waitForResult(timeout);
assertEquals(mucAsSeenByOne.getOccupantsCount(), 3, "Unexpected occupant count in room " + mucAddress);

allOccupantsDetectedSyncPoint.waitForResult(timeout);

assertEquals(MUCRole.moderator, mucAsSeenByOne.getOccupant(jidOne).getRole(), "Unexpected role for occupant " + jidOne + " in room " + mucAddress);
assertEquals(MUCRole.moderator, mucAsSeenByOne.getOccupant(jidTwo).getRole(), "Unexpected role for occupant " + jidTwo + " in room " + mucAddress);
assertEquals(MUCRole.participant, mucAsSeenByOne.getOccupant(jidThree).getRole(), "Unexpected role for occupant " + jidThree + " in room " + mucAddress);
Expand Down

0 comments on commit 5a4af2b

Please sign in to comment.