Search in sources :

Example 1 with RecordProcessingException

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());
}
Also used : TransformationException(eu.europeana.metis.transformation.service.TransformationException) RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) EuropeanaGeneratedIdsMap(eu.europeana.metis.transformation.service.EuropeanaGeneratedIdsMap) IOException(java.io.IOException) TransformationException(eu.europeana.metis.transformation.service.TransformationException) RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) Test(org.junit.jupiter.api.Test)

Example 2 with RecordProcessingException

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());
}
Also used : RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) RecordInfo(eu.europeana.metis.sandbox.domain.RecordInfo) Event(eu.europeana.metis.sandbox.domain.Event) RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) Test(org.junit.jupiter.api.Test)

Example 3 with RecordProcessingException

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());
}
Also used : RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) RecordInfo(eu.europeana.metis.sandbox.domain.RecordInfo) Event(eu.europeana.metis.sandbox.domain.Event) RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) Test(org.junit.jupiter.api.Test)

Example 4 with RecordProcessingException

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());
}
Also used : RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) RecordInfo(eu.europeana.metis.sandbox.domain.RecordInfo) Event(eu.europeana.metis.sandbox.domain.Event) RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) Test(org.junit.jupiter.api.Test)

Example 5 with RecordProcessingException

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);
}
Also used : IndexingException(eu.europeana.indexing.exception.IndexingException) RecordProcessingException(eu.europeana.metis.sandbox.common.exception.RecordProcessingException) Indexer(eu.europeana.indexing.Indexer) RecordInfo(eu.europeana.metis.sandbox.domain.RecordInfo) IndexingProperties(eu.europeana.indexing.IndexingProperties) Date(java.util.Date)

Aggregations

RecordProcessingException (eu.europeana.metis.sandbox.common.exception.RecordProcessingException)34 RecordInfo (eu.europeana.metis.sandbox.domain.RecordInfo)28 Test (org.junit.jupiter.api.Test)23 RecordProcessEvent (eu.europeana.metis.sandbox.domain.RecordProcessEvent)12 Event (eu.europeana.metis.sandbox.domain.Event)10 RecordError (eu.europeana.metis.sandbox.domain.RecordError)5 TransformationException (eu.europeana.metis.transformation.service.TransformationException)5 Record (eu.europeana.metis.sandbox.domain.Record)3 EuropeanaGeneratedIdsMap (eu.europeana.metis.transformation.service.EuropeanaGeneratedIdsMap)2 EuropeanaIdCreator (eu.europeana.metis.transformation.service.EuropeanaIdCreator)2 EuropeanaIdException (eu.europeana.metis.transformation.service.EuropeanaIdException)2 XsltTransformer (eu.europeana.metis.transformation.service.XsltTransformer)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 LinkedList (java.util.LinkedList)2 DereferenceException (eu.europeana.enrichment.rest.client.exceptions.DereferenceException)1 EnrichmentException (eu.europeana.enrichment.rest.client.exceptions.EnrichmentException)1 Indexer (eu.europeana.indexing.Indexer)1 IndexingProperties (eu.europeana.indexing.IndexingProperties)1 IndexingException (eu.europeana.indexing.exception.IndexingException)1 MediaExtractionException (eu.europeana.metis.mediaprocessing.exception.MediaExtractionException)1