use of eu.europeana.metis.sandbox.domain.Record in project metis-sandbox by europeana.
the class EnrichedConsumerTest method processMedia_serviceThrowException_expectFailStatus.
@Test
void processMedia_serviceThrowException_expectFailStatus() {
Record record = Record.builder().datasetId("1").datasetName("").country(Country.ITALY).language(Language.IT).content("".getBytes()).recordId("").build();
Event recordEvent = new Event(new RecordInfo(record), Step.ENRICH, Status.SUCCESS);
when(service.processMedia(record)).thenThrow(new RecordProcessingException("1", new Exception()));
consumer.processMedia(recordEvent);
verify(service).processMedia(record);
verify(amqpTemplate).convertAndSend(any(), captor.capture());
assertEquals(Status.FAIL, captor.getValue().getStatus());
}
use of eu.europeana.metis.sandbox.domain.Record in project metis-sandbox by europeana.
the class EnrichedConsumerTest method processMedia_expectSuccess.
@Test
void processMedia_expectSuccess() {
Record record = Record.builder().datasetId("1").datasetName("").country(Country.ITALY).language(Language.IT).content("".getBytes()).recordId("").build();
Event recordEvent = new Event(new RecordInfo(record), Step.ENRICH, Status.SUCCESS);
when(service.processMedia(record)).thenReturn(new RecordInfo(record));
consumer.processMedia(recordEvent);
verify(service).processMedia(record);
verify(amqpTemplate).convertAndSend(any(), captor.capture());
assertEquals(Step.MEDIA_PROCESS, captor.getValue().getStep());
}
use of eu.europeana.metis.sandbox.domain.Record in project metis-sandbox by europeana.
the class StepExecutorTest method consumeEventStatusSuccess_expectEventSuccess.
@Test
void consumeEventStatusSuccess_expectEventSuccess() {
final String routingKey = "routingKey";
final Record myTestRecord = getTestRecord(1L);
final RecordProcessEvent myEvent = new RecordProcessEvent(new RecordInfo(myTestRecord), Step.HARVEST_ZIP, Status.SUCCESS);
stepExecutor.consume(routingKey, myEvent, Step.HARVEST_ZIP, () -> getRecordInfo());
verify(amqpTemplate).convertAndSend(eq(routingKey), captor.capture());
assertRecordId_CreatedStepAndStatus(getRecordInfo().getRecord().getRecordId(), Status.SUCCESS);
}
use of eu.europeana.metis.sandbox.domain.Record in project metis-sandbox by europeana.
the class StepExecutorTest method consumeEventStatusFailQueueNeverCalled_expectException.
@Test
void consumeEventStatusFailQueueNeverCalled_expectException() {
final String routingKey = "routingKey";
final Record myTestRecord = getTestRecord(1L);
final RecordProcessEvent myEvent = new RecordProcessEvent(new RecordInfo(myTestRecord), Step.HARVEST_ZIP, Status.FAIL);
stepExecutor.consume(routingKey, myEvent, Step.HARVEST_ZIP, () -> getRecordInfo());
verify(amqpTemplate, never()).convertAndSend(eq(routingKey), captor.capture());
assertThrows(MockitoException.class, () -> captor.getValue());
}
use of eu.europeana.metis.sandbox.domain.Record in project metis-sandbox by europeana.
the class StepExecutorTest method consumeEventStatusSuccessThrowsRuntimeException_expectEventFail.
@Test
void consumeEventStatusSuccessThrowsRuntimeException_expectEventFail() {
final String routingKey = "routingKey";
final Long expectedRecordId = 1L;
final Record myTestRecord = getTestRecord(expectedRecordId);
final RecordProcessEvent myEvent = new RecordProcessEvent(new RecordInfo(myTestRecord), Step.HARVEST_ZIP, Status.SUCCESS);
stepExecutor.consume(routingKey, myEvent, Step.HARVEST_ZIP, () -> {
throw new RuntimeException("General Failure");
});
verify(amqpTemplate).convertAndSend(eq(routingKey), captor.capture());
assertRecordId_CreatedStepAndStatus(expectedRecordId, Status.FAIL);
}
Aggregations