forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf6563b
commit f648715
Showing
40 changed files
with
6,413 additions
and
84 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
* @kleewho @bartk @budgetpreneur | ||
.travis/* @parfeon @kleewho @bartk @budgetpreneur | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,4 +48,6 @@ target | |
build | ||
.gradle | ||
out | ||
gradlew.bat | ||
gradlew.bat | ||
|
||
/src/integrationTest/resources/config.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
src/integrationTest/java/com/pubnub/api/integration/GroupManagementIntegrationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package com.pubnub.api.integration; | ||
|
||
import com.pubnub.api.integration.util.BaseIntegrationTest; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.concurrent.CountDownLatch; | ||
|
||
import static com.pubnub.api.integration.util.Utils.random; | ||
import static com.pubnub.api.integration.util.Utils.randomChannel; | ||
import static org.junit.Assert.*; | ||
|
||
public class GroupManagementIntegrationTests extends BaseIntegrationTest { | ||
|
||
private String mChannel1; | ||
private String mChannel2; | ||
private String mChannel3; | ||
|
||
private String mGroup; | ||
|
||
@Override | ||
protected void onBefore() { | ||
mChannel1 = randomChannel(); | ||
mChannel2 = randomChannel(); | ||
mChannel3 = randomChannel(); | ||
mGroup = "cg_".concat(random()); | ||
} | ||
|
||
@Override | ||
protected void onAfter() { | ||
|
||
} | ||
|
||
@Test | ||
public void testRemoveChannelsFromGroup() throws InterruptedException { | ||
final CountDownLatch signal = new CountDownLatch(1); | ||
|
||
addChannelsToGroup(); | ||
|
||
pubNub.removeChannelsFromChannelGroup() | ||
.channelGroup(mGroup) | ||
.channels(Arrays.asList(mChannel1, mChannel2, mChannel3)) | ||
.async((result, status) -> { | ||
assertFalse(status.isError()); | ||
assert status.getAffectedChannels() != null; | ||
assertEquals(3, status.getAffectedChannels().size()); | ||
assertEquals(0, pubNub.getSubscribedChannels().size()); | ||
assert status.getAffectedChannelGroups() != null; | ||
assertEquals(1, status.getAffectedChannelGroups().size()); | ||
assertEquals(0, pubNub.getSubscribedChannelGroups().size()); | ||
signal.countDown(); | ||
}); | ||
|
||
signal.await(); | ||
} | ||
|
||
@Test | ||
public void testRemoveChannelFromGroup() throws InterruptedException { | ||
final CountDownLatch signal = new CountDownLatch(1); | ||
|
||
addChannelsToGroup(); | ||
|
||
pubNub.removeChannelsFromChannelGroup() | ||
.channelGroup(mGroup) | ||
.channels(Collections.singletonList(mChannel1)) | ||
.async((result, status) -> { | ||
assertFalse(status.isError()); | ||
signal.countDown(); | ||
}); | ||
|
||
signal.await(); | ||
} | ||
|
||
@Test | ||
public void testSubscribeToChannelGroup() throws InterruptedException { | ||
addChannelsToGroup(); | ||
subscribeToChannelGroup(pubNub, mGroup); | ||
|
||
boolean isGroupSubscribed = false; | ||
for (int i = 0; i < pubNub.getSubscribedChannelGroups().size(); i++) { | ||
if (pubNub.getSubscribedChannelGroups().get(i).equals(mGroup)) { | ||
isGroupSubscribed = true; | ||
} | ||
} | ||
|
||
assertTrue(isGroupSubscribed); | ||
} | ||
|
||
@Test | ||
public void testUnsubscribeFromChannelGroup() throws InterruptedException { | ||
addChannelsToGroup(); | ||
subscribeToChannelGroup(pubNub, mGroup); | ||
|
||
pubNub.unsubscribe() | ||
.channelGroups(Collections.singletonList(mGroup)) | ||
.execute(); | ||
|
||
pause(1); | ||
|
||
assertEquals(0, pubNub.getSubscribedChannelGroups().size()); | ||
} | ||
|
||
@Test | ||
public void testGetAllChannelsFromGroup() throws InterruptedException { | ||
final CountDownLatch signal = new CountDownLatch(1); | ||
|
||
addChannelsToGroup(); | ||
|
||
pubNub.listChannelsForChannelGroup() | ||
.channelGroup(mGroup) | ||
.async((result, status) -> { | ||
assertFalse(status.isError()); | ||
assert result != null; | ||
assertEquals(3, result.getChannels().size()); | ||
signal.countDown(); | ||
}); | ||
|
||
signal.await(); | ||
} | ||
|
||
@Test | ||
public void testAddChannelsToGroup() throws InterruptedException { | ||
final CountDownLatch signal = new CountDownLatch(1); | ||
|
||
pubNub.addChannelsToChannelGroup() | ||
.channelGroup(mGroup) | ||
.channels(Arrays.asList(mChannel1, mChannel2, mChannel3)) | ||
.async((result, status) -> { | ||
assertFalse(status.isError()); | ||
assert status.getAffectedChannelGroups() != null; | ||
assertEquals(1, status.getAffectedChannelGroups().size()); | ||
assert status.getAffectedChannels() != null; | ||
assertEquals(3, status.getAffectedChannels().size()); | ||
signal.countDown(); | ||
}); | ||
|
||
signal.await(); | ||
} | ||
|
||
private void addChannelsToGroup() throws InterruptedException { | ||
final CountDownLatch signal = new CountDownLatch(1); | ||
|
||
pubNub.addChannelsToChannelGroup() | ||
.channelGroup(mGroup) | ||
.channels(Arrays.asList(mChannel1, mChannel2, mChannel3)) | ||
.async((result, status) -> { | ||
assertFalse(status.isError()); | ||
signal.countDown(); | ||
}); | ||
|
||
signal.await(); | ||
} | ||
|
||
} |
Oops, something went wrong.