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