Search in sources :

Example 1 with Linkifier

use of com.github.jamesnetherton.zulip.client.api.server.Linkifier in project zulip-java-client by jamesnetherton.

the class ZulipServerIT method linkifierCrud.

@Test
public void linkifierCrud() throws ZulipClientException {
    // Create linikifier
    Long id = zulip.server().addLinkifier("#(?P<id>[0-9]+)", "https://github.com/zulip/zulip/issues/%(id)s").execute();
    assertTrue(id > 0);
    try {
        // Get linkifiers
        List<Linkifier> linkifiers = zulip.server().getLinkifiers().execute();
        assertEquals(1, linkifiers.size());
        Linkifier linkifier = linkifiers.get(0);
        assertEquals(id, linkifier.getId());
        assertEquals("#(?P<id>[0-9]+)", linkifier.getPattern());
        assertEquals("https://github.com/zulip/zulip/issues/%(id)s", linkifier.getUrlFormat());
        // Delete linkifiers
        zulip.server().deleteLinkifier(id).execute();
    } catch (Throwable t) {
        try {
            zulip.server().deleteLinkifier(id).execute();
        } catch (Throwable t2) {
        // Ignore
        }
        throw t;
    }
    List<Linkifier> linkifiers = zulip.server().getLinkifiers().execute();
    assertTrue(linkifiers.isEmpty());
}
Also used : Linkifier(com.github.jamesnetherton.zulip.client.api.server.Linkifier) Test(org.junit.jupiter.api.Test)

Aggregations

Linkifier (com.github.jamesnetherton.zulip.client.api.server.Linkifier)1 Test (org.junit.jupiter.api.Test)1