INT-538: fix bug preventing @Aggregator with @Payloads from working
This commit is contained in:
@@ -537,7 +537,7 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator {
|
||||
Annotation match = null;
|
||||
for (Annotation annotation : annotations) {
|
||||
Class<? extends Annotation> type = annotation.annotationType();
|
||||
if (type.equals(Payload.class) || type.equals(Header.class) || type.equals(Headers.class)) {
|
||||
if (type.equals(Payload.class) || type.equals(Payloads.class) || type.equals(Header.class) || type.equals(Headers.class)) {
|
||||
if (match != null) {
|
||||
throw new MessagingException(
|
||||
"At most one parameter annotation can be provided for message mapping, "
|
||||
|
||||
@@ -188,6 +188,35 @@ public class MethodInvokingMessageGroupProcessorTests {
|
||||
assertThat((String) messageCaptor.getValue().getPayload(), is("[1, 2, 4, 3, 101, 102]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void shouldUseAnnotatedPayloads() throws Exception {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
class SimpleAggregator {
|
||||
@Aggregator
|
||||
public String and(@Payloads List<Integer> flags) {
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
for (int flag : flags) {
|
||||
result.add(flag);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
public String or(List<Integer> flags) {
|
||||
throw new UnsupportedOperationException("Not expected");
|
||||
}
|
||||
}
|
||||
|
||||
MessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(new SimpleAggregator());
|
||||
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
|
||||
when(outputChannel.send(isA(Message.class))).thenReturn(true);
|
||||
when(messageGroupMock.getUnmarked()).thenReturn(messagesUpForProcessing);
|
||||
processor.processAndSend(messageGroupMock, messagingTemplate, outputChannel);
|
||||
// verify
|
||||
verify(messagingTemplate).send(eq(outputChannel), messageCaptor.capture());
|
||||
assertThat((String) messageCaptor.getValue().getPayload(), is("[1, 2, 4]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void shouldFindSimpleAggregatorMethodWithCollection() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user