Search in sources :

Example 6 with MetadataCacheValueTranslator

use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.

the class CacheEntryEvaluatorTest method testSetValueTranslator.

@Test
public void testSetValueTranslator() throws Exception {
    CacheEntryEvaluator eval = new CacheEntryEvaluator();
    assertNull(eval.getValueTranslator());
    assertNotNull(eval.valueTranslator());
    MetadataCacheValueTranslator translator = new MetadataCacheValueTranslator(DEFAULT_METADATA_KEY);
    eval.setValueTranslator(translator);
    assertEquals(translator, eval.getValueTranslator());
    assertEquals(translator, eval.valueTranslator());
    try {
        eval.setValueTranslator(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertEquals(translator, eval.getValueTranslator());
    assertEquals(translator, eval.valueTranslator());
}
Also used : MetadataCacheValueTranslator(com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator) Test(org.junit.Test)

Example 7 with MetadataCacheValueTranslator

use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.

the class CacheEntryEvaluatorTest method testEvaluateValue_NoErrorOnEmpty_EmptyValue.

@Test
public void testEvaluateValue_NoErrorOnEmpty_EmptyValue() throws Exception {
    CacheEntryEvaluator eval = new CacheEntryEvaluator();
    CacheValueTranslator translator = new MetadataCacheValueTranslator(DEFAULT_METADATA_KEY);
    eval.setValueTranslator(translator);
    eval.setErrorOnEmptyValue(false);
    AdaptrisMessage msg = createMessage(new ArrayList<MetadataElement>());
    assertEquals(null, eval.getValue(msg));
}
Also used : MetadataCacheValueTranslator(com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StaticCacheValueTranslator(com.adaptris.core.services.cache.translators.StaticCacheValueTranslator) MetadataCacheValueTranslator(com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator) NullCacheValueTranslator(com.adaptris.core.services.cache.CacheEntryEvaluator.NullCacheValueTranslator) MetadataElement(com.adaptris.core.MetadataElement) Test(org.junit.Test)

Example 8 with MetadataCacheValueTranslator

use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.

the class CacheEntryEvaluatorTest method testEvaluateKey_ErrorOnEmpty_NonEmptyValue.

@Test
public void testEvaluateKey_ErrorOnEmpty_NonEmptyValue() throws Exception {
    CacheEntryEvaluator eval = new CacheEntryEvaluator();
    MetadataCacheValueTranslator translator = new MetadataCacheValueTranslator(DEFAULT_METADATA_KEY);
    eval.setKeyTranslator(translator);
    AdaptrisMessage msg = createMessage(Arrays.asList(new MetadataElement[] { new MetadataElement(DEFAULT_METADATA_KEY, DEFAULT_VALUE) }));
    assertEquals(DEFAULT_VALUE, eval.getKey(msg));
}
Also used : MetadataCacheValueTranslator(com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) Test(org.junit.Test)

Example 9 with MetadataCacheValueTranslator

use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.

the class CacheEntryEvaluatorTest method testEvaluateKey_NoErrorOnEmpty_EmptyValue.

@Test
public void testEvaluateKey_NoErrorOnEmpty_EmptyValue() throws Exception {
    CacheEntryEvaluator eval = new CacheEntryEvaluator();
    MetadataCacheValueTranslator translator = new MetadataCacheValueTranslator(DEFAULT_METADATA_KEY);
    eval.setKeyTranslator(translator);
    eval.setErrorOnEmptyKey(false);
    AdaptrisMessage msg = createMessage(new ArrayList<MetadataElement>());
    assertEquals(null, eval.getKey(msg));
}
Also used : MetadataCacheValueTranslator(com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) Test(org.junit.Test)

Example 10 with MetadataCacheValueTranslator

use of com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator in project interlok by adaptris.

the class CacheEntryEvaluatorTest method testSetKeyTranslator.

@Test
public void testSetKeyTranslator() throws Exception {
    CacheEntryEvaluator eval = new CacheEntryEvaluator();
    assertNull(eval.getKeyTranslator());
    assertNotNull(eval.keyTranslator());
    MetadataCacheValueTranslator translator = new MetadataCacheValueTranslator(DEFAULT_METADATA_KEY);
    eval.setKeyTranslator(translator);
    assertEquals(translator, eval.getKeyTranslator());
    assertEquals(translator, eval.keyTranslator());
    try {
        eval.setKeyTranslator(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertEquals(translator, eval.getKeyTranslator());
    assertEquals(translator, eval.keyTranslator());
}
Also used : MetadataCacheValueTranslator(com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator) Test(org.junit.Test)

Aggregations

MetadataCacheValueTranslator (com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator)20 Test (org.junit.Test)13 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)11 MetadataElement (com.adaptris.core.MetadataElement)11 Cache (com.adaptris.core.cache.Cache)5 ServiceException (com.adaptris.core.ServiceException)3 CacheEntryEvaluator (com.adaptris.core.services.cache.CacheEntryEvaluator)3 NullCacheValueTranslator (com.adaptris.core.services.cache.CacheEntryEvaluator.NullCacheValueTranslator)3 JmsReplyToCacheValueTranslator (com.adaptris.core.services.cache.translators.JmsReplyToCacheValueTranslator)3 ObjectMetadataCacheValueTranslator (com.adaptris.core.services.cache.translators.ObjectMetadataCacheValueTranslator)3 StaticCacheValueTranslator (com.adaptris.core.services.cache.translators.StaticCacheValueTranslator)3 ArrayList (java.util.ArrayList)3 StringPayloadCacheTranslator (com.adaptris.core.services.cache.translators.StringPayloadCacheTranslator)2 AddToCacheService (com.adaptris.core.services.cache.AddToCacheService)1 XpathCacheValueTranslator (com.adaptris.core.services.cache.translators.XpathCacheValueTranslator)1