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());
}
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));
}
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));
}
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));
}
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());
}
Aggregations