當前位置: 首頁>>代碼示例>>Java>>正文


Java LineMessageHandler類代碼示例

本文整理匯總了Java中com.linecorp.bot.spring.boot.annotation.LineMessageHandler的典型用法代碼示例。如果您正苦於以下問題:Java LineMessageHandler類的具體用法?Java LineMessageHandler怎麽用?Java LineMessageHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LineMessageHandler類屬於com.linecorp.bot.spring.boot.annotation包,在下文中一共展示了LineMessageHandler類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refresh

import com.linecorp.bot.spring.boot.annotation.LineMessageHandler; //導入依賴的package包/類
@VisibleForTesting
void refresh() {
    final Map<String, Object> handlerBeanMap =
            applicationContext.getBeansWithAnnotation(LineMessageHandler.class);

    final List<HandlerMethod> collect = handlerBeanMap
            .values().stream()
            .flatMap((Object bean) -> {
                final Method[] uniqueDeclaredMethods =
                        ReflectionUtils.getUniqueDeclaredMethods(bean.getClass());

                return Arrays.stream(uniqueDeclaredMethods)
                             .map(method -> getMethodHandlerMethodFunction(bean, method))
                             .filter(Objects::nonNull);
            })
            .sorted(HANDLER_METHOD_PRIORITY_COMPARATOR)
            .collect(Collectors.toList());

    log.info("Registered LINE Messaging API event handler: count = {}", collect.size());
    collect.forEach(item -> log.info("Mapped \"{}\" onto {}",
                                     item.getSupportType(), item.getHandler().toGenericString()));

    eventConsumerList = collect;
}
 
開發者ID:line,項目名稱:line-bot-sdk-java,代碼行數:25,代碼來源:LineMessageHandlerSupport.java

示例2: testRefreshForOneItem

import com.linecorp.bot.spring.boot.annotation.LineMessageHandler; //導入依賴的package包/類
@Test
public void testRefreshForOneItem() throws Exception {
    when(applicationContext.getBeansWithAnnotation(LineMessageHandler.class))
            .thenReturn(singletonMap("bean", new MessageHandler()));

    // Do
    target.refresh();

    // Verify
    assertThat(target.eventConsumerList).hasSize(1);
    HandlerMethod handlerMethod = target.eventConsumerList.get(0);

    assertThat(handlerMethod.getSupportType())
            .isInstanceOf(Predicate.class);
    assertThat(handlerMethod.getHandler())
            .isInstanceOf(Method.class);
}
 
開發者ID:line,項目名稱:line-bot-sdk-java,代碼行數:18,代碼來源:LineMessageHandlerSupportTest.java

示例3: testPrioritySelection

import com.linecorp.bot.spring.boot.annotation.LineMessageHandler; //導入依賴的package包/類
@Test
public void testPrioritySelection() throws Exception {
    when(applicationContext.getBeansWithAnnotation(LineMessageHandler.class))
            .thenReturn(ImmutableMap.of("bean", new MessageHandler(),
                                        "anothrer", new AnotherMessageHandler()));

    // Do
    target.refresh();

    // Verify
    assertThat(target.eventConsumerList).hasSize(3);

    // 1st
    assertThat(target.eventConsumerList.get(0).getHandler().getName())
            .isEqualTo("textMessageEventHandler");

    // 2nd
    assertThat(target.eventConsumerList.get(1).getHandler().getName())
            .isEqualTo("generalMessageHandler");

    // 3rd
    assertThat(target.eventConsumerList.get(2).getHandler().getName())
            .isEqualTo("defaultEventHandler");
}
 
開發者ID:line,項目名稱:line-bot-sdk-java,代碼行數:25,代碼來源:LineMessageHandlerSupportTest.java

示例4: dispatchAndReplyMessageTest

import com.linecorp.bot.spring.boot.annotation.LineMessageHandler; //導入依賴的package包/類
@Test
public void dispatchAndReplyMessageTest() {
    final MessageEvent event = EventTestUtil.createTextMessage("text");

    when(applicationContext.getBeansWithAnnotation(LineMessageHandler.class))
            .thenReturn(singletonMap("bean", new ReplyHandler("Message from Handler method")));

    target.refresh();

    // Do
    target.dispatch(event);

    // Verify
    verify(replyByReturnValueConsumerFactory).createForEvent(event);
    verify(replyByReturnValueConsumer, times(1)).accept(new TextMessage("Message from Handler method"));
}
 
開發者ID:line,項目名稱:line-bot-sdk-java,代碼行數:17,代碼來源:LineMessageHandlerSupportTest.java


注:本文中的com.linecorp.bot.spring.boot.annotation.LineMessageHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。