Search in sources :

Example 1 with Topic

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

the class ZulipStreamIT method streamTopics.

@Test
public void streamTopics() throws ZulipClientException {
    // Create
    zulip.streams().subscribe(StreamSubscriptionRequest.of("Test Stream For Topic", "Test Stream For Topic")).withAuthorizationErrorsFatal(false).withHistoryPublicToSubscribers(true).withInviteOnly(false).withMessageRetention(RetentionPolicy.FOREVER).withStreamPostPolicy(StreamPostPolicy.ANY).execute();
    // Get ID
    Long streamId = zulip.streams().getStreamId("Test Stream For Topic").execute();
    List<Topic> topics = zulip.streams().getTopics(streamId).execute();
    assertEquals(1, topics.size());
    Topic topic = topics.get(0);
    assertEquals("stream events", topic.getName());
    assertTrue(topic.getMaxId() > 0);
}
Also used : Topic(com.github.jamesnetherton.zulip.client.api.stream.Topic) Test(org.junit.jupiter.api.Test)

Example 2 with Topic

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

the class ZulipStreamIT method deleteStreamTopic.

@Test
public void deleteStreamTopic() throws ZulipClientException {
    // Create stream & topic
    zulip.streams().subscribe(StreamSubscriptionRequest.of("Test Stream For Topic", "Test Stream For Topic")).withAuthorizationErrorsFatal(false).withHistoryPublicToSubscribers(true).withInviteOnly(false).withMessageRetention(RetentionPolicy.FOREVER).withStreamPostPolicy(StreamPostPolicy.ANY).execute();
    Long streamId = zulip.streams().getStreamId("Test Stream For Topic").execute();
    List<Topic> topics = zulip.streams().getTopics(streamId).execute();
    assertEquals(1, topics.size());
    Topic topic = topics.get(0);
    assertEquals("stream events", topic.getName());
    assertTrue(topic.getMaxId() > 0);
    // Delete topic
    zulip.streams().deleteTopic(streamId, topic.getName()).execute();
    // Verify deletion
    topics = zulip.streams().getTopics(streamId).execute();
    assertTrue(topics.isEmpty());
}
Also used : Topic(com.github.jamesnetherton.zulip.client.api.stream.Topic) Test(org.junit.jupiter.api.Test)

Aggregations

Topic (com.github.jamesnetherton.zulip.client.api.stream.Topic)2 Test (org.junit.jupiter.api.Test)2