当前位置: 首页>>代码示例>>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;未经允许,请勿转载。