From 3275c10913a2e14d6ee67414c5d7c74eeddd0f04 Mon Sep 17 00:00:00 2001 From: rubenlagus Date: Sat, 31 Oct 2020 17:43:32 +0000 Subject: [PATCH] More cleanup --- pom.xml | 2 +- .../abilitybots/api/util/AbilityUtils.java | 6 +- .../api/bot/AbilityBotI18nTest.java | 4 +- .../abilitybots/api/bot/AbilityBotTest.java | 3 +- .../api/bot/ContinuousTextTest.java | 2 +- .../abilitybots/api/bot/TestUtils.java | 4 +- .../commands/CommandRegistryTest.java | 9 - telegrambots-meta/pom.xml | 5 +- .../meta/api/methods/BotApiMethod.java | 2 - .../telegrambots/meta/api/objects/Chat.java | 93 +----- .../meta/api/objects/Location.java | 6 +- .../meta/api/objects/Message.java | 293 +++--------------- .../telegrambots/meta/api/objects/User.java | 100 +----- .../meta/api/objects/games/Animation.java | 10 + .../meta/api/objects/games/Game.java | 8 + .../meta/api/objects/games/GameHighScore.java | 6 + .../inlinequery/ChosenInlineQuery.java | 8 + .../api/objects/inlinequery/InlineQuery.java | 9 + .../InputContactMessageContent.java | 2 + .../InputLocationMessageContent.java | 2 + .../InputTextMessageContent.java | 2 + .../InputVenueMessageContent.java | 2 + .../result/InlineQueryResultPhoto.java | 148 +-------- .../meta/test/TestDeserialization.java | 5 +- .../test/BotApiMethodHelperFactory.java | 103 +++--- .../telegrambots/test/TestRestApi.java | 88 ++++-- 26 files changed, 273 insertions(+), 649 deletions(-) diff --git a/pom.xml b/pom.xml index 68db8f58..7899d19a 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ ${java.version} ${java.version} - 5.5.2 + 5.6.2 3.1.0 3.1.0 2.10.1 diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java index b38f5ab0..02db0f9a 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java @@ -25,7 +25,7 @@ import static org.telegram.abilitybots.api.objects.Flag.*; * Helper and utility methods */ public final class AbilityUtils { - public static User EMPTY_USER = new User(0, "", false, "", "", ""); + public static User EMPTY_USER = new User(0, "", false); private AbilityUtils() { @@ -37,7 +37,7 @@ public final class AbilityUtils { */ public static String stripTag(String username) { String lowerCase = username.toLowerCase(); - return lowerCase.startsWith("@") ? lowerCase.substring(1, lowerCase.length()) : lowerCase; + return lowerCase.startsWith("@") ? lowerCase.substring(1) : lowerCase; } /** @@ -252,7 +252,7 @@ public final class AbilityUtils { * The full name is identified as the concatenation of the first and last name, separated by a space. * This method can return an empty name if both first and last name are empty. * - * @param user + * @param user User to use * @return the full name of the user */ public static String fullName(User user) { diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotI18nTest.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotI18nTest.java index 5b320898..ada4147f 100644 --- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotI18nTest.java +++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotI18nTest.java @@ -19,8 +19,8 @@ import static org.telegram.abilitybots.api.bot.TestUtils.mockContext; import static org.telegram.abilitybots.api.db.MapDBContext.offlineInstance; class AbilityBotI18nTest { - private static final User NO_LANGUAGE_USER = new User(1, "first", false, "last", "username", null); - private static final User ITALIAN_USER = new User(2, "first", false, "last", "username", "it-IT"); + private static final User NO_LANGUAGE_USER = new User(1, "first", false, "last", "username", null, false, false, false); + private static final User ITALIAN_USER = new User(2, "first", false, "last", "username", "it-IT", false, false, false); private DBContext db; private NoPublicCommandsBot bot; diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java index 2e407cc3..c69daef3 100644 --- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java +++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java @@ -351,7 +351,7 @@ public class AbilityBotTest { String newFirstName = USER.getFirstName() + "-test"; String newLastName = USER.getLastName() + "-test"; int sameId = USER.getId(); - User changedUser = new User(sameId, newFirstName, false, newLastName, newUsername, null); + User changedUser = new User(sameId, newFirstName, false, newLastName, newUsername, "en", false, false, false); mockAlternateUser(update, message, changedUser); @@ -515,6 +515,7 @@ public class AbilityBotTest { assertTrue(bot.checkGlobalFlags(update), "Unexpected result when checking for the default global flags"); } + @SuppressWarnings({"NumericOverflow", "divzero"}) @Test void canConsumeUpdate() { Ability ability = getDefaultBuilder() diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/ContinuousTextTest.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/ContinuousTextTest.java index a2e5b18f..2604a2ba 100644 --- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/ContinuousTextTest.java +++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/ContinuousTextTest.java @@ -22,7 +22,7 @@ import static org.telegram.abilitybots.api.objects.Locality.ALL; import static org.telegram.abilitybots.api.objects.Privacy.PUBLIC; public class ContinuousTextTest { - private static final User USER = new User(1, "first", false, "last", "username", null); + private static final User USER = new User(1, "first", false); private DBContext db; diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/TestUtils.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/TestUtils.java index bf1c3479..5e85b66b 100644 --- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/TestUtils.java +++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/TestUtils.java @@ -11,8 +11,8 @@ import static org.mockito.Mockito.when; import static org.telegram.abilitybots.api.objects.MessageContext.newContext; public final class TestUtils { - public static final User USER = new User(1, "first", false, "last", "username", null); - public static final User CREATOR = new User(1337, "creatorFirst", false, "creatorLast", "creatorUsername", null); + public static final User USER = new User(1, "first", false, "last", "username", null, false, false, false); + public static final User CREATOR = new User(1337, "creatorFirst", false, "creatorLast", "creatorUsername", null, false, false, false); private TestUtils() { diff --git a/telegrambots-extensions/src/test/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/CommandRegistryTest.java b/telegrambots-extensions/src/test/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/CommandRegistryTest.java index 9b847418..232ea85b 100644 --- a/telegrambots-extensions/src/test/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/CommandRegistryTest.java +++ b/telegrambots-extensions/src/test/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/CommandRegistryTest.java @@ -8,15 +8,6 @@ import org.telegram.telegrambots.meta.bots.AbsSender; class CommandRegistryTest { - @Test - void should_create_registry() { - CommandRegistry registry = new CommandRegistry(true, () -> "BotUsername"); - Assertions.assertNotNull(registry, "CommandRegistry is not created"); - NullPointerException exception = Assertions.assertThrows(NullPointerException.class, - () -> new CommandRegistry(true, () -> "BotUsername")); - Assertions.assertEquals("Bot username must not be null", exception.getMessage(), "Invalid exception message"); - } - @Test void should_executes_commandWithBotUsername() { CommandRegistry registry = new CommandRegistry(true, () -> "BotUsername"); diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 24c60519..7d3ffc4e 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -69,11 +69,11 @@ UTF-8 UTF-8 - 4.2.2 + 4.2.3 2.10.1 2.10.1 20180813 - 28.1-jre + 30.0-jre @@ -119,6 +119,7 @@ lombok provided + diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/BotApiMethod.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/BotApiMethod.java index 6d4cc32f..620f7bf2 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/BotApiMethod.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/BotApiMethod.java @@ -3,7 +3,6 @@ package org.telegram.telegrambots.meta.api.methods; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; import java.io.Serializable; @@ -15,7 +14,6 @@ import java.io.Serializable; */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) -@Data public abstract class BotApiMethod extends PartialBotApiMethod { protected static final String METHOD_FIELD = "method"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java index 266c5692..a02a06bc 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java @@ -1,6 +1,12 @@ package org.telegram.telegrambots.meta.api.objects; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -9,6 +15,10 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; * This object represents a Telegram chat with an user or a group */ @SuppressWarnings("WeakerAccess") +@Data +@RequiredArgsConstructor +@NoArgsConstructor +@AllArgsConstructor public class Chat implements BotApiObject { private static final String ID_FIELD = "id"; @@ -39,8 +49,10 @@ public class Chat implements BotApiObject { * so a signed 64 bit integer or double-precision float type are safe for storing this identifier. */ @JsonProperty(ID_FIELD) + @NonNull private Long id; ///< Unique identifier for this chat, not exceeding 1e13 by absolute value @JsonProperty(TYPE_FIELD) + @NonNull private String type; ///< Type of the chat, one of “private”, “group” or “channel” @JsonProperty(TITLE_FIELD) private String title; ///< Optional. Title of the chat, only for channels and group chat @@ -83,96 +95,23 @@ public class Chat implements BotApiObject { @JsonProperty(SLOWMODEDELAY_FIELD) private Integer slowModeDelay; - public Chat() { - super(); - } - - public Long getId() { - return id; - } - + @JsonIgnore public Boolean isGroupChat() { return GROUPCHATTYPE.equals(type); } + @JsonIgnore public Boolean isChannelChat() { return CHANNELCHATTYPE.equals(type); } + @JsonIgnore public Boolean isUserChat() { return USERCHATTYPE.equals(type); } + @JsonIgnore public Boolean isSuperGroupChat() { return SUPERGROUPCHATTYPE.equals(type); } - - public String getTitle() { - return title; - } - - public String getFirstName() { - return firstName; - } - - public String getLastName() { - return lastName; - } - - public String getUserName() { - return userName; - } - - public ChatPermissions getPermissions() { - return permissions; - } - - public ChatPhoto getPhoto() { - return photo; - } - - public String getDescription() { - return description; - } - - public String getInviteLink() { - return inviteLink; - } - - public Message getPinnedMessage() { - return pinnedMessage; - } - - public String getStickerSetName() { - return stickerSetName; - } - - public Boolean getCanSetStickerSet() { - return canSetStickerSet; - } - - public Integer getSlowModeDelay() { - return slowModeDelay; - } - - @Override - public String toString() { - return "Chat{" + - "id=" + id + - ", type='" + type + '\'' + - ", title='" + title + '\'' + - ", firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - ", userName='" + userName + '\'' + - ", allMembersAreAdministrators=" + allMembersAreAdministrators + - ", photo=" + photo + - ", description='" + description + '\'' + - ", inviteLink='" + inviteLink + '\'' + - ", pinnedMessage=" + pinnedMessage + - ", stickerSetName='" + stickerSetName + '\'' + - ", canSetStickerSet=" + canSetStickerSet + - ", permissions=" + permissions + - ", slowModeDelay=" + slowModeDelay + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Location.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Location.java index d21a07c3..6dac47db 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Location.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Location.java @@ -1,10 +1,10 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -13,15 +13,17 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; * This object represents a point on the map. */ @Data -@NoArgsConstructor @AllArgsConstructor +@NoArgsConstructor public class Location implements BotApiObject { private static final String LONGITUDE_FIELD = "longitude"; private static final String LATITUDE_FIELD = "latitude"; @JsonProperty(LONGITUDE_FIELD) + @NonNull private Double longitude; ///< Longitude as defined by sender @JsonProperty(LATITUDE_FIELD) + @NonNull private Double latitude; ///< Latitude as defined by sender } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java index b0723615..8db7b7cb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java @@ -1,6 +1,12 @@ package org.telegram.telegrambots.meta.api.objects; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.games.Animation; import org.telegram.telegrambots.meta.api.objects.games.Game; @@ -19,6 +25,10 @@ import java.util.List; * @version 1.0 * This object represents a message. */ +@Data +@RequiredArgsConstructor +@NoArgsConstructor +@AllArgsConstructor public class Message implements BotApiObject { private static final String MESSAGEID_FIELD = "message_id"; private static final String FROM_FIELD = "from"; @@ -71,12 +81,15 @@ public class Message implements BotApiObject { private static final String VIABOT_FIELD = "via_bot"; @JsonProperty(MESSAGEID_FIELD) + @NonNull private Integer messageId; ///< Integer Unique message identifier @JsonProperty(FROM_FIELD) private User from; ///< Optional. Sender, can be empty for messages sent to channels @JsonProperty(DATE_FIELD) - private Integer date; ///< Optional. Date the message was sent in Unix time + @NonNull + private Integer date; ///< ODate the message was sent in Unix time @JsonProperty(CHAT_FIELD) + @NonNull private Chat chat; ///< Conversation the message belongs to @JsonProperty(FORWARDFROM_FIELD) private User forwardFrom; ///< Optional. For forwarded messages, sender of the original message @@ -213,37 +226,6 @@ public class Message implements BotApiObject { private Dice dice; // Optional. Message is a dice with random value from 1 to 6 @JsonProperty(VIABOT_FIELD) private User viaBot; // Optional. Bot through which the message was sent - public Message() { - super(); - } - - public Integer getMessageId() { - return messageId; - } - - public User getFrom() { - return from; - } - - public Integer getDate() { - return date; - } - - public Chat getChat() { - return chat; - } - - public User getForwardFrom() { - return forwardFrom; - } - - public Integer getForwardDate() { - return forwardDate; - } - - public String getText() { - return text; - } public List getEntities() { if (entities != null) { @@ -259,130 +241,47 @@ public class Message implements BotApiObject { return captionEntities; } - public Audio getAudio() { - return audio; - } - - public Document getDocument() { - return document; - } - - public List getPhoto() { - return photo; - } - - public Sticker getSticker() { - return sticker; - } - - public boolean hasSticker() { - return sticker != null; - } - - public Video getVideo() { - return video; - } - - public Animation getAnimation() { - return animation; - } - - public Contact getContact() { - return contact; - } - - public Location getLocation() { - return location; - } - - public Venue getVenue() { - return venue; - } - - public Message getPinnedMessage() { - return pinnedMessage; - } - + @JsonIgnore public List getNewChatMembers() { return newChatMembers == null ? new ArrayList<>() : newChatMembers; } - public User getLeftChatMember() { - return leftChatMember; - } - - public String getNewChatTitle() { - return newChatTitle; - } - - public List getNewChatPhoto() { - return newChatPhoto; - } - - public Boolean getDeleteChatPhoto() { - return deleteChatPhoto; - } - - public Boolean getGroupchatCreated() { - return groupchatCreated; - } - - public Message getReplyToMessage() { - return replyToMessage; - } - - public Voice getVoice() { - return voice; - } - - public String getCaption() { - return caption; - } - - public Boolean getSuperGroupCreated() { - return superGroupCreated; - } - - public Boolean getChannelChatCreated() { - return channelChatCreated; - } - - public Long getMigrateToChatId() { - return migrateToChatId; - } - - public Long getMigrateFromChatId() { - return migrateFromChatId; - } - - public Integer getForwardFromMessageId() { - return forwardFromMessageId; + @JsonIgnore + public boolean hasSticker() { + return sticker != null; } + @JsonIgnore public boolean isGroupMessage() { return chat.isGroupChat(); } + @JsonIgnore public boolean isUserMessage() { return chat.isUserChat(); } + @JsonIgnore public boolean isChannelMessage() { return chat.isChannelChat(); } + @JsonIgnore public boolean isSuperGroupMessage() { return chat.isSuperGroupChat(); } + @JsonIgnore public Long getChatId() { return chat.getId(); } + @JsonIgnore public boolean hasText() { return text != null && !text.isEmpty(); } + @JsonIgnore public boolean isCommand() { if (hasText() && entities != null) { for (MessageEntity entity : entities) { @@ -395,202 +294,98 @@ public class Message implements BotApiObject { return false; } + @JsonIgnore public boolean hasDocument() { return this.document != null; } + @JsonIgnore public boolean hasVideo() { return this.video != null; } + @JsonIgnore public boolean hasAudio(){ return this.audio != null; } + @JsonIgnore public boolean hasVoice(){ return this.voice != null; } + @JsonIgnore public boolean isReply() { return this.replyToMessage != null; } + @JsonIgnore public boolean hasLocation() { return location != null; } - public Chat getForwardFromChat() { - return forwardFromChat; - } - - public Integer getEditDate() { - return editDate; - } - - public Game getGame() { - return game; - } - + @JsonIgnore private boolean hasGame() { return game != null; } + @JsonIgnore public boolean hasEntities() { return entities != null && !entities.isEmpty(); } + @JsonIgnore public boolean hasPhoto() { return photo != null && !photo.isEmpty(); } + @JsonIgnore public boolean hasInvoice() { return invoice != null; } + @JsonIgnore public boolean hasSuccessfulPayment() { return successfulPayment != null; } + @JsonIgnore public boolean hasContact() { return contact != null; } - public Invoice getInvoice() { - return invoice; - } - - public SuccessfulPayment getSuccessfulPayment() { - return successfulPayment; - } - - public VideoNote getVideoNote() { - return videoNote; - } - + @JsonIgnore public boolean hasVideoNote() { return videoNote != null; } - public String getAuthorSignature() { - return authorSignature; - } - - public String getForwardSignature() { - return forwardSignature; - } - - public String getMediaGroupId() { - return mediaGroupId; - } - - public String getConnectedWebsite() { - return connectedWebsite; - } - - public PassportData getPassportData() { - return passportData; - } - + @JsonIgnore public boolean hasPassportData() { return passportData != null; } + @JsonIgnore public boolean hasAnimation() { return animation != null; } - public String getForwardSenderName() { - return forwardSenderName; - } - - public void setForwardSenderName(String forwardSenderName) { - this.forwardSenderName = forwardSenderName; - } - + @JsonIgnore public boolean hasPoll() { return poll != null; } - public Poll getPoll() { - return poll; - } - - public Dice getDice() { - return dice; - } - + @JsonIgnore public boolean hasDice() { return dice != null; } - public User getViaBot() { - return viaBot; - } - + @JsonIgnore public boolean hasViaBot() { return viaBot != null; } + @JsonIgnore public boolean hasReplyMarkup() { return replyMarkup != null; } - - public InlineKeyboardMarkup getReplyMarkup() { - return replyMarkup; - } - - @Override - public String toString() { - return "Message{" + - "messageId=" + messageId + - ", from=" + from + - ", date=" + date + - ", chat=" + chat + - ", forwardFrom=" + forwardFrom + - ", forwardFromChat=" + forwardFromChat + - ", forwardDate=" + forwardDate + - ", text='" + text + '\'' + - ", entities=" + entities + - ", captionEntities=" + captionEntities + - ", audio=" + audio + - ", document=" + document + - ", photo=" + photo + - ", sticker=" + sticker + - ", video=" + video + - ", contact=" + contact + - ", location=" + location + - ", venue=" + venue + - ", animation=" + animation + - ", pinnedMessage=" + pinnedMessage + - ", newChatMembers=" + newChatMembers + - ", leftChatMember=" + leftChatMember + - ", newChatTitle='" + newChatTitle + '\'' + - ", newChatPhoto=" + newChatPhoto + - ", deleteChatPhoto=" + deleteChatPhoto + - ", groupchatCreated=" + groupchatCreated + - ", replyToMessage=" + replyToMessage + - ", voice=" + voice + - ", caption='" + caption + '\'' + - ", superGroupCreated=" + superGroupCreated + - ", channelChatCreated=" + channelChatCreated + - ", migrateToChatId=" + migrateToChatId + - ", migrateFromChatId=" + migrateFromChatId + - ", editDate=" + editDate + - ", game=" + game + - ", forwardFromMessageId=" + forwardFromMessageId + - ", invoice=" + invoice + - ", successfulPayment=" + successfulPayment + - ", videoNote=" + videoNote + - ", authorSignature='" + authorSignature + '\'' + - ", forwardSignature='" + forwardSignature + '\'' + - ", mediaGroupId='" + mediaGroupId + '\'' + - ", connectedWebsite='" + connectedWebsite + '\'' + - ", passportData=" + passportData + - ", forwardSenderName='" + forwardSenderName + '\'' + - ", poll=" + poll + - ", replyMarkup=" + replyMarkup + - ", dice=" + dice + - ", viaBot=" + viaBot + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java index 8bc2582c..32501eae 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java @@ -1,15 +1,22 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; -import java.util.Objects; - /** * @author Ruben Bermudez * @version 3.0 * This object represents a Telegram user or bot. */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@RequiredArgsConstructor public class User implements BotApiObject { private static final String ID_FIELD = "id"; @@ -23,10 +30,13 @@ public class User implements BotApiObject { private static final String SUPPORTINLINEQUERIES_FIELD = "supports_inline_queries"; @JsonProperty(ID_FIELD) + @NonNull private Integer id; ///< Unique identifier for this user or bot @JsonProperty(FIRSTNAME_FIELD) + @NonNull private String firstName; ///< User‘s or bot’s first name @JsonProperty(ISBOT_FIELD) + @NonNull private Boolean isBot; ///< True, if this user is a bot @JsonProperty(LASTNAME_FIELD) private String lastName; ///< Optional. User‘s or bot’s last name @@ -40,90 +50,4 @@ public class User implements BotApiObject { private Boolean canReadAllGroupMessages; ///< Optional. True, if privacy mode is disabled for the bot. Returned only in getMe. @JsonProperty(SUPPORTINLINEQUERIES_FIELD) private Boolean supportInlineQueries; ///< Optional. True, if the bot supports inline queries. Returned only in getMe. - - public User() { - super(); - } - - public User(Integer id, String firstName, Boolean isBot, String lastName, String userName, String languageCode) { - this.id = id; - this.firstName = firstName; - this.isBot = isBot; - this.lastName = lastName; - this.userName = userName; - this.languageCode = languageCode; - } - - public Integer getId() { - return id; - } - - public String getFirstName() { - return firstName; - } - - public String getLastName() { - return lastName; - } - - public String getUserName() { - return userName; - } - - public String getLanguageCode() { - return languageCode; - } - - public Boolean getBot() { - return isBot; - } - - public Boolean getCanJoinGroups() { - return canJoinGroups; - } - - public Boolean getCanReadAllGroupMessages() { - return canReadAllGroupMessages; - } - - public Boolean getSupportInlineQueries() { - return supportInlineQueries; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - User user = (User) o; - return Objects.equals(id, user.id) && - Objects.equals(firstName, user.firstName) && - Objects.equals(isBot, user.isBot) && - Objects.equals(lastName, user.lastName) && - Objects.equals(userName, user.userName) && - Objects.equals(languageCode, user.languageCode) && - Objects.equals(canJoinGroups, user.canJoinGroups) && - Objects.equals(canReadAllGroupMessages, user.canReadAllGroupMessages) && - Objects.equals(supportInlineQueries, user.supportInlineQueries); - } - - @Override - public int hashCode() { - return Objects.hash(id, firstName, isBot, lastName, userName, languageCode, - canJoinGroups, canReadAllGroupMessages, supportInlineQueries); - } - - @Override - public String toString() { - return "User{" + - "id=" + id + - ", firstName='" + firstName + '\'' + - ", isBot=" + isBot + - ", lastName='" + lastName + '\'' + - ", userName='" + userName + '\'' + - ", languageCode='" + languageCode + '\'' + - ", canJoinGroups=" + canJoinGroups + - ", canReadAllGroupMessages=" + canReadAllGroupMessages + - ", supportInlineQueries=" + supportInlineQueries + - '}'; - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java index d1279e21..6fd19f03 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java @@ -17,8 +17,11 @@ package org.telegram.telegrambots.meta.api.objects.games; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.PhotoSize; @@ -28,7 +31,9 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize; * This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). */ @Data +@RequiredArgsConstructor @NoArgsConstructor +@AllArgsConstructor public class Animation implements BotApiObject { private static final String FILEID_FIELD = "file_id"; private static final String FILEUNIQUEID_FIELD = "file_unique_id"; @@ -41,18 +46,23 @@ public class Animation implements BotApiObject { private static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILEID_FIELD) + @NonNull private String fileId; ///< Identifier for this file, which can be used to download or reuse the file /** * Unique identifier for this file, which is supposed to be the same over time and for different bots. * Can't be used to download or reuse the file. */ @JsonProperty(FILEUNIQUEID_FIELD) + @NonNull private String fileUniqueId; @JsonProperty(WIDTH_FIELD) + @NonNull private Integer width; ///< Video width as defined by sender @JsonProperty(HEIGHT_FIELD) + @NonNull private Integer height; ///< Video height as defined by sender @JsonProperty(DURATION_FIELD) + @NonNull private Integer duration; ///< Duration of the video in seconds as defined by sender @JsonProperty(THUMB_FIELD) private PhotoSize thumb; ///< Optional. Animation thumbnail as defined by sender diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java index 2be56adb..8ddbfd3e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java @@ -17,8 +17,11 @@ package org.telegram.telegrambots.meta.api.objects.games; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.MessageEntity; import org.telegram.telegrambots.meta.api.objects.PhotoSize; @@ -32,7 +35,9 @@ import java.util.List; * @apiNote Use BotFather to create and edit games, their short names will act as unique identifiers. */ @Data +@RequiredArgsConstructor @NoArgsConstructor +@AllArgsConstructor public class Game implements BotApiObject { private static final String TITLE_FIELD = "title"; @@ -43,10 +48,13 @@ public class Game implements BotApiObject { private static final String TEXTENTITIES_FIELD = "text_entities"; @JsonProperty(TITLE_FIELD) + @NonNull private String title; ///< Title of the game @JsonProperty(DESCRIPTION_FIELD) + @NonNull private String description; ///< Description of the game @JsonProperty(PHOTO_FIELD) + @NonNull private List photo; ///< Photo /** * Optional. Brief description of the game or high scores included in the game message. diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java index 379fd281..86bf27a8 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java @@ -18,8 +18,10 @@ package org.telegram.telegrambots.meta.api.objects.games; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.User; @@ -30,15 +32,19 @@ import org.telegram.telegrambots.meta.api.objects.User; */ @Data @NoArgsConstructor +@AllArgsConstructor public class GameHighScore implements BotApiObject { private static final String POSITION_FIELD = "position"; private static final String USER_FIELD = "user"; private static final String SCORE_FIELD = "score"; @JsonProperty(POSITION_FIELD) + @NonNull private Integer position; ///< Position in the game high score table @JsonProperty(USER_FIELD) + @NonNull private User user; ///< User @JsonProperty(SCORE_FIELD) + @NonNull private Integer score; ///< Score } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java index bd1114eb..09d11e69 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java @@ -2,9 +2,12 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.Location; import org.telegram.telegrambots.meta.api.objects.User; @@ -16,7 +19,9 @@ import org.telegram.telegrambots.meta.api.objects.User; * partner. */ @Data +@RequiredArgsConstructor @NoArgsConstructor +@AllArgsConstructor @Builder public class ChosenInlineQuery implements BotApiObject { private static final String RESULTID_FIELD = "result_id"; @@ -26,8 +31,10 @@ public class ChosenInlineQuery implements BotApiObject { private static final String QUERY_FIELD = "query"; @JsonProperty(RESULTID_FIELD) + @NonNull private String resultId; ///< The unique identifier for the result that was chosen. @JsonProperty(FROM_FIELD) + @NonNull private User from; ///< The user that chose the result. @JsonProperty(LOCATION_FIELD) private Location location; ///< Optional. Sender location, only for bots that require user location @@ -40,5 +47,6 @@ public class ChosenInlineQuery implements BotApiObject { @JsonProperty(INLINE_MESSAGE_ID_FIELD) private String inlineMessageId; @JsonProperty(QUERY_FIELD) + @NonNull private String query; ///< The query that was used to obtain the result. } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java index b41039a4..4049e4f9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java @@ -2,9 +2,12 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.Location; import org.telegram.telegrambots.meta.api.objects.User; @@ -16,7 +19,9 @@ import org.telegram.telegrambots.meta.api.objects.User; * bot could return some default or trending results. */ @Data +@RequiredArgsConstructor @NoArgsConstructor +@AllArgsConstructor @Builder public class InlineQuery implements BotApiObject { private static final String ID_FIELD = "id"; @@ -26,14 +31,18 @@ public class InlineQuery implements BotApiObject { private static final String OFFSET_FIELD = "offset"; @JsonProperty(ID_FIELD) + @NonNull private String id; ///< Unique identifier for this query @JsonProperty(FROM_FIELD) + @NonNull private User from; ///< Sender @JsonProperty(LOCATION_FIELD) private Location location; ///< Optional. Sender location, only for bots that request user location @JsonProperty(QUERY_FIELD) + @NonNull private String query; ///< Text of the query @JsonProperty(OFFSET_FIELD) + @NonNull private String offset; ///< Offset of the results to be returned, can be controlled by the bot } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java index 28309713..2cdc30a4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java @@ -7,6 +7,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** @@ -18,6 +19,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; */ @JsonDeserialize @Data +@RequiredArgsConstructor @NoArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java index a60d3949..66656f0c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java @@ -7,6 +7,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** @@ -18,6 +19,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; */ @JsonDeserialize @Data +@RequiredArgsConstructor @NoArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java index 0f529854..3c86b2c7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java @@ -7,6 +7,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** @@ -16,6 +17,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; */ @JsonDeserialize @Data +@RequiredArgsConstructor @NoArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java index 68b0f945..58d6a312 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java @@ -8,6 +8,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** @@ -19,6 +20,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; */ @JsonDeserialize @Data +@RequiredArgsConstructor @NoArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultPhoto.java index 5b3c78c4..81827796 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultPhoto.java @@ -3,6 +3,12 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery.result; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent; import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @@ -15,6 +21,11 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; * specified content instead of the photo. */ @JsonDeserialize +@Data +@RequiredArgsConstructor +@NoArgsConstructor +@AllArgsConstructor +@Builder public class InlineQueryResultPhoto implements InlineQueryResult { private static final String TYPE_FIELD = "type"; private static final String ID_FIELD = "id"; @@ -33,8 +44,10 @@ public class InlineQueryResultPhoto implements InlineQueryResult { @JsonProperty(TYPE_FIELD) private final String type = "photo"; ///< Type of the result, must be “photo” @JsonProperty(ID_FIELD) + @NonNull private String id; ///< Unique identifier of this result, 1-64 bytes @JsonProperty(PHOTOURL_FIELD) + @NonNull private String photoUrl; ///< A valid URL of the photo. Photo size must not exceed 5MB @JsonProperty(MIMETYPE_FIELD) private String mimeType; ///< Optional. MIME type of the photo, defaults to image/jpeg @@ -57,122 +70,6 @@ public class InlineQueryResultPhoto implements InlineQueryResult { @JsonProperty(PARSEMODE_FIELD) private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - public InlineQueryResultPhoto() { - super(); - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public InlineQueryResultPhoto setId(String id) { - this.id = id; - return this; - } - - public String getPhotoUrl() { - return photoUrl; - } - - public InlineQueryResultPhoto setPhotoUrl(String photoUrl) { - this.photoUrl = photoUrl; - return this; - } - - public String getMimeType() { - return mimeType; - } - - public InlineQueryResultPhoto setMimeType(String mimeType) { - this.mimeType = mimeType; - return this; - } - - public Integer getPhotoWidth() { - return photoWidth; - } - - public InlineQueryResultPhoto setPhotoWidth(Integer photoWidth) { - this.photoWidth = photoWidth; - return this; - } - - public Integer getPhotoHeight() { - return photoHeight; - } - - public InlineQueryResultPhoto setPhotoHeight(Integer photoHeight) { - this.photoHeight = photoHeight; - return this; - } - - public String getThumbUrl() { - return thumbUrl; - } - - public InlineQueryResultPhoto setThumbUrl(String thumbUrl) { - this.thumbUrl = thumbUrl; - return this; - } - - public String getTitle() { - return title; - } - - public InlineQueryResultPhoto setTitle(String title) { - this.title = title; - return this; - } - - public String getDescription() { - return description; - } - - public InlineQueryResultPhoto setDescription(String description) { - this.description = description; - return this; - } - - public String getCaption() { - return caption; - } - - public InlineQueryResultPhoto setCaption(String caption) { - this.caption = caption; - return this; - } - - public InputMessageContent getInputMessageContent() { - return inputMessageContent; - } - - public InlineQueryResultPhoto setInputMessageContent(InputMessageContent inputMessageContent) { - this.inputMessageContent = inputMessageContent; - return this; - } - - public InlineKeyboardMarkup getReplyMarkup() { - return replyMarkup; - } - - public InlineQueryResultPhoto setReplyMarkup(InlineKeyboardMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - return this; - } - - public String getParseMode() { - return parseMode; - } - - public InlineQueryResultPhoto setParseMode(String parseMode) { - this.parseMode = parseMode; - return this; - } - @Override public void validate() throws TelegramApiValidationException { if (id == null || id.isEmpty()) { @@ -188,23 +85,4 @@ public class InlineQueryResultPhoto implements InlineQueryResult { replyMarkup.validate(); } } - - @Override - public String toString() { - return "InlineQueryResultPhoto{" + - "type='" + type + '\'' + - ", id='" + id + '\'' + - ", photoUrl='" + photoUrl + '\'' + - ", mimeType='" + mimeType + '\'' + - ", photoWidth=" + photoWidth + - ", photoHeight=" + photoHeight + - ", thumbUrl='" + thumbUrl + '\'' + - ", title='" + title + '\'' + - ", description='" + description + '\'' + - ", caption='" + caption + '\'' + - ", inputMessageContent=" + inputMessageContent + - ", replyMarkup=" + replyMarkup + - ", parseMode='" + parseMode + '\'' + - '}'; - } } diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java index 02893c15..9f9a3c6f 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java @@ -2,7 +2,6 @@ package org.telegram.telegrambots.meta.test; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.telegram.telegrambots.meta.api.objects.ApiResponse; @@ -183,8 +182,8 @@ class TestDeserialization { assertEquals("offset", inlineQuery.getOffset()); assertFromUser(inlineQuery.getFrom()); assertNotNull(inlineQuery.getLocation()); - assertEquals(Float.valueOf("0.234242534"), inlineQuery.getLocation().getLatitude()); - assertEquals(Float.valueOf("0.234242534"), inlineQuery.getLocation().getLongitude()); + assertEquals(0.234242534, inlineQuery.getLocation().getLatitude()); + assertEquals(0.234242534, inlineQuery.getLocation().getLongitude()); } private void assertCallbackQuery(CallbackQuery callbackQuery) { diff --git a/telegrambots/src/test/java/org/telegram/telegrambots/test/BotApiMethodHelperFactory.java b/telegrambots/src/test/java/org/telegram/telegrambots/test/BotApiMethodHelperFactory.java index 2b43acaa..9ac70c3f 100644 --- a/telegrambots/src/test/java/org/telegram/telegrambots/test/BotApiMethodHelperFactory.java +++ b/telegrambots/src/test/java/org/telegram/telegrambots/test/BotApiMethodHelperFactory.java @@ -18,11 +18,25 @@ import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMem import org.telegram.telegrambots.meta.api.methods.groupadministration.KickChatMember; import org.telegram.telegrambots.meta.api.methods.groupadministration.LeaveChat; import org.telegram.telegrambots.meta.api.methods.groupadministration.UnbanChatMember; -import org.telegram.telegrambots.meta.api.methods.send.*; +import org.telegram.telegrambots.meta.api.methods.send.SendChatAction; +import org.telegram.telegrambots.meta.api.methods.send.SendContact; +import org.telegram.telegrambots.meta.api.methods.send.SendGame; +import org.telegram.telegrambots.meta.api.methods.send.SendInvoice; +import org.telegram.telegrambots.meta.api.methods.send.SendLocation; +import org.telegram.telegrambots.meta.api.methods.send.SendMessage; +import org.telegram.telegrambots.meta.api.methods.send.SendVenue; import org.telegram.telegrambots.meta.api.methods.updates.GetWebhookInfo; import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageCaption; import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageReplyMarkup; import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageText; +import org.telegram.telegrambots.meta.api.objects.Chat; +import org.telegram.telegrambots.meta.api.objects.ChatMember; +import org.telegram.telegrambots.meta.api.objects.File; +import org.telegram.telegrambots.meta.api.objects.Message; +import org.telegram.telegrambots.meta.api.objects.User; +import org.telegram.telegrambots.meta.api.objects.UserProfilePhotos; +import org.telegram.telegrambots.meta.api.objects.WebhookInfo; +import org.telegram.telegrambots.meta.api.objects.games.GameHighScore; import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent; import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputTextMessageContent; import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult; @@ -37,6 +51,7 @@ import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.InlineKe import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.KeyboardButton; import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.KeyboardRow; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -48,7 +63,7 @@ public final class BotApiMethodHelperFactory { private BotApiMethodHelperFactory() { } - public static BotApiMethod getSendMessage() { + public static BotApiMethod getSendMessage() { return new SendMessage() .setChatId("@test") .setText("Hithere") @@ -57,14 +72,14 @@ public final class BotApiMethodHelperFactory { .setReplyMarkup(new ForceReplyKeyboard()); } - public static BotApiMethod getAnswerCallbackQuery() { + public static BotApiMethod getAnswerCallbackQuery() { return new AnswerCallbackQuery() .setCallbackQueryId("id") .setText("text") .setShowAlert(true); } - public static BotApiMethod getAnswerInlineQuery() { + public static BotApiMethod getAnswerInlineQuery() { return new AnswerInlineQuery() .setInlineQueryId("id") .setPersonal(true) @@ -75,7 +90,7 @@ public final class BotApiMethodHelperFactory { .setSwitchPmText("pmText"); } - public static BotApiMethod getEditMessageCaption() { + public static BotApiMethod getEditMessageCaption() { return new EditMessageCaption() .setChatId("ChatId") .setMessageId(1) @@ -84,7 +99,7 @@ public final class BotApiMethodHelperFactory { } - public static BotApiMethod getEditMessageText() { + public static BotApiMethod getEditMessageText() { return new EditMessageText() .setChatId("ChatId") .setMessageId(1) @@ -93,13 +108,13 @@ public final class BotApiMethodHelperFactory { .setReplyMarkup(getInlineKeyboardMarkup()); } - public static BotApiMethod getEditMessageReplyMarkup() { + public static BotApiMethod getEditMessageReplyMarkup() { return new EditMessageReplyMarkup() .setInlineMessageId("12345") .setReplyMarkup(getInlineKeyboardMarkup()); } - public static BotApiMethod getForwardMessage() { + public static BotApiMethod getForwardMessage() { return new ForwardMessage(54L, 123L, 55) .setFromChatId("From") .setChatId("To") @@ -107,72 +122,72 @@ public final class BotApiMethodHelperFactory { .disableNotification(); } - public static BotApiMethod getGetChat() { + public static BotApiMethod getGetChat() { return new GetChat() .setChatId("12345"); } - public static BotApiMethod getChatAdministrators() { + public static BotApiMethod> getChatAdministrators() { return new GetChatAdministrators() .setChatId("12345"); } - public static BotApiMethod getChatMember() { + public static BotApiMethod getChatMember() { return new GetChatMember() .setChatId("12345") .setUserId(98765); } - public static BotApiMethod getChatMembersCount() { + public static BotApiMethod getChatMembersCount() { return new GetChatMembersCount() .setChatId("12345"); } - public static BotApiMethod getGetFile() { + public static BotApiMethod getGetFile() { return new GetFile() .setFileId("FileId"); } - public static BotApiMethod getGetGameHighScores() { + public static BotApiMethod> getGetGameHighScores() { return new GetGameHighScores() .setChatId("12345") .setMessageId(67890) .setUserId(98765); } - public static BotApiMethod getGetMe() { + public static BotApiMethod getGetMe() { return new GetMe(); } - public static BotApiMethod getGetUserProfilePhotos() { + public static BotApiMethod getGetUserProfilePhotos() { return new GetUserProfilePhotos() .setUserId(98765) .setLimit(10) .setOffset(3); } - public static BotApiMethod getGetWebhookInfo() { + public static BotApiMethod getGetWebhookInfo() { return new GetWebhookInfo(); } - public static BotApiMethod getKickChatMember() { + public static BotApiMethod getKickChatMember() { return new KickChatMember() .setChatId("12345") .setUserId(98765); } - public static BotApiMethod getLeaveChat() { + public static BotApiMethod getLeaveChat() { return new LeaveChat() .setChatId("12345"); } - public static BotApiMethod getSendChatAction() { + public static BotApiMethod getSendChatAction() { return new SendChatAction() .setChatId("12345") .setAction(ActionType.RECORDVIDEO); } - public static BotApiMethod getSendContact() { + public static BotApiMethod getSendContact() { return new SendContact() .setChatId("12345") .setFirstName("First Name") @@ -213,24 +228,28 @@ public final class BotApiMethodHelperFactory { } private static InlineQueryResult getInlineQueryResultPhoto() { - return new InlineQueryResultPhoto() - .setId("1") - .setPhotoUrl("PhotoUrl") - .setPhotoWidth(10) - .setPhotoHeight(20) - .setMimeType("image/jpg") - .setThumbUrl("ThumbUrl") - .setTitle("Title") - .setDescription("Description") - .setCaption("Caption") - .setInputMessageContent(getInputMessageContent()) - .setReplyMarkup(getInlineKeyboardMarkup()); + return InlineQueryResultPhoto + .builder() + .id("1") + .photoUrl("PhotoUrl") + .photoWidth(10) + .photoHeight(20) + .mimeType("image/jpg") + .thumbUrl("ThumbUrl") + .title("Title") + .description("Description") + .caption("Caption") + .inputMessageContent(getInputMessageContent()) + .replyMarkup(getInlineKeyboardMarkup()) + .build(); } private static InputMessageContent getInputMessageContent() { - return new InputTextMessageContent() - .setMessageText("Text") - .setParseMode(ParseMode.MARKDOWN); + return InputTextMessageContent + .builder() + .messageText("Text") + .parseMode(ParseMode.MARKDOWN) + .build(); } private static InlineKeyboardMarkup getInlineKeyboardMarkup() { @@ -245,13 +264,13 @@ public final class BotApiMethodHelperFactory { .setKeyboard(keyboard); } - public static BotApiMethod getSendGame() { + public static BotApiMethod getSendGame() { return new SendGame() .setChatId("12345") .setGameShortName("MyGame"); } - public static BotApiMethod getSendLocation() { + public static BotApiMethod getSendLocation() { return new SendLocation() .setChatId("12345") .setLatitude(12.5F) @@ -259,7 +278,7 @@ public final class BotApiMethodHelperFactory { .setReplyToMessageId(53); } - public static BotApiMethod getSendVenue() { + public static BotApiMethod getSendVenue() { return new SendVenue() .setChatId("12345") .setLatitude(12.5F) @@ -270,7 +289,7 @@ public final class BotApiMethodHelperFactory { .setFoursquareId("FourId"); } - public static BotApiMethod getSetGameScore() { + public static BotApiMethod getSetGameScore() { return new SetGameScore() .setInlineMessageId("12345") .setDisableEditMessage(true) @@ -278,13 +297,13 @@ public final class BotApiMethodHelperFactory { .setUserId(98765); } - public static BotApiMethod getUnbanChatMember() { + public static BotApiMethod getUnbanChatMember() { return new UnbanChatMember() .setChatId("12345") .setUserId(98765); } - public static BotApiMethod getSendInvoice() { + public static BotApiMethod getSendInvoice() { List prices = new ArrayList<>(); prices.add(new LabeledPrice("LABEL", 1000)); diff --git a/telegrambots/src/test/java/org/telegram/telegrambots/test/TestRestApi.java b/telegrambots/src/test/java/org/telegram/telegrambots/test/TestRestApi.java index 26e18097..c1d43a92 100644 --- a/telegrambots/src/test/java/org/telegram/telegrambots/test/TestRestApi.java +++ b/telegrambots/src/test/java/org/telegram/telegrambots/test/TestRestApi.java @@ -7,16 +7,42 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.junit.Before; import org.junit.Test; -import org.telegram.telegrambots.meta.api.methods.*; +import org.telegram.telegrambots.meta.api.methods.AnswerCallbackQuery; +import org.telegram.telegrambots.meta.api.methods.AnswerInlineQuery; +import org.telegram.telegrambots.meta.api.methods.BotApiMethod; +import org.telegram.telegrambots.meta.api.methods.ForwardMessage; +import org.telegram.telegrambots.meta.api.methods.GetFile; +import org.telegram.telegrambots.meta.api.methods.GetMe; +import org.telegram.telegrambots.meta.api.methods.GetUserProfilePhotos; import org.telegram.telegrambots.meta.api.methods.games.GetGameHighScores; import org.telegram.telegrambots.meta.api.methods.games.SetGameScore; -import org.telegram.telegrambots.meta.api.methods.groupadministration.*; -import org.telegram.telegrambots.meta.api.methods.send.*; +import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChat; +import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatAdministrators; +import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMember; +import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMembersCount; +import org.telegram.telegrambots.meta.api.methods.groupadministration.KickChatMember; +import org.telegram.telegrambots.meta.api.methods.groupadministration.LeaveChat; +import org.telegram.telegrambots.meta.api.methods.groupadministration.UnbanChatMember; +import org.telegram.telegrambots.meta.api.methods.send.SendChatAction; +import org.telegram.telegrambots.meta.api.methods.send.SendContact; +import org.telegram.telegrambots.meta.api.methods.send.SendGame; +import org.telegram.telegrambots.meta.api.methods.send.SendInvoice; +import org.telegram.telegrambots.meta.api.methods.send.SendLocation; +import org.telegram.telegrambots.meta.api.methods.send.SendMessage; +import org.telegram.telegrambots.meta.api.methods.send.SendVenue; import org.telegram.telegrambots.meta.api.methods.updates.GetWebhookInfo; import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageCaption; import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageReplyMarkup; import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageText; +import org.telegram.telegrambots.meta.api.objects.Chat; +import org.telegram.telegrambots.meta.api.objects.ChatMember; +import org.telegram.telegrambots.meta.api.objects.File; +import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.api.objects.Update; +import org.telegram.telegrambots.meta.api.objects.User; +import org.telegram.telegrambots.meta.api.objects.UserProfilePhotos; +import org.telegram.telegrambots.meta.api.objects.WebhookInfo; +import org.telegram.telegrambots.meta.api.objects.games.GameHighScore; import org.telegram.telegrambots.test.Fakes.FakeWebhook; import org.telegram.telegrambots.updatesreceivers.RestApi; @@ -24,6 +50,8 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -55,7 +83,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendMessage()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, SendMessage.class); @@ -67,7 +95,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getAnswerCallbackQuery()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, AnswerCallbackQuery.class); @@ -80,7 +108,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getAnswerInlineQuery()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, AnswerInlineQuery.class); @@ -93,7 +121,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageCaption()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, EditMessageCaption.class); @@ -109,7 +137,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageReplyMarkup()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, EditMessageReplyMarkup.class); @@ -125,7 +153,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageText()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, EditMessageText.class); @@ -141,7 +169,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getForwardMessage()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, ForwardMessage.class); @@ -155,7 +183,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetChat()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetChat.class); @@ -168,7 +196,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatAdministrators()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod> result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetChatAdministrators.class); @@ -181,7 +209,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatMember()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetChatMember.class); @@ -194,7 +222,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatMembersCount()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetChatMembersCount.class); @@ -207,7 +235,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetFile()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetFile.class); @@ -220,7 +248,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetGameHighScores()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod> result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetGameHighScores.class); @@ -233,7 +261,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetMe()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetMe.class); @@ -246,7 +274,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetUserProfilePhotos()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetUserProfilePhotos.class); @@ -259,7 +287,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetWebhookInfo()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, GetWebhookInfo.class); @@ -272,7 +300,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getKickChatMember()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, KickChatMember.class); @@ -285,7 +313,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getLeaveChat()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, LeaveChat.class); @@ -298,7 +326,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendChatAction()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, SendChatAction.class); @@ -311,7 +339,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendContact()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, SendContact.class); @@ -324,7 +352,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendGame()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, SendGame.class); @@ -337,7 +365,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendLocation()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, SendLocation.class); @@ -350,7 +378,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendVenue()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, SendVenue.class); @@ -363,7 +391,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getSetGameScore()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, SetGameScore.class); @@ -376,7 +404,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getUnbanChatMember()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, UnbanChatMember.class); @@ -389,7 +417,7 @@ public class TestRestApi extends JerseyTest { webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendInvoice()); Entity entity = Entity.json(getUpdate()); - BotApiMethod result = + BotApiMethod result = target("callback/testbot") .request(MediaType.APPLICATION_JSON) .post(entity, SendInvoice.class); @@ -409,7 +437,7 @@ public class TestRestApi extends JerseyTest { } } - private String map(BotApiMethod method) { + private String map(BotApiMethod method) { ObjectMapper mapper = new ObjectMapper(); try { return mapper.writeValueAsString(method);