Skip to content

Commit

Permalink
MET-6103 Cleanup deprecations on http harvesting (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
stzanakis authored Sep 5, 2024
1 parent 7268ef6 commit 58eba73
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import eu.europeana.metis.harvesting.HarvestingIterator;
import eu.europeana.metis.harvesting.ReportingIteration;
import eu.europeana.metis.harvesting.http.HttpHarvester;
import eu.europeana.metis.harvesting.http.HttpHarvester.ArchiveEntry;
import eu.europeana.metis.harvesting.oaipmh.OaiHarvest;
import eu.europeana.metis.harvesting.oaipmh.OaiHarvester;
import eu.europeana.metis.harvesting.oaipmh.OaiRecord;
Expand Down Expand Up @@ -173,7 +172,7 @@ public void harvestFromCompressedArchive(InputStream inputStream, String dataset

final List<Pair<String, Exception>> exception = new ArrayList<>(1);
final List<RecordInfo> recordInfoList = new ArrayList<>();
try (final HarvestingIterator<ArchiveEntry, Path> iterator = httpHarvester.createFullRecordHarvestIterator(inputStream,
try (final HarvestingIterator<FullRecord, Path> iterator = httpHarvester.createFullRecordHarvestIterator(inputStream,
compressedFileExtension)) {

harvestFromIterator(iterator, datasetId, stepSize, entry -> {
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/eu/europeana/metis/sandbox/common/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import static org.junit.jupiter.api.Assertions.fail;

import eu.europeana.metis.harvesting.FullRecord;
import eu.europeana.metis.harvesting.FullRecordHarvestingIterator;
import eu.europeana.metis.harvesting.HarvesterException;
import eu.europeana.metis.harvesting.ReportingIteration;
import eu.europeana.metis.harvesting.http.HttpHarvester.ArchiveEntry;
import eu.europeana.metis.harvesting.oaipmh.OaiRecordHeader;
import eu.europeana.metis.harvesting.oaipmh.OaiRecordHeaderIterator;
import java.io.BufferedReader;
Expand Down Expand Up @@ -75,18 +75,18 @@ public void close() {
}

public static class TestHttpRecordIterator implements
FullRecordHarvestingIterator<ArchiveEntry, Path> {
FullRecordHarvestingIterator<FullRecord, Path> {

private final List<ArchiveEntry> extractedDirectory;
private final List<FullRecord> extractedDirectory;

public TestHttpRecordIterator(List<ArchiveEntry> extractedDirectory) {
public TestHttpRecordIterator(List<FullRecord> extractedDirectory) {
this.extractedDirectory = extractedDirectory;
}

@Override
public void forEachFiltered(ReportingIteration<ArchiveEntry> reportingIteration, Predicate<Path> predicate)
public void forEachFiltered(ReportingIteration<FullRecord> reportingIteration, Predicate<Path> predicate)
throws HarvesterException {
for (ArchiveEntry item : this.extractedDirectory) {
for (FullRecord item : this.extractedDirectory) {
try {
reportingIteration.process(item);
} catch (IOException e) {
Expand All @@ -96,7 +96,7 @@ public void forEachFiltered(ReportingIteration<ArchiveEntry> reportingIteration,
}

@Override
public void forEachNonDeleted(ReportingIteration<ArchiveEntry> reportingIteration) {
public void forEachNonDeleted(ReportingIteration<FullRecord> reportingIteration) {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import eu.europeana.metis.harvesting.FullRecord;
import eu.europeana.metis.harvesting.HarvesterException;
import eu.europeana.metis.harvesting.http.HttpHarvester;
import eu.europeana.metis.harvesting.http.HttpHarvester.ArchiveEntry;
import eu.europeana.metis.harvesting.oaipmh.OaiHarvest;
import eu.europeana.metis.harvesting.oaipmh.OaiHarvester;
import eu.europeana.metis.harvesting.oaipmh.OaiRecord;
Expand All @@ -34,7 +34,6 @@
import eu.europeana.metis.sandbox.service.dataset.DatasetService;
import eu.europeana.metis.sandbox.service.dataset.RecordPublishService;
import eu.europeana.metis.utils.CompressedFileExtension;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -46,7 +45,6 @@
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -300,7 +298,7 @@ void harvest_exceedingRecordLimitWithXslt_expectSuccess() throws HarvesterExcept
void harvest_failsWithErrorMessage_expectSuccess() throws HarvesterException {
Path record1Path = Paths.get("src", "test", "resources", "zip", "Record1.xml");
assertTrue(Files.exists(record1Path));
final List<ArchiveEntry> pathList = convertFromPathList(List.of(record1Path));
final List<FullRecord> pathList = convertFromPathList(List.of(record1Path));

var httpRecordIterator = new TestUtils.TestHttpRecordIterator(pathList);

Expand Down Expand Up @@ -824,13 +822,8 @@ private void assertHarvestProcessWithoutXslt(RecordPublishService recordPublishS
assertHarvestProcess(recordPublishService, times, step, numberOfRecords);
}

private List<ArchiveEntry> convertFromPathList(List<Path> pathList) {
return pathList.stream().map(path -> new ArchiveEntry() {

@Override
public ByteArrayInputStream getEntryContent() {
throw new UnsupportedOperationException();
}
private List<FullRecord> convertFromPathList(List<Path> pathList) {
return pathList.stream().map(path -> new FullRecord() {

@Override
public void writeContent(OutputStream outputStream) {
Expand Down Expand Up @@ -859,15 +852,15 @@ public Instant getTimeStamp() {
}).collect(Collectors.toList());
}

private List<ArchiveEntry> prepareMockListForHttpIterator() {
private List<FullRecord> prepareMockListForHttpIterator() {
Path record1Path = Paths.get("src", "test", "resources", "zip", "Record1.xml");
assertTrue(Files.exists(record1Path));
Path record2Path = Paths.get("src", "test", "resources", "zip", "Record2.xml");
assertTrue(Files.exists(record2Path));
return convertFromPathList(List.of(record1Path, record2Path));
}

private List<ArchiveEntry> prepareMockListForHttpIteratorStepSizeTest() {
private List<FullRecord> prepareMockListForHttpIteratorStepSizeTest() {
Path record1Path = Paths.get("src", "test", "resources", "zip", "Record1.xml");
assertTrue(Files.exists(record1Path));
Path record2Path = Paths.get("src", "test", "resources", "zip", "Record2.xml");
Expand All @@ -879,7 +872,7 @@ private List<ArchiveEntry> prepareMockListForHttpIteratorStepSizeTest() {
return convertFromPathList(List.of(record1Path, record2Path, record3Path, record4Path));
}

private List<ArchiveEntry> addDuplicatedRecordsToHttpIterator(final List<ArchiveEntry> pathList) {
private List<FullRecord> addDuplicatedRecordsToHttpIterator(final List<FullRecord> pathList) {
final Path record2Path = Paths.get("src", "test", "resources", "zip", "Record2.xml");
assertTrue(Files.exists(record2Path));
return Stream.concat(pathList.stream(),
Expand Down

0 comments on commit 58eba73

Please sign in to comment.