use of com.adaptris.core.MetadataElement 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.MetadataElement in project interlok by adaptris.
the class CacheEntryEvaluatorTest method testEvaluateValue_WithError.
@Test
public void testEvaluateValue_WithError() throws Exception {
CacheEntryEvaluator eval = new CacheEntryEvaluator();
CacheValueTranslator translator = new StaticCacheValueTranslator() {
@Override
public String getValueFromMessage(AdaptrisMessage msg) throws CoreException {
throw new UnsupportedOperationException();
}
};
eval.setValueTranslator(translator);
AdaptrisMessage msg = createMessage(new ArrayList<MetadataElement>());
// We don't actually *expect* to catch an exception here.
// The code just returns null in the event we can't get the value from the AdaptrisMessage.
assertNull(eval.getValue(msg));
}
use of com.adaptris.core.MetadataElement 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.MetadataElement in project interlok by adaptris.
the class DynamicServiceExecutorTest method testDoService_DefaultServiceExtractor_WithMarshaller.
@Test
public void testDoService_DefaultServiceExtractor_WithMarshaller() throws Exception {
AddMetadataService metadataService = new AddMetadataService();
metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
DynamicServiceExecutor dynamicService = createService();
dynamicService.setMarshaller(new XStreamMarshaller());
AdaptrisMessage msg = createMessage(new ServiceList(new Service[] { metadataService }));
execute(dynamicService, msg);
assertEquals(getName(), msg.getMetadataValue(getName()));
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class DynamicServiceExecutorTest method testDoService_MimeServiceExtractor_ByContentId_NotFound.
@Test
public void testDoService_MimeServiceExtractor_ByContentId_NotFound() throws Exception {
AddMetadataService metadataService = new AddMetadataService();
metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
DynamicServiceExecutor dynamicService = createService();
dynamicService.setServiceExtractor(new MimeServiceExtractor(new SelectByContentId("Blah")));
AdaptrisMessage msg = createMimeMessage(new ServiceList(new Service[] { metadataService }), ENCODING_BASE64);
try {
execute(dynamicService, msg);
fail();
} catch (ServiceException expected) {
}
}
Aggregations