本文整理匯總了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"));
}