use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadStringInputParameterTest method testExtract.
@Test
public void testExtract() throws Exception {
MultiPayloadStringInputParameter parameter = new MultiPayloadStringInputParameter();
parameter.setPayloadId(ID);
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage(ID, PAYLOAD, ENCODING);
assertEquals(PAYLOAD, parameter.extract(message));
assertEquals(PAYLOAD, parameter.extract(ID, message));
assertEquals(PAYLOAD, parameter.extract(null, message));
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadStringOutputParameterTest method testInsertSetId.
@Test
public void testInsertSetId() throws Exception {
MultiPayloadStringOutputParameter parameter = new MultiPayloadStringOutputParameter();
parameter.setPayloadId(ID);
MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
parameter.insert(PAYLOAD, message);
assertEquals(PAYLOAD, message.getContent(ID));
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadMessageAggregator method aggregate.
@Override
public void aggregate(AdaptrisMessage original, Iterable<AdaptrisMessage> msgs) throws CoreException {
if (!(original instanceof MultiPayloadAdaptrisMessage)) {
throw new CoreException("Original not a multi-payload message, cannot merge");
}
log.trace("Adding messages to existing message [{}]", original.getUniqueId());
MultiPayloadAdaptrisMessage multiMessage = (MultiPayloadAdaptrisMessage) original;
String originalId = multiMessage.getCurrentPayloadId();
long count = 0;
for (AdaptrisMessage message : msgs) {
if (filter(message)) {
count++;
log.trace("Adding message payload [{}]", message.getUniqueId());
multiMessage.addPayload(message.getUniqueId(), message.getPayload());
}
}
if (replaceOriginal()) {
multiMessage.deletePayload(originalId);
}
log.trace("Finished adding {} messages", count);
}
Aggregations