From 9abe126a6d4491b113a61cc082499250ae0a9ced Mon Sep 17 00:00:00 2001 From: SamuelQuetin Date: Tue, 21 Nov 2023 15:17:31 +0100 Subject: [PATCH] fix champ doi -> titleUrl modif scanpackage swagger --- .../fr/abes/bestppn/controller/BestPpnController.java | 6 +++--- src/main/resources/application.properties | 2 +- .../fr/abes/bestppn/controller/BestPpnControllerTest.java | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index f08a701..23acadf 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -39,7 +39,7 @@ public BestPpnController(BestPpnService service) { @GetMapping(value = "/bestPpn") public String bestPpn(@RequestParam(name = "provider") String provider, @RequestParam(name = "publication_title", required = false) String publicationTitle, @RequestParam(name = "publication_type") String publicationType, @RequestParam(name = "online_identifier", required = false) String onlineIdentifier, - @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "doi", required = false) String doi, + @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force) throws IOException, IllegalPpnException { try { @@ -48,14 +48,14 @@ public String bestPpn(@RequestParam(name = "provider") String provider, @Request ligneKbartDto.setPublicationTitle((publicationTitle != null) ? publicationTitle : ""); ligneKbartDto.setOnlineIdentifier((onlineIdentifier != null) ? onlineIdentifier : ""); ligneKbartDto.setPrintIdentifier((printIdentifier != null) ? printIdentifier : ""); - ligneKbartDto.setTitleUrl((doi != null) ? doi : ""); + ligneKbartDto.setTitleUrl((titleUrl != null) ? titleUrl : ""); ligneKbartDto.setDateMonographPublishedPrint((dateMonographPublishedPrint != null) ? dateMonographPublishedPrint : ""); ligneKbartDto.setDateMonographPublishedOnline((dateMonographPublishedOnline != null) ? dateMonographPublishedOnline : ""); ligneKbartDto.setFirstAuthor((firstAuthor != null) ? firstAuthor : ""); boolean injectKafka = (force != null) ? force : false; return service.getBestPpn(ligneKbartDto, provider, injectKafka).getPpn(); } catch (URISyntaxException e) { - throw new IllegalArgumentException("Une url dans le champ doi du kbart n'est pas correcte"); + throw new IllegalArgumentException("Une url dans le champ title_url du kbart n'est pas correcte"); } catch (BestPpnException | RestClientException | IllegalArgumentException e) { return e.getMessage(); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 9df4eb6..6e72f02 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -42,7 +42,7 @@ kafkaconvergence.openapi.url= springdoc.swagger-ui.path=/convergence-documentation springdoc.api-docs.path=/convergence-api-docs -springdoc.packages-to-scan=fr.abes.kafkaconvergence.controller +springdoc.packages-to-scan=fr.abes.bestppn.controller springdoc.swagger-ui.try-it-out-enabled=true springdoc.swagger-ui.operations-sorter=method springdoc.swagger-ui.tags-sorter=alpha diff --git a/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java b/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java index a71bd9b..21a65ee 100644 --- a/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java +++ b/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java @@ -75,17 +75,17 @@ void testBestPpnControllerWrongNumberOfParameters() throws Exception { @DisplayName("test controller with wrong URL format") void testBestPpnControllerBadUrlFormat() throws Exception { Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new URISyntaxException("test", "Format d'URL incorrect")); - this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&doi=test").characterEncoding(StandardCharsets.UTF_8)) + this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&title_url=test").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isBadRequest()) .andExpect(result -> Assertions.assertTrue((result.getResolvedException() instanceof IllegalArgumentException))) - .andExpect(result -> Assertions.assertTrue(result.getResponse().getContentAsString(StandardCharsets.UTF_8).contains("Une url dans le champ doi du kbart n'est pas correcte"))); + .andExpect(result -> Assertions.assertTrue(result.getResponse().getContentAsString(StandardCharsets.UTF_8).contains("Une url dans le champ title_url du kbart n'est pas correcte"))); } @Test @DisplayName("test controller with BestPpnException") void testBestPpnControllerBestPpnException() throws Exception { Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new BestPpnException("Plusieurs ppn imprimés")); - this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&doi=test").characterEncoding(StandardCharsets.UTF_8)) + this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&title_url=test").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isOk()) .andExpect(result -> Assertions.assertTrue(result.getResponse().getContentAsString(StandardCharsets.UTF_8).contains("Plusieurs ppn imprimés"))); } @@ -94,7 +94,7 @@ void testBestPpnControllerBestPpnException() throws Exception { @DisplayName("test controller Ok") void testBestPpnControllerOk() throws Exception { Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(new PpnWithDestinationDto("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); - this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&doi=test").characterEncoding(StandardCharsets.UTF_8)) + this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&title_url=test").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isOk()) .andExpect(result -> Assertions.assertTrue(result.getResponse().getContentAsString(StandardCharsets.UTF_8).contains("111111111"))); }