use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class FixedValuesMetadataFilterTest method testFilterMessage.
@Test
public void testFilterMessage() throws Exception {
FixedValuesMetadataFilter filter = new FixedValuesMetadataFilter().withMetadata(new KeyValuePair("hello", "world"));
MetadataCollection c = filter.filter(createMessage());
assertEquals(1, c.size());
Map<String, String> map = MetadataCollection.asMap(c);
assertFalse(map.containsKey("someRandomKey"));
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class MappedKeyMetadataFilterTest method testFilter.
@Test
public void testFilter() {
MappedKeyMetadataFilter filterer = new MappedKeyMetadataFilter("^key(.*)$", "actual$1");
AdaptrisMessage message = newMessage();
MetadataCollection resultingCollection = filterer.filter(message);
assertEquals(message.getMetadata().size(), resultingCollection.size());
assertTrue(message.getMessageHeaders().containsKey("key1"));
assertFalse(resultingCollection.containsKey("key1"));
assertFalse(message.getMessageHeaders().containsKey("actual1"));
assertTrue(resultingCollection.containsKey("actual1"));
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class MetadataRegexKeyFilterTest method testExcludes2Keys.
@Test
public void testExcludes2Keys() {
filterer.addExcludePattern("Jill");
MetadataCollection resultingCollection = filterer.filter(message);
assertEquals(6, resultingCollection.size());
assertTrue(resultingCollection.containsKey("key1"));
assertTrue(resultingCollection.containsKey("key2"));
assertTrue(resultingCollection.containsKey("key3"));
assertTrue(resultingCollection.containsKey("key4"));
assertTrue(resultingCollection.containsKey("key5"));
assertTrue(resultingCollection.containsKey("someRandomKey"));
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class MetadataRegexKeyFilterTest method testIncludesOnly5Keys.
@Test
public void testIncludesOnly5Keys() {
filterer.addIncludePattern("key");
MetadataCollection resultingCollection = filterer.filter(message);
assertEquals(5, resultingCollection.size());
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class MetadataRegexKeyFilterTest method testIncludesKeyAndExcludes3.
@Test
public void testIncludesKeyAndExcludes3() {
filterer.addIncludePattern("key");
filterer.addExcludePattern("3");
MetadataCollection resultingCollection = filterer.filter(message);
assertEquals(4, resultingCollection.size());
assertTrue(resultingCollection.containsKey("key1"));
assertTrue(resultingCollection.containsKey("key2"));
assertTrue(resultingCollection.containsKey("key4"));
assertTrue(resultingCollection.containsKey("key5"));
}
Aggregations