@Test public void testSplitWithObjectMetadata() throws Exception { final int expectedSplitCount = 10; AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(LINE); String obj = "ABCDEFG"; msg.addObjectHeader(obj, obj); msg.addMetadata(METADATA_KEY, String.valueOf(expectedSplitCount)); MetadataDocumentCopier splitter = new MetadataDocumentCopier(METADATA_KEY, METADATA_KEY_INDEX); splitter.setCopyObjectMetadata(true); try (CloseableIterable<AdaptrisMessage> result = splitter.splitMessage(msg)) { int count = 0; for (AdaptrisMessage m : result) { assertTrue("Object Metadata", m.getObjectHeaders().containsKey(obj)); assertEquals(obj, m.getObjectHeaders().get(obj)); assertEquals(String.valueOf(count), m.getMetadataValue(METADATA_KEY_INDEX)); count++; } assertEquals(expectedSplitCount, count); } }
@Override public CloseableIterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg) throws CoreException { int size = toInteger(msg.getMetadataValue(getMetadataKey())); return new MessageCopierIterator(msg, size, (m, count) -> { if (!isEmpty(getIndexMetadataKey())) { m.addMetadata(getIndexMetadataKey(), String.valueOf(count)); } return m; }); }
MetadataDocumentCopier extends MessageCopier { @Override public CloseableIterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg) throws CoreException { int size = toInteger(msg.getMetadataValue(getMetadataKey())); return new MessageCopierIterator(msg, size, (m, count) -> { if (!isEmpty(getIndexMetadataKey())) { m.addMetadata(getIndexMetadataKey(), String.valueOf(count)); } return m; }); } }
MetadataDocumentCopier extends MessageCopier { @Override public CloseableIterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg) throws CoreException { int size = toInteger(msg.getMetadataValue(getMetadataKey())); return new MessageCopierIterator(msg, size, (m, count) -> { if (!isEmpty(getIndexMetadataKey())) { m.addMetadata(getIndexMetadataKey(), String.valueOf(count)); } return m; }); } MetadataDocumentCopier();  MetadataDocumentCopier(String key);  MetadataDocumentCopier(String key, String indexKey); }
MetadataDocumentCopier extends MessageCopier { @Override public CloseableIterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg) throws CoreException { int size = toInteger(msg.getMetadataValue(getMetadataKey())); return new MessageCopierIterator(msg, size, (m, count) -> { if (!isEmpty(getIndexMetadataKey())) { m.addMetadata(getIndexMetadataKey(), String.valueOf(count)); } return m; }); } MetadataDocumentCopier();  MetadataDocumentCopier(String key);  MetadataDocumentCopier(String key, String indexKey); @Override CloseableIterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg); void setMetadataKey(String key); String getMetadataKey(); String getIndexMetadataKey(); void setIndexMetadataKey(String s); }
MetadataDocumentCopier extends MessageCopier { @Override public CloseableIterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg) throws CoreException { int size = toInteger(msg.getMetadataValue(getMetadataKey())); return new MessageCopierIterator(msg, size, (m, count) -> { if (!isEmpty(getIndexMetadataKey())) { m.addMetadata(getIndexMetadataKey(), String.valueOf(count)); } return m; }); } MetadataDocumentCopier();  MetadataDocumentCopier(String key);  MetadataDocumentCopier(String key, String indexKey); @Override CloseableIterable<AdaptrisMessage> splitMessage(AdaptrisMessage msg); void setMetadataKey(String key); String getMetadataKey(); String getIndexMetadataKey(); void setIndexMetadataKey(String s);  }