Search in sources :

Example 1 with CustomEmoji

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

the class GetAllEmojiApiRequest method execute.

/**
 * Executes the Zulip API request for getting all custom emoji.
 *
 * @return                      List of all custom {@link CustomEmoji}
 * @throws ZulipClientException if the request was not successful
 */
@Override
public List<CustomEmoji> execute() throws ZulipClientException {
    GetAllEmojiApiResponse response = client().get(REALM_EMOJI, getParams(), GetAllEmojiApiResponse.class);
    List<CustomEmoji> emojis = new ArrayList<>();
    Map<String, CustomEmoji> emojiMap = response.getEmoji();
    emojiMap.keySet().stream().map(emojiMap::get).forEach(emojis::add);
    return emojis;
}
Also used : CustomEmoji(com.github.jamesnetherton.zulip.client.api.server.CustomEmoji) GetAllEmojiApiResponse(com.github.jamesnetherton.zulip.client.api.server.response.GetAllEmojiApiResponse) ArrayList(java.util.ArrayList)

Example 2 with CustomEmoji

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

the class ZulipServerIT method emoji.

@Test
public void emoji() throws ZulipClientException {
    File file = new File("./src/test/resources/com/github/jamesnetherton/zulip/client/api/server/emoji/smile.png");
    String emojiName = UUID.randomUUID().toString().split("-")[0];
    zulip.server().uploadEmoji(emojiName, file).execute();
    List<CustomEmoji> emojis = zulip.server().getEmoji().execute();
    Optional<CustomEmoji> optional = emojis.stream().filter(e -> e.getName().equals(emojiName)).findFirst();
    assertTrue(optional.isPresent());
    CustomEmoji emoji = optional.get();
    assertEquals(emojiName, emoji.getName());
    assertTrue(emoji.getSourceUrl().endsWith(emoji.getId() + ".png"));
    assertTrue(emoji.getAuthorId() > 0);
    assertTrue(emoji.getId() > 0);
    assertFalse(emoji.isDeactivated());
}
Also used : CustomEmoji(com.github.jamesnetherton.zulip.client.api.server.CustomEmoji) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ZulipClientException(com.github.jamesnetherton.zulip.client.exception.ZulipClientException) CustomEmoji(com.github.jamesnetherton.zulip.client.api.server.CustomEmoji) ZulipIntegrationTestBase(com.github.jamesnetherton.zulip.client.api.integration.ZulipIntegrationTestBase) ProfileField(com.github.jamesnetherton.zulip.client.api.server.ProfileField) UUID(java.util.UUID) AuthenticationSettings(com.github.jamesnetherton.zulip.client.api.server.AuthenticationSettings) ServerSettings(com.github.jamesnetherton.zulip.client.api.server.ServerSettings) File(java.io.File) ArrayList(java.util.ArrayList) Linkifier(com.github.jamesnetherton.zulip.client.api.server.Linkifier) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test) List(java.util.List) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ProfileFieldType(com.github.jamesnetherton.zulip.client.api.server.ProfileFieldType) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Map(java.util.Map) Optional(java.util.Optional) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Collections(java.util.Collections) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

CustomEmoji (com.github.jamesnetherton.zulip.client.api.server.CustomEmoji)2 ArrayList (java.util.ArrayList)2 ZulipIntegrationTestBase (com.github.jamesnetherton.zulip.client.api.integration.ZulipIntegrationTestBase)1 AuthenticationSettings (com.github.jamesnetherton.zulip.client.api.server.AuthenticationSettings)1 Linkifier (com.github.jamesnetherton.zulip.client.api.server.Linkifier)1 ProfileField (com.github.jamesnetherton.zulip.client.api.server.ProfileField)1 ProfileFieldType (com.github.jamesnetherton.zulip.client.api.server.ProfileFieldType)1 ServerSettings (com.github.jamesnetherton.zulip.client.api.server.ServerSettings)1 GetAllEmojiApiResponse (com.github.jamesnetherton.zulip.client.api.server.response.GetAllEmojiApiResponse)1 ZulipClientException (com.github.jamesnetherton.zulip.client.exception.ZulipClientException)1 File (java.io.File)1 Collections (java.util.Collections)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)1