From 2d50d2fe5f12c08f62d64d7d460405b36edc8ccc Mon Sep 17 00:00:00 2001 From: Joana Sousa Date: Fri, 1 Dec 2023 12:51:54 +0100 Subject: [PATCH] MET-5637 Code review changes --- .../dataset/DatasetReportServiceImpl.java | 4 ++-- .../service/dataset/DatasetServiceImpl.java | 7 +++++-- .../HarvestingParameterServiceImpl.java | 4 +++- .../controller/DatasetControllerIT.java | 4 ---- .../controller/DatasetControllerTest.java | 12 ++++++++---- .../PatternAnalysisServiceImplIT.java | 18 +++++++++++++++--- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/main/java/eu/europeana/metis/sandbox/service/dataset/DatasetReportServiceImpl.java b/src/main/java/eu/europeana/metis/sandbox/service/dataset/DatasetReportServiceImpl.java index b22e06b4..40650537 100644 --- a/src/main/java/eu/europeana/metis/sandbox/service/dataset/DatasetReportServiceImpl.java +++ b/src/main/java/eu/europeana/metis/sandbox/service/dataset/DatasetReportServiceImpl.java @@ -99,10 +99,10 @@ public ProgressInfoDto getReport(String datasetId) { } // get qty of records completely processed - long completedRecords = getCompletedRecords(stepStatistics); + final long completedRecords = getCompletedRecords(stepStatistics); // search for dataset - DatasetEntity dataset = getDataset(datasetId); + final DatasetEntity dataset = getDataset(datasetId); List datasetLogs = datasetLogService.getAllLogs(datasetId); if (stepStatistics.isEmpty() || stepStatistics.stream().allMatch(step -> step.getStatus().equals(Status.FAIL)) diff --git a/src/main/java/eu/europeana/metis/sandbox/service/dataset/DatasetServiceImpl.java b/src/main/java/eu/europeana/metis/sandbox/service/dataset/DatasetServiceImpl.java index 4cf651a2..d6a69495 100644 --- a/src/main/java/eu/europeana/metis/sandbox/service/dataset/DatasetServiceImpl.java +++ b/src/main/java/eu/europeana/metis/sandbox/service/dataset/DatasetServiceImpl.java @@ -9,7 +9,11 @@ import eu.europeana.metis.sandbox.common.exception.XsltProcessingException; import eu.europeana.metis.sandbox.common.locale.Country; import eu.europeana.metis.sandbox.common.locale.Language; -import eu.europeana.metis.sandbox.dto.*; +import eu.europeana.metis.sandbox.dto.DatasetInfoDto; +import eu.europeana.metis.sandbox.dto.HarvestingParametricDto; +import eu.europeana.metis.sandbox.dto.FileHarvestingDto; +import eu.europeana.metis.sandbox.dto.HttpHarvestingDto; +import eu.europeana.metis.sandbox.dto.OAIPmhHarvestingDto; import eu.europeana.metis.sandbox.entity.DatasetEntity; import eu.europeana.metis.sandbox.entity.HarvestingParameterEntity; import eu.europeana.metis.sandbox.entity.projection.DatasetIdView; @@ -98,7 +102,6 @@ public DatasetInfoDto getDatasetInfo(String datasetId) { DatasetEntity datasetEntity = datasetRepository.findById(Integer.valueOf(datasetId)).orElseThrow(() -> new InvalidDatasetException(datasetId)); return new DatasetInfoDto(datasetId, datasetEntity.getDatasetName(), datasetEntity.getCreatedDate(), datasetEntity.getLanguage(), datasetEntity.getCountry(), getHarvestingParameterDto(datasetId), isXsltPresent(datasetId)); - } private boolean isInputStreamAvailable(InputStream stream) { diff --git a/src/main/java/eu/europeana/metis/sandbox/service/dataset/HarvestingParameterServiceImpl.java b/src/main/java/eu/europeana/metis/sandbox/service/dataset/HarvestingParameterServiceImpl.java index df8f1464..f5775867 100644 --- a/src/main/java/eu/europeana/metis/sandbox/service/dataset/HarvestingParameterServiceImpl.java +++ b/src/main/java/eu/europeana/metis/sandbox/service/dataset/HarvestingParameterServiceImpl.java @@ -13,7 +13,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import static eu.europeana.metis.sandbox.common.HarvestProtocol.*; +import static eu.europeana.metis.sandbox.common.HarvestProtocol.FILE; +import static eu.europeana.metis.sandbox.common.HarvestProtocol.HTTP; +import static eu.europeana.metis.sandbox.common.HarvestProtocol.OAI_PMH; import static java.lang.String.format; import static java.util.Objects.requireNonNull; diff --git a/src/test/java/eu/europeana/metis/sandbox/controller/DatasetControllerIT.java b/src/test/java/eu/europeana/metis/sandbox/controller/DatasetControllerIT.java index 251d091d..8bb1dfa3 100644 --- a/src/test/java/eu/europeana/metis/sandbox/controller/DatasetControllerIT.java +++ b/src/test/java/eu/europeana/metis/sandbox/controller/DatasetControllerIT.java @@ -204,8 +204,6 @@ public void retrieveDatasetProgress_expectStatus_ok() throws IOException { assertNotNull(getDatasetResponse.getBody()); JSONAssert.assertEquals(StringUtils.deleteWhitespace(datasetResponseBodyContent), StringUtils.deleteWhitespace(getDatasetResponse.getBody()), true); - - } @Test @@ -232,8 +230,6 @@ void retrieveDatasetInfo_expectStatus_ok() throws IOException { assertTrue(getDatasetResponse.getBody().contains("\"creation-date\"")); JSONAssert.assertEquals(StringUtils.deleteWhitespace(datasetResponseBodyContent), StringUtils.deleteWhitespace(removeCreationDate(getDatasetResponse.getBody())), true); - - } @Test diff --git a/src/test/java/eu/europeana/metis/sandbox/controller/DatasetControllerTest.java b/src/test/java/eu/europeana/metis/sandbox/controller/DatasetControllerTest.java index b2d256f1..cd70afe4 100644 --- a/src/test/java/eu/europeana/metis/sandbox/controller/DatasetControllerTest.java +++ b/src/test/java/eu/europeana/metis/sandbox/controller/DatasetControllerTest.java @@ -34,11 +34,13 @@ import eu.europeana.metis.sandbox.common.exception.InvalidDatasetException; import eu.europeana.metis.sandbox.common.exception.NoRecordFoundException; import eu.europeana.metis.sandbox.common.exception.ServiceException; -import eu.europeana.metis.sandbox.common.locale.Country; -import eu.europeana.metis.sandbox.common.locale.Language; import eu.europeana.metis.sandbox.controller.ratelimit.RateLimitInterceptor; import eu.europeana.metis.sandbox.domain.DatasetMetadata; -import eu.europeana.metis.sandbox.dto.*; +import eu.europeana.metis.sandbox.dto.DatasetInfoDto; +import eu.europeana.metis.sandbox.dto.FileHarvestingDto; +import eu.europeana.metis.sandbox.dto.HttpHarvestingDto; +import eu.europeana.metis.sandbox.dto.OAIPmhHarvestingDto; +import eu.europeana.metis.sandbox.dto.RecordTiersInfoDto; import eu.europeana.metis.sandbox.dto.report.ErrorInfoDto; import eu.europeana.metis.sandbox.dto.report.ProgressByStepDto; import eu.europeana.metis.sandbox.dto.report.ProgressInfoDto; @@ -502,7 +504,9 @@ void retrieveDatasetProgress_expectSuccess() throws Exception { .andExpect(jsonPath("$.status", is("COMPLETED"))) .andExpect(jsonPath("$.progress-by-step[1].errors[0].message", - is(message1))); + is(message1))) + .andExpect(jsonPath("$.progress-by-step[1].errors[1].message", + is(message2))); verify(datasetLogService, never()).logException(any(), any()); } diff --git a/src/test/java/eu/europeana/metis/sandbox/service/problempatterns/PatternAnalysisServiceImplIT.java b/src/test/java/eu/europeana/metis/sandbox/service/problempatterns/PatternAnalysisServiceImplIT.java index 7a1dd116..856f8b84 100644 --- a/src/test/java/eu/europeana/metis/sandbox/service/problempatterns/PatternAnalysisServiceImplIT.java +++ b/src/test/java/eu/europeana/metis/sandbox/service/problempatterns/PatternAnalysisServiceImplIT.java @@ -4,7 +4,11 @@ import eu.europeana.metis.sandbox.entity.problempatterns.ExecutionPoint; import eu.europeana.metis.sandbox.entity.problempatterns.RecordTitle; import eu.europeana.metis.sandbox.entity.problempatterns.RecordTitleCompositeKey; -import eu.europeana.metis.sandbox.repository.problempatterns.*; +import eu.europeana.metis.sandbox.repository.problempatterns.RecordTitleRepository; +import eu.europeana.metis.sandbox.repository.problempatterns.ExecutionPointRepository; +import eu.europeana.metis.sandbox.repository.problempatterns.RecordProblemPatternRepository; +import eu.europeana.metis.sandbox.repository.problempatterns.RecordProblemPatternOccurrenceRepository; +import eu.europeana.metis.sandbox.repository.problempatterns.DatasetProblemPatternRepository; import eu.europeana.metis.sandbox.test.utils.TestContainer; import eu.europeana.metis.sandbox.test.utils.TestContainerFactoryIT; import eu.europeana.metis.sandbox.test.utils.TestContainerType; @@ -12,7 +16,11 @@ import eu.europeana.metis.schema.convert.SerializationException; import eu.europeana.metis.schema.jibx.RDF; import eu.europeana.patternanalysis.exception.PatternAnalysisException; -import eu.europeana.patternanalysis.view.*; +import eu.europeana.patternanalysis.view.ProblemPatternDescription; +import eu.europeana.patternanalysis.view.DatasetProblemPatternAnalysis; +import eu.europeana.patternanalysis.view.ProblemPattern; +import eu.europeana.patternanalysis.view.RecordAnalysis; +import eu.europeana.patternanalysis.view.ProblemOccurrence; import org.apache.commons.io.IOUtils; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.AfterEach; @@ -42,7 +50,11 @@ import java.util.Optional; import static org.apache.commons.lang3.StringUtils.isNotBlank; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; @ExtendWith(SpringExtension.class) @EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)