MultipartMessageBuilder extends ServiceImp { public MultipartMessageBuilder withMimeParts(List<MimePartBuilder> list) { setMimeParts(list); return this; } MultipartMessageBuilder(); @Override void doService(AdaptrisMessage msg); @Override void prepare(); List<MimePartBuilder> getMimeParts(); void setMimeParts(List<MimePartBuilder> parts); MetadataFilter getMimeHeaderFilter(); void setMimeHeaderFilter(MetadataFilter filter); String getContentId(); void setContentId(String s); String getMimeContentSubType(); void setMimeContentSubType(String sub); MultipartMessageBuilder withMimeHeaderFilter(MetadataFilter filter); MultipartMessageBuilder withMimeParts(List<MimePartBuilder> list); MultipartMessageBuilder withMimeParts(MimePartBuilder... builders); MultipartMessageBuilder withContentId(String s); MultipartMessageBuilder withMimeContentSubType(String s);  }
@Test public void testService() throws Exception { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World"); assertFalse(msg.headersContainsKey(CoreConstants.MSG_MIME_ENCODED)); MultipartMessageBuilder service = new MultipartMessageBuilder().withMimeParts(new InlineMimePartBuilder()); ExampleServiceCase.execute(service, msg); String payload = msg.getContent(); assertTrue(payload.contains(msg.getUniqueId())); assertTrue(msg.headersContainsKey(CoreConstants.MSG_MIME_ENCODED)); assertTrue( BooleanUtils.toBoolean(msg.getMetadataValue(CoreConstants.MSG_MIME_ENCODED))); }
@Test public void testService_Exception() throws Exception { AdaptrisMessage msg = new DefectiveMessageFactory(WhenToBreak.OUTPUT).newMessage("Hello World"); MultipartMessageBuilder service = new MultipartMessageBuilder().withMimeParts(new InlineMimePartBuilder()); try { ExampleServiceCase.execute(service, msg); fail(); } catch (ServiceException expected) { } }