use of eu.europeana.metis.sandbox.common.exception.RecordProcessingException in project metis-sandbox by europeana.
the class TransformationServiceImplTest method transform_invalidXml_expectFail.
@Test
void transform_invalidXml_expectFail() throws IOException, TransformationException {
var input = testUtils.readFileToBytes("record/bad-order/record-input.xml");
var record = Record.builder().datasetId("1").datasetName("").country(Country.ITALY).language(Language.IT).content(input).recordId("1").build();
when(objectProvider.getObject(anyString(), anyString(), anyString())).thenReturn(xsltTransformer);
when(xsltTransformer.transformToBytes(any(byte[].class), any(EuropeanaGeneratedIdsMap.class))).thenThrow(new TransformationException(new Exception("Failing here")));
RecordProcessingException exception = assertThrows(RecordProcessingException.class, () -> service.transform(record));
assertEquals("1", exception.getRecordId());
}
use of eu.europeana.metis.sandbox.common.exception.RecordProcessingException in project metis-sandbox by europeana.
the class PreviewedConsumerTest method publish_serviceThrowException_expectFailStatus.
@Test
void publish_serviceThrowException_expectFailStatus() {
var record = Record.builder().datasetId("").datasetName("").country(Country.ITALY).language(Language.IT).content("".getBytes()).recordId("").build();
var recordEvent = new Event(new RecordInfo(record), Step.CREATE, Status.SUCCESS);
when(service.index(record, IndexEnvironment.PUBLISH)).thenThrow(new RecordProcessingException("1", new Exception()));
consumer.publish(recordEvent);
verify(service).index(record, IndexEnvironment.PUBLISH);
verify(amqpTemplate).convertAndSend(any(), captor.capture());
assertEquals(Status.FAIL, captor.getValue().getStatus());
}
use of eu.europeana.metis.sandbox.common.exception.RecordProcessingException in project metis-sandbox by europeana.
the class TransformedConsumerTest method validateInternal_serviceThrowException_expectFailStatus.
@Test
void validateInternal_serviceThrowException_expectFailStatus() {
var record = Record.builder().datasetId("1").datasetName("").country(Country.ITALY).language(Language.IT).content("".getBytes()).recordId("").build();
var recordEvent = new Event(new RecordInfo(record), Step.VALIDATE_INTERNAL, Status.SUCCESS);
when(service.validate(record)).thenThrow(new RecordProcessingException("1", new Exception()));
consumer.validateInternal(recordEvent);
verify(service).validate(record);
verify(amqpTemplate).convertAndSend(any(), captor.capture());
assertEquals(Status.FAIL, captor.getValue().getStatus());
}
use of eu.europeana.metis.sandbox.common.exception.RecordProcessingException in project metis-sandbox by europeana.
the class CreatedConsumerTest method validateExternal_serviceThrowException_expectFailStatus.
@Test
void validateExternal_serviceThrowException_expectFailStatus() {
var record = Record.builder().datasetId("1").datasetName("").country(Country.ITALY).language(Language.IT).content("".getBytes()).recordId("").build();
var recordEvent = new Event(new RecordInfo(record), Step.CREATE, Status.SUCCESS);
when(service.validate(record)).thenThrow(new RecordProcessingException("1", new Exception()));
consumer.validateExternal(recordEvent);
verify(service).validate(record);
verify(amqpTemplate).convertAndSend(any(), captor.capture());
assertEquals(Status.FAIL, captor.getValue().getStatus());
}
use of eu.europeana.metis.sandbox.common.exception.RecordProcessingException in project metis-sandbox by europeana.
the class IndexingServiceImpl method index.
@Override
public RecordInfo index(Record record, IndexEnvironment indexEnvironment) {
requireNonNull(record, "Record must not be null");
requireNonNull(indexEnvironment, "Index must not be null");
Indexer indexer = IndexEnvironment.PREVIEW == indexEnvironment ? previewIndexer : publishIndexer;
try {
indexer.index(record.getContentInputStream(), new IndexingProperties(new Date(), false, null, false, true));
} catch (IndexingException ex) {
throw new RecordProcessingException(record.getRecordId(), ex);
}
return new RecordInfo(record);
}
Aggregations