From 4214864244ffbd7eeabc3e36b1f48ea90ad684fa Mon Sep 17 00:00:00 2001 From: Sam Leeflang Date: Mon, 16 Dec 2024 15:09:40 +0100 Subject: [PATCH] Two minor fixes, annotation-creator and mjr for target --- .../backend/repository/ElasticSearchRepository.java | 2 +- .../dissco/backend/service/MasJobRecordService.java | 5 +---- src/test/java/eu/dissco/backend/TestUtils.java | 2 +- .../repository/ElasticSearchRepositoryIT.java | 5 +++-- .../backend/service/MasJobRecordServiceTest.java | 12 ------------ 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/main/java/eu/dissco/backend/repository/ElasticSearchRepository.java b/src/main/java/eu/dissco/backend/repository/ElasticSearchRepository.java index 845c78bd..c3c4bf7a 100644 --- a/src/main/java/eu/dissco/backend/repository/ElasticSearchRepository.java +++ b/src/main/java/eu/dissco/backend/repository/ElasticSearchRepository.java @@ -121,7 +121,7 @@ private DigitalSpecimen mapToDigitalSpecimen(ObjectNode json) { public Pair> getAnnotationsForCreator(String userId, int pageNumber, int pageSize) throws IOException { - var fieldName = "dcterms:creator.@id"; + var fieldName = "dcterms:creator.@id.keyword"; var offset = getOffset(pageNumber, pageSize); var pageSizePlusOne = pageSize + ONE_TO_CHECK_NEXT; diff --git a/src/main/java/eu/dissco/backend/service/MasJobRecordService.java b/src/main/java/eu/dissco/backend/service/MasJobRecordService.java index 60a76705..c0b16c0e 100644 --- a/src/main/java/eu/dissco/backend/service/MasJobRecordService.java +++ b/src/main/java/eu/dissco/backend/service/MasJobRecordService.java @@ -51,13 +51,10 @@ public JsonApiWrapper getMasJobRecordById(String masJobRecordHandle, String path } public JsonApiListResponseWrapper getMasJobRecordByTargetId(String targetId, - JobState state, String path, int pageNum, int pageSize) throws NotFoundException { + JobState state, String path, int pageNum, int pageSize) { var pageSizePlusOne = pageSize + 1; var masJobRecordListPlusOne = masJobRecordRepository.getMasJobRecordsByTargetId(targetId, state, pageNum, pageSizePlusOne); - if (masJobRecordListPlusOne.isEmpty()) { - throw new NotFoundException("No MAS Jobs for " + targetId + " found"); - } return packageList(masJobRecordListPlusOne, path, pageNum, pageSize); } diff --git a/src/test/java/eu/dissco/backend/TestUtils.java b/src/test/java/eu/dissco/backend/TestUtils.java index cbb00f43..c42dd108 100644 --- a/src/test/java/eu/dissco/backend/TestUtils.java +++ b/src/test/java/eu/dissco/backend/TestUtils.java @@ -21,7 +21,7 @@ public class TestUtils { - public static final String USER_ID_TOKEN = "e2befba6-9324-4bb4-9f41-d7dfae4a44b0"; + public static final String USER_ID_TOKEN = "https://orcid.org/0000-0002-5669-2769"; public static final String FORBIDDEN_MESSAGE = "User: " + USER_ID_TOKEN + " is not allowed to perform this action"; public static final String HANDLE = "https://hdl.handle.net/"; diff --git a/src/test/java/eu/dissco/backend/repository/ElasticSearchRepositoryIT.java b/src/test/java/eu/dissco/backend/repository/ElasticSearchRepositoryIT.java index 897a17a5..6ee6e0f3 100644 --- a/src/test/java/eu/dissco/backend/repository/ElasticSearchRepositoryIT.java +++ b/src/test/java/eu/dissco/backend/repository/ElasticSearchRepositoryIT.java @@ -68,7 +68,7 @@ class ElasticSearchRepositoryIT { private static final DockerImageName ELASTIC_IMAGE = DockerImageName.parse( - "docker.elastic.co/elasticsearch/elasticsearch").withTag("8.7.1"); + "docker.elastic.co/elasticsearch/elasticsearch").withTag("8.15.0"); private static final String DIGITAL_SPECIMEN_INDEX = "digital-specimen"; private static final String ANNOTATION_INDEX = "annotation"; private static final String ELASTICSEARCH_USERNAME = "elastic"; @@ -441,7 +441,8 @@ void testGetAnnotationsForCreator() throws IOException { expected.add(givenAnnotationResponse(id, USER_ID_TOKEN)); } givenAnnotations.add(givenAnnotationResponse(id, USER_ID_TOKEN)); - givenAnnotations.add(givenAnnotationResponse(id + "1", "A different User")); + givenAnnotations.add( + givenAnnotationResponse(id + "1", "https://orcid.org/0000-1112-5669-2769")); } postAnnotations(parseAnnotationToElasticFormat(givenAnnotations)); diff --git a/src/test/java/eu/dissco/backend/service/MasJobRecordServiceTest.java b/src/test/java/eu/dissco/backend/service/MasJobRecordServiceTest.java index d86911b3..a7dd7fed 100644 --- a/src/test/java/eu/dissco/backend/service/MasJobRecordServiceTest.java +++ b/src/test/java/eu/dissco/backend/service/MasJobRecordServiceTest.java @@ -74,18 +74,6 @@ void testGetMasJobRecordById() throws Exception { assertThat(result).isEqualTo(expected); } - @Test - void testGetMasJobRecordNotFound() { - // Given - given(masJobRecordRepository.getMasJobRecordsByTargetId(ID, - JobState.SCHEDULED, 1, 2)).willReturn(Collections.emptyList()); - - // Then - assertThrows(NotFoundException.class, - () -> masJobRecordService.getMasJobRecordByTargetId(ID, JobState.SCHEDULED, MJR_URI, - 1, 1)); - } - @Test void testGetMasJobRecordByIdEmpty() { // Given