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);
}
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());
}