Search in sources :

Example 1 with StreamSubscription

use of com.github.jamesnetherton.zulip.client.api.stream.StreamSubscription in project zulip-java-client by jamesnetherton.

the class ZulipStreamIT method streamSubscribeUnsubscribe.

@Test
public void streamSubscribeUnsubscribe() throws ZulipClientException {
    // Create
    zulip.streams().subscribe(StreamSubscriptionRequest.of("Test Subscribed", "Test Subscribed")).execute();
    // Check subscriptions
    List<StreamSubscription> subscriptions = zulip.streams().getSubscribedStreams().withIncludeSubscribers(true).execute();
    assertEquals(1, subscriptions.size());
    StreamSubscription streamSubscription = subscriptions.get(0);
    List<String> subscribers = streamSubscription.getSubscribers();
    assertEquals(1, subscribers.size());
    String email = subscribers.get(0);
    assertEquals("test@test.com", email);
    // Get ID
    Long streamId = zulip.streams().getStreamId("Test Subscribed").execute();
    // Verify subscribed
    assertTrue(zulip.streams().isSubscribed(ownUser.getUserId(), streamId).execute());
    // Unsubscribe
    zulip.streams().unsubscribe("Test Subscribed").execute();
    assertFalse(zulip.streams().isSubscribed(ownUser.getUserId(), streamId).execute());
}
Also used : StreamSubscription(com.github.jamesnetherton.zulip.client.api.stream.StreamSubscription) Test(org.junit.jupiter.api.Test)

Aggregations

StreamSubscription (com.github.jamesnetherton.zulip.client.api.stream.StreamSubscription)1 Test (org.junit.jupiter.api.Test)1