本文整理汇总了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;
}
示例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);
}
示例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");
}
示例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"));
}