use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class OrderedItemMetadataFilterTest method testFilterIgnoreCase.
@Test
public void testFilterIgnoreCase() {
OrderedItemMetadataFilter filter = new OrderedItemMetadataFilter();
filter.setIgnoreCase(true);
filter.setMetadataKeys(Arrays.asList("key1", "key2", "key3"));
AdaptrisMessage message = AdaptrisMessageFactory.getDefaultInstance().newMessage();
message.addMetadata("Key1", "value1");
message.addMetadata("key3", "value3");
MetadataCollection collection = filter.filter(message);
assertEquals(3, collection.size());
assertEquals("key1", collection.get(0).getKey());
assertEquals("value1", collection.get(0).getValue());
assertEquals("key2", collection.get(1).getKey());
assertEquals("", collection.get(1).getValue());
assertEquals("key3", collection.get(2).getKey());
assertEquals("value3", collection.get(2).getValue());
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class PasswordDecodeMetadataFilterTest method testFilter_NoMatches.
@Test
public void testFilter_NoMatches() throws Exception {
PasswordDecodeMetadataFilter filter = new PasswordDecodeMetadataFilter();
AdaptrisMessage msg = createMessage();
MetadataCollection filtered = filter.filter(msg);
assertEquals(3, filtered.size());
// Changes not reflected in the underlying message.
assertNotSame("password1", msg.getMetadataValue("passwordKey1"));
assertNotSame("password2", msg.getMetadataValue("passwordKey2"));
assertEquals("PW:WillNotDecode", msg.getMetadataValue("key1"));
for (MetadataElement e : filtered) {
if ("passwordKey1".equalsIgnoreCase(e.getKey())) {
assertTrue(e.getValue().startsWith("PW:"));
}
if ("passwordKey2".equalsIgnoreCase(e.getKey())) {
assertTrue(e.getValue().startsWith("PW:"));
}
}
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class PasswordDecodeMetadataFilterTest method testFilterWithException.
@Test
public void testFilterWithException() throws Exception {
PasswordDecodeMetadataFilter filter = new PasswordDecodeMetadataFilter().withPatterns("^.*password.*$", "^.*secret.*$");
AdaptrisMessage msg = createMessage();
msg.addMetadata("passwordKey3", "PW:Does_Not_Compute");
try {
MetadataCollection filtered = filter.filter(msg);
fail();
} catch (RuntimeException expected) {
}
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class PasswordDecodeMetadataFilterTest method testFilter.
@Test
public void testFilter() throws Exception {
PasswordDecodeMetadataFilter filter = new PasswordDecodeMetadataFilter().withPatterns("^.*password.*$", "^.*secret.*$");
AdaptrisMessage msg = createMessage();
MetadataCollection filtered = filter.filter(msg);
assertEquals(3, filtered.size());
// Changes not reflected in the underlying message.
assertNotSame("password1", msg.getMetadataValue("passwordKey1"));
assertNotSame("password2", msg.getMetadataValue("passwordKey2"));
assertEquals("PW:WillNotDecode", msg.getMetadataValue("key1"));
assertPasswords(filtered);
}
use of com.adaptris.core.MetadataCollection in project interlok by adaptris.
the class RemoveAllMetadataFilterTest method testFilterSet.
@Test
public void testFilterSet() throws Exception {
RemoveAllMetadataFilter filter = new RemoveAllMetadataFilter();
MetadataCollection c = filter.filter(createMessage().getMetadata());
assertEquals(0, c.size());
}
Aggregations