本文整理汇总了Java中javax.ws.rs.client.Entity.json方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.json方法的具体用法?Java Entity.json怎么用?Java Entity.json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.client.Entity
的用法示例。
在下文中一共展示了Entity.json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TestEditMessageCaption
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestEditMessageCaption() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageCaption());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, EditMessageCaption.class);
assertEquals("{\"chat_id\":\"ChatId\",\"message_id\":1,\"caption\":\"Caption\"," +
"\"reply_markup\":{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard" +
".InlineKeyboardMarkup\",\"inline_keyboard\":[[{\"@class\":\"org.telegram." +
"telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton\"," +
"\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"method\":" +
"\"editmessagecaption\"}", map(result));
}
示例2: TestEditMessageReplyMarkup
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestEditMessageReplyMarkup() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageReplyMarkup());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, EditMessageReplyMarkup.class);
assertEquals("{\"inline_message_id\":\"12345\",\"reply_markup\":{\"@class\":\"org" +
".telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup\"," +
"\"inline_keyboard\":[[{\"@class\":\"org.telegram.telegrambots.api.objects." +
"replykeyboard.buttons.InlineKeyboardButton\",\"text\":\"Button1\"," +
"\"callback_data\":\"Callback\"}]]},\"method\":\"editmessagereplymarkup\"}",
map(result));
}
示例3: TestEditMessageText
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestEditMessageText() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageText());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, EditMessageText.class);
assertEquals("{\"chat_id\":\"ChatId\",\"message_id\":1,\"text\":\"Text\"," +
"\"parse_mode\":\"Markdown\",\"reply_markup\":{\"@class\":\"org.telegram." +
"telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup\",\"" +
"inline_keyboard\":[[{\"@class\":\"org.telegram.telegrambots.api.objects." +
"replykeyboard.buttons.InlineKeyboardButton\",\"text\":\"Button1\",\"callback_data\"" +
":\"Callback\"}]]},\"method\":\"editmessagetext\"}", map(result));
}
示例4: TestSendInvoice
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestSendInvoice() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendInvoice());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, SendInvoice.class);
assertEquals("{\"chat_id\":12345,\"title\":\"Random title\",\"description\":\"Random description\"" +
",\"payload\":\"Random Payload\",\"provider_token\":\"Random provider token\",\"start_parameter\":" +
"\"STARTPARAM\",\"currency\":\"EUR\",\"prices\":[{\"@class\":" +
"\"org.telegram.telegrambots.api.objects.payments.LabeledPrice\",\"label\":\"LABEL\"," +
"\"amount\":1000}],\"method\":\"sendinvoice\"}", map(result));
}
示例5: TestSendMessage
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestSendMessage() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendMessage());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, SendMessage.class);
assertEquals("{\"chat_id\":\"@test\",\"text\":\"Hithere\",\"parse_mode\":\"html\",\"reply_to_message_id\":12,\"reply_markup\":{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.ForceReplyKeyboard\",\"force_reply\":true},\"method\":\"sendmessage\"}", map(result));
}
示例6: TestAnswerCallbackQuery
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestAnswerCallbackQuery() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getAnswerCallbackQuery());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, AnswerCallbackQuery.class);
assertEquals("{\"callback_query_id\":\"id\",\"text\":\"text\",\"show_alert\":true,\"method\":\"answercallbackquery\"}", map(result));
}
示例7: TestAnswerInlineQuery
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestAnswerInlineQuery() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getAnswerInlineQuery());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, AnswerInlineQuery.class);
assertEquals("{\"personal\":true,\"inline_query_id\":\"id\",\"results\":[{\"@class\":\"org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResultArticle\",\"type\":\"article\",\"id\":\"0\",\"title\":\"Title\",\"input_message_content\":{\"@class\":\"org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputTextMessageContent\",\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup\",\"inline_keyboard\":[[{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton\",\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"url\":\"Url\",\"hide_url\":false,\"description\":\"Description\",\"thumb_url\":\"ThumbUrl\",\"thumb_width\":10,\"thumb_height\":20},{\"@class\":\"org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResultPhoto\",\"type\":\"photo\",\"id\":\"1\",\"photo_url\":\"PhotoUrl\",\"mime_type\":\"image/jpg\",\"photo_width\":10,\"photo_height\":20,\"thumb_url\":\"ThumbUrl\",\"title\":\"Title\",\"description\":\"Description\",\"caption\":\"Caption\",\"input_message_content\":{\"@class\":\"org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputTextMessageContent\",\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup\",\"inline_keyboard\":[[{\"@class\":\"org.telegram.telegrambots.api.objects.replykeyboard.buttons.InlineKeyboardButton\",\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]}}],\"cache_time\":100,\"is_personal\":true,\"next_offset\":\"3\",\"switch_pm_text\":\"pmText\",\"switch_pm_parameter\":\"PmParameter\",\"method\":\"answerInlineQuery\"}", map(result));
}
示例8: TestSendVenue
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestSendVenue() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendVenue());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, SendVenue.class);
assertEquals("{\"chat_id\":\"12345\",\"latitude\":12.5,\"longitude\":21.5,\"title\":\"Venue Title\",\"address\":\"Address\",\"foursquare_id\":\"FourId\",\"reply_to_message_id\":53,\"method\":\"sendVenue\"}", map(result));
}
示例9: TestSendGame
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestSendGame() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendGame());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, SendGame.class);
assertEquals("{\"chat_id\":\"12345\",\"game_short_name\":\"MyGame\",\"method\":\"sendGame\"}", map(result));
}
示例10: TestUnbanChatMember
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestUnbanChatMember() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getUnbanChatMember());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, UnbanChatMember.class);
assertEquals("{\"chat_id\":\"12345\",\"user_id\":98765,\"method\":\"unbanchatmember\"}", map(result));
}
示例11: TestGetChatMember
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestGetChatMember() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatMember());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, GetChatMember.class);
assertEquals("{\"chat_id\":\"12345\",\"user_id\":98765,\"method\":\"getChatMember\"}", map(result));
}
示例12: createEntity
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
public static <T> Entity<T> createEntity(T entityObject, String mediaType) {
if (entityObject instanceof String) {
if (MediaType.APPLICATION_JSON.equals(mediaType)) {
return Entity.json(entityObject);
} else {
return Entity.xml(entityObject);
}
} else {
return Entity.entity(entityObject, mediaType);
}
}
示例13: TestGetFile
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestGetFile() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetFile());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, GetFile.class);
assertEquals("{\"file_id\":\"FileId\",\"method\":\"getFile\"}", map(result));
}
示例14: TestGetGameHighScores
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestGetGameHighScores() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetGameHighScores());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, GetGameHighScores.class);
assertEquals("{\"chat_id\":\"12345\",\"message_id\":67890,\"user_id\":98765,\"method\":\"getGameHighScores\"}", map(result));
}
示例15: TestGetMe
import javax.ws.rs.client.Entity; //导入方法依赖的package包/类
@Test
public void TestGetMe() {
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetMe());
Entity<Update> entity = Entity.json(getUpdate());
BotApiMethod result =
target("callback/testbot")
.request(MediaType.APPLICATION_JSON)
.post(entity, GetMe.class);
assertEquals("{\"method\":\"getme\"}", map(result));
}