Search in sources :

Example 6 with KeyValuePairList

use of com.adaptris.util.KeyValuePairList in project interlok by adaptris.

the class AddExtendedLoggingContextTest method testUseDefaultKeysReplace.

@Test
public void testUseDefaultKeysReplace() throws Exception {
    AddExtendedLoggingContext srv = new AddExtendedLoggingContext().withUseDefaultKeys(true).withValuesToSet(new KeyValuePairList(Collections.singletonMap(CoreConstants.MESSAGE_UNIQUE_ID_KEY, "somethingElse")));
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.addObjectHeader(CoreConstants.MESSAGE_UNIQUE_ID_KEY, "unique");
    execute(srv, msg);
    assertEquals("somethingElse", MDC.get(CoreConstants.MESSAGE_UNIQUE_ID_KEY));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) KeyValuePairList(com.adaptris.util.KeyValuePairList) Test(org.junit.Test)

Example 7 with KeyValuePairList

use of com.adaptris.util.KeyValuePairList in project interlok by adaptris.

the class MultiPayloadXmlTransformServiceTest method testResolvableExpressionParameter_XSLTOutput.

@Test
public void testResolvableExpressionParameter_XSLTOutput() throws Exception {
    MultiPayloadAdaptrisMessage message = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
    message.addPayload("somePayload", "World".getBytes());
    MultiPayloadXmlTransformService service = createBaseExample();
    ResolvableExpressionParameter params = new ResolvableExpressionParameter();
    KeyValuePairList exprns = new KeyValuePairList();
    exprns.add(new KeyValuePair("world", "%payload{id:somePayload}"));
    params.setExpressions(exprns);
    service.setTransformParameter(params);
    execute(service, message);
    assertEquals(PROPERTIES.getProperty(KEY_XML_TEST_OUTPUT) + "World", message.getContent(PAYLOAD_ID_OUTPUT));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairList(com.adaptris.util.KeyValuePairList) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

Example 8 with KeyValuePairList

use of com.adaptris.util.KeyValuePairList in project interlok by adaptris.

the class ResolvableExpressionParameterTest method setUp.

@Before
public void setUp() throws Exception {
    message = createMessage();
    message.setContent(CONTENT, "UTF-8");
    expressions = new KeyValuePairList();
    expressions.add(new KeyValuePair("beer", CONTENT));
    existing = new HashMap<>();
    existing.put("key", "value");
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairList(com.adaptris.util.KeyValuePairList) Before(org.junit.Before)

Example 9 with KeyValuePairList

use of com.adaptris.util.KeyValuePairList in project interlok by adaptris.

the class MapMetadataServiceTest method testReplacement_Resolved.

@Test
public void testReplacement_Resolved() throws Exception {
    MapMetadataService service = createService();
    KeyValuePairList kvps = new KeyValuePairList();
    kvps.addKeyValuePair(new KeyValuePair(BASIC_MATCH_VALUE, "%message{ResolvedKey}"));
    service.setMetadataKeyMap(kvps);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("zzzzzzzz");
    msg.addMetadata(METADATA_KEY, BASIC_MATCH_VALUE);
    msg.addMetadata("ResolvedKey", BASIC_NEW_VALUE);
    execute(service, msg);
    assertTrue(msg.getMetadataValue(METADATA_KEY).equals(BASIC_NEW_VALUE));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) KeyValuePairList(com.adaptris.util.KeyValuePairList) Test(org.junit.Test)

Example 10 with KeyValuePairList

use of com.adaptris.util.KeyValuePairList in project interlok by adaptris.

the class MapMetadataServiceTest method createService.

private MapMetadataService createService() {
    KeyValuePairList kvps = new KeyValuePairList();
    kvps.addKeyValuePair(new KeyValuePair(BASIC_MATCH_VALUE, BASIC_NEW_VALUE));
    kvps.addKeyValuePair(new KeyValuePair(UNMATCHED_REGXP, BASIC_NEW_VALUE));
    kvps.addKeyValuePair(new KeyValuePair(UNMATCHED_REGXP, "{1}"));
    kvps.addKeyValuePair(new KeyValuePair(REGEXP, REGEX_MATCH_GROUP));
    MapMetadataService service = new MapMetadataService();
    service.setMetadataKeyMap(kvps);
    service.setMetadataKey(METADATA_KEY);
    return service;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairList(com.adaptris.util.KeyValuePairList)

Aggregations

KeyValuePairList (com.adaptris.util.KeyValuePairList)15 KeyValuePair (com.adaptris.util.KeyValuePair)12 Test (org.junit.Test)12 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)9 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)2 StandardWorkflow (com.adaptris.core.StandardWorkflow)2 MockChannel (com.adaptris.core.stubs.MockChannel)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 MultiPayloadAdaptrisMessage (com.adaptris.core.MultiPayloadAdaptrisMessage)1 Before (org.junit.Before)1