@Test public void testOnMessageWithInterceptors() throws Exception { MockWorkflowInterceptor interceptor = new MockWorkflowInterceptor(); MockMessageProducer producer = new MockMessageProducer(); MockChannel channel = createChannel(producer, Arrays.asList(new Service[] { new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement(METADATA_KEY, METADATA_VALUE) })), new PayloadFromMetadataService(PAYLOAD_2) })); int count = 10; try { StandardWorkflow workflow = (StandardWorkflow) channel.getWorkflowList().get(0); workflow.addInterceptor(interceptor); channel.prepare(); start(channel); for (int i = 0; i < count; i++) { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1); workflow.onAdaptrisMessage(msg); } assertEquals("Make sure all produced", count, producer.messageCount()); assertEquals("Make sure all intercepted", count, interceptor.messageCount()); for (AdaptrisMessage m : producer.getMessages()) { assertEquals(PAYLOAD_2, m.getContent()); assertTrue("Contains correct metadata key", m.containsKey(METADATA_KEY)); assertEquals(METADATA_VALUE, m.getMetadataValue(METADATA_KEY)); } } finally { stop(channel); } }
@Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { super.onAdaptrisMessage(msg, success, failure); }
StandardWorkflow extends StandardWorkflowImpl { @Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { super.onAdaptrisMessage(msg, success, failure); } }
StandardWorkflow extends StandardWorkflowImpl { @Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { super.onAdaptrisMessage(msg, success, failure); } StandardWorkflow();  StandardWorkflow(AdaptrisMessageConsumer consumer, AdaptrisMessageProducer producer);  StandardWorkflow(AdaptrisMessageConsumer consumer, ServiceCollection services, AdaptrisMessageProducer producer); }
StandardWorkflow extends StandardWorkflowImpl { @Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { super.onAdaptrisMessage(msg, success, failure); } StandardWorkflow();  StandardWorkflow(AdaptrisMessageConsumer consumer, AdaptrisMessageProducer producer);  StandardWorkflow(AdaptrisMessageConsumer consumer, ServiceCollection services, AdaptrisMessageProducer producer); @Override synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure); }
StandardWorkflow extends StandardWorkflowImpl { @Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { super.onAdaptrisMessage(msg, success, failure); } StandardWorkflow();  StandardWorkflow(AdaptrisMessageConsumer consumer, AdaptrisMessageProducer producer);  StandardWorkflow(AdaptrisMessageConsumer consumer, ServiceCollection services, AdaptrisMessageProducer producer); @Override synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure);  }