From 9a85911033b3cf588b925c6a09eab1790799c431 Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Sat, 21 Oct 2023 20:50:57 -0400 Subject: [PATCH 1/9] Unused imports --- .../DomainClientLayer/VetsClient.java | 1 - .../Exceptions/BadRequestExceptionTest.java | 4 +--- .../GlobalControllerExceptionHandlerTest.java | 3 +-- .../Exceptions/NotFoundExceptionTest.java | 4 +--- .../PresentationLayer/VisitControllerUnitTest.java | 12 ++++++------ 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/VetsClient.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/VetsClient.java index daa42fdd16..264ace4cc5 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/VetsClient.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/VetsClient.java @@ -5,7 +5,6 @@ import org.springframework.http.HttpStatusCode; import org.springframework.stereotype.Service; import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @Service diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/BadRequestExceptionTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/BadRequestExceptionTest.java index ba3106a65f..2e87c1acd6 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/BadRequestExceptionTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/BadRequestExceptionTest.java @@ -1,11 +1,9 @@ package com.petclinic.visits.visitsservicenew.Exceptions; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; @SpringBootTest class BadRequestExceptionTest { diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/GlobalControllerExceptionHandlerTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/GlobalControllerExceptionHandlerTest.java index c3210a912b..9b7d216d0f 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/GlobalControllerExceptionHandlerTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/GlobalControllerExceptionHandlerTest.java @@ -9,9 +9,8 @@ import org.springframework.mock.http.server.reactive.MockServerHttpRequest; import org.springframework.test.context.junit.jupiter.SpringExtension; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; @SpringBootTest diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/NotFoundExceptionTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/NotFoundExceptionTest.java index b8075439c5..0241ea2885 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/NotFoundExceptionTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Exceptions/NotFoundExceptionTest.java @@ -2,11 +2,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.internal.matchers.Not; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; - -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; @SpringBootTest @ExtendWith(SpringExtension.class) diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitControllerUnitTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitControllerUnitTest.java index f9e50d24ec..e4f0e990fa 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitControllerUnitTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitControllerUnitTest.java @@ -3,8 +3,9 @@ import com.petclinic.visits.visitsservicenew.BusinessLayer.VisitService; import com.petclinic.visits.visitsservicenew.DataLayer.Status; -import com.petclinic.visits.visitsservicenew.DataLayer.Visit; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.*; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.SpecialtyDTO; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.VetDTO; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Workday; import com.petclinic.visits.visitsservicenew.Exceptions.NotFoundException; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -15,15 +16,14 @@ import org.springframework.test.web.reactive.server.WebTestClient; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Date; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.*; @WebFluxTest(VisitController.class) class VisitControllerUnitTest { From 6e111a47a505547c2d510705f7cd7e16ac181c77 Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Mon, 23 Oct 2023 10:31:40 -0400 Subject: [PATCH 2/9] Rebase --- api-gateway/build.gradle | 48 ++++++++++++++------------------- visits-service-new/build.gradle | 31 ++++++++++----------- 2 files changed, 36 insertions(+), 43 deletions(-) diff --git a/api-gateway/build.gradle b/api-gateway/build.gradle index 074e953a67..8160c9dabb 100755 --- a/api-gateway/build.gradle +++ b/api-gateway/build.gradle @@ -21,39 +21,31 @@ repositories { dependencies { - - - implementation 'io.jsonwebtoken:jjwt-api:0.11.2' - runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2' - runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.2' - - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-actuator' - implementation 'org.springframework.boot:spring-boot-starter-webflux' - implementation 'org.yaml:snakeyaml:2.2' - - implementation 'org.webjars:bootstrap:5.1.0' // https://mvnrepository.com/artifact/org.webjars/bootstrap - implementation 'org.webjars:jquery:3.6.0' // https://mvnrepository.com/artifact/org.webjars/jquery - implementation 'org.webjars:angularjs:2.0.0-alpha.22' // https://mvnrepository.com/artifact/org.webjars/angularjs - - implementation 'org.webjars.bower:angular-ui-router:1.0.28' // https://mvnrepository.com/artifact/org.webjars.bower/angular-ui-router - implementation 'org.webjars:webjars-locator-core:0.47' // https://mvnrepository.com/artifact/org.webjars/webjars-locator-core - implementation 'ro.isdc.wro4j:wro4j-core:1.10.1' // https://mvnrepository.com/artifact/ro.isdc.wro4j/wro4j-core - implementation 'com.github.houbie:lesscss-gradle-plugin:1.0.3-less-1.7.0' // https://mvnrepository.com/artifact/com.github.houbie/lesscss-gradle-plugin - implementation 'com.github.houbie:lesscss-gradle-plugin:1.0.3-less-1.7.0' // https://mvnrepository.com/artifact/com.github.houbie/lesscss-gradle-plugin - implementation 'org.jolokia:jolokia-core:1.7.0' // https://mvnrepository.com/artifact/org.jolokia/jolokia-core - implementation 'io.springfox:springfox-boot-starter:3.0.0' - implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' //for serializing and deserializing java.time.LocalDateTime - + runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2', 'io.jsonwebtoken:jjwt-jackson:0.11.2' + + implementation 'org.webjars:bootstrap:5.1.0', // https://mvnrepository.com/artifact/org.webjars/bootstrap + 'org.springframework.boot:spring-boot-starter-webflux', + 'org.springframework.boot:spring-boot-starter-actuator', + 'org.springframework.boot:spring-boot-starter-validation', + 'io.jsonwebtoken:jjwt-api:0.11.2', + 'org.webjars:jquery:3.6.0', // https://mvnrepository.com/artifact/org.webjars/jquery + 'org.webjars:angularjs:2.0.0-alpha.22', // https://mvnrepository.com/artifact/org.webjars/angularjs + 'org.webjars.bower:angular-ui-router:1.0.28', // https://mvnrepository.com/artifact/org.webjars.bower/angular-ui-router + 'org.webjars:webjars-locator-core:0.47', // https://mvnrepository.com/artifact/org.webjars/webjars-locator-core + 'ro.isdc.wro4j:wro4j-core:1.10.1', // https://mvnrepository.com/artifact/ro.isdc.wro4j/wro4j-core + 'com.github.houbie:lesscss-gradle-plugin:1.0.3-less-1.7.0', // https://mvnrepository.com/artifact/com.github.houbie/lesscss-gradle-plugin + 'org.jolokia:jolokia-core:1.7.0', // https://mvnrepository.com/artifact/org.jolokia/jolokia-core + 'io.springfox:springfox-boot-starter:3.0.0', + 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310', //for serializing and deserializing java.time.LocalDateTime + 'org.yaml:snakeyaml:2.2' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } - testImplementation 'io.projectreactor:reactor-test' - testImplementation 'com.squareup.okhttp3:okhttp:4.11.0' - testImplementation 'com.squareup.okhttp3:mockwebserver:4.11.0' - + testImplementation 'com.squareup.okhttp3:okhttp:4.11.0', + 'com.squareup.okhttp3:mockwebserver:4.11.0', + 'io.projectreactor:reactor-test' } jacoco { diff --git a/visits-service-new/build.gradle b/visits-service-new/build.gradle index 812ebabd18..f82e3b1aaa 100644 --- a/visits-service-new/build.gradle +++ b/visits-service-new/build.gradle @@ -18,25 +18,26 @@ ext { mapstructVersion = "1.5.5.Final" } dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive', + 'org.springframework.boot:spring-boot-starter-webflux', + 'org.yaml:snakeyaml:2.2', + "org.mapstruct:mapstruct:${mapstructVersion}", + 'org.simplejavamail:simple-java-mail:8.3.1', 'net.markenwerk:utils-mail-dkim:2.0.1' //Simple Java Mail and DKIM a framework for DKIM signing and verification - implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive' - implementation 'org.springframework.boot:spring-boot-starter-webflux' - compileOnly 'org.projectlombok:lombok' - annotationProcessor 'org.projectlombok:lombok' + compileOnly 'org.projectlombok:lombok', + "org.mapstruct:mapstruct-processor:${mapstructVersion}" - - implementation("org.mapstruct:mapstruct:${mapstructVersion}") - compileOnly "org.mapstruct:mapstruct-processor:${mapstructVersion}" - annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}" testAnnotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}" + annotationProcessor 'org.projectlombok:lombok', + "org.mapstruct:mapstruct-processor:${mapstructVersion}" - testImplementation 'org.springframework.boot:spring-boot-starter-test' - implementation 'org.yaml:snakeyaml:2.2' - testImplementation 'org.yaml:snakeyaml:2.2' - testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo.spring30x:4.9.2' - testImplementation 'io.projectreactor:reactor-test' - testImplementation 'com.squareup.okhttp3:okhttp:4.11.0' - testImplementation 'com.squareup.okhttp3:mockwebserver:4.11.0' + testImplementation 'com.squareup.okhttp3:mockwebserver:4.11.0', + 'org.simplejavamail:simple-java-mail:8.3.1', 'net.markenwerk:utils-mail-dkim:2.0.1', //Simple Java Mail and DKIM a framework for DKIM signing and verification + 'org.springframework.boot:spring-boot-starter-test', + 'org.yaml:snakeyaml:2.2', + 'de.flapdoodle.embed:de.flapdoodle.embed.mongo.spring30x:4.9.2', + 'io.projectreactor:reactor-test', + 'com.squareup.okhttp3:okhttp:4.11.0' } jacoco { From 61529eb4c6e704dd44a16326557ba985cabf2958 Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Sun, 22 Oct 2023 23:07:45 -0400 Subject: [PATCH 3/9] Fixes --- .../VisitsServiceClient.java | 28 ++++++++++++++++ .../BFFApiGatewayController.java | 3 +- .../BusinessLayer/VisitServiceImpl.java | 9 +----- .../SimpleJavaMailClient.java | 32 +++++++++++++++++++ .../BusinessLayer/VisitServiceImplTest.java | 2 +- 5 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMailClient.java diff --git a/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java b/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java index 265f5fe9b4..d0b2f84b13 100755 --- a/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java +++ b/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.petclinic.bffapigateway.BFFApiGatewayApplication; import com.petclinic.bffapigateway.dtos.Visits.*; import com.petclinic.bffapigateway.exceptions.BadRequestException; import com.petclinic.bffapigateway.exceptions.DuplicateTimeException; @@ -132,6 +133,33 @@ else if (httpStatus == HttpStatus.CONFLICT){ } }); }) + .onStatus(HttpStatusCode::is2xxSuccessful, response -> { + HttpStatusCode httpStatus = response.statusCode(); + if (httpStatus == HttpStatus.CREATED) { + + return null; +// return response.bodyToMono(VisitResponseDTO.class); + } + return null; + +// return response.bodyToMono(String.class) +// .flatMap(errorMessage -> { +// try { +// ObjectMapper objectMapper = new ObjectMapper(); +// JsonNode errorNode = objectMapper.readTree(errorMessage); +// String message = errorNode.get("message").asText(); +// +// if (httpStatus == HttpStatus.NOT_FOUND) { +// return Mono.error(new NotFoundException(message)); +// } else { +// return Mono.error(new BadRequestException(message)); +// } +// } catch (IOException e) { +// // Handle parsing error +// return Mono.error(new BadRequestException("Bad Request")); +// } +// }); + }) .bodyToMono(VisitResponseDTO.class); } diff --git a/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java b/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java index 68fc527953..0adbcd8a98 100644 --- a/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java +++ b/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java @@ -262,8 +262,9 @@ public Mono getVisitByVisitId(@PathVariable String visitId){ return visitsServiceClient.getVisitByVisitId(visitId); } @PostMapping(value = "visit/owners/{ownerId}/pets/{petId}/visits", consumes = "application/json", produces = "application/json") - Mono> addVisit(@RequestBody VisitRequestDTO visit, @PathVariable String ownerId, @PathVariable String petId) { + Mono> addVisit(@RequestBody VisitRequestDTO visit, @PathVariable String ownerId, @PathVariable String petId, @CookieValue("Bearer") String auth) { // visit.setPetId(petId); + Mono user = getUserById(auth, ownerId); return visitsServiceClient.createVisitForPet(visit).map(ResponseEntity.status(HttpStatus.CREATED)::body) .defaultIfEmpty(ResponseEntity.badRequest().build()); } diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java index 221b84e47f..09a6d9bbdc 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java @@ -2,10 +2,7 @@ import com.petclinic.visits.visitsservicenew.DataLayer.Status; import com.petclinic.visits.visitsservicenew.DataLayer.VisitRepo; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.PetResponseDTO; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.PetsClient; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.VetDTO; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.VetsClient; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.*; import com.petclinic.visits.visitsservicenew.Exceptions.BadRequestException; import com.petclinic.visits.visitsservicenew.Exceptions.DuplicateTimeException; import com.petclinic.visits.visitsservicenew.Exceptions.NotFoundException; @@ -100,10 +97,6 @@ public Mono addVisit(Mono visitRequestDTOMono .flatMap(visit -> entityDtoUtil.toVisitResponseDTO(visit)); } - - - - @Override public Mono deleteVisit(String visitId) { return repo.existsByVisitId(visitId) diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMailClient.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMailClient.java new file mode 100644 index 0000000000..ea1dc65464 --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMailClient.java @@ -0,0 +1,32 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer; + + +import lombok.NoArgsConstructor; +import org.simplejavamail.api.email.Email; +import org.simplejavamail.api.mailer.Mailer; +import org.simplejavamail.api.mailer.config.TransportStrategy; +import org.simplejavamail.email.EmailBuilder; +import org.simplejavamail.mailer.MailerBuilder; + + +@NoArgsConstructor +public class SimpleJavaMailClient { + private final Email email = EmailBuilder.startingBlank() + .from("From", "champlain.petclinic@gmail.com") + .to("William", "william.chalifoux@gmail.com") + .withSubject("Email test with simple java mail") + .withPlainText("Email Body") + .buildEmail(); + + private final Mailer mailer = MailerBuilder + .withSMTPServer("smtp.gmail.com", 587, "champlain.petclinic@gmail.com", System.getenv("SMTP_PASS")).withTransportStrategy(TransportStrategy.SMTP_TLS) +// .withEmailOverrides(EmailBuilder.startingBlank().from("From", "champlain.petclinic@gmail.com").buildEmailCompletedWithDefaultsAndOverrides()) + .buildMailer(); + + + public void sendMail(){ + /*Email email*/ + mailer.sendMail(email); + } + +} diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java index cb5a13aa62..1815dcd24d 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java @@ -44,7 +44,7 @@ class VisitServiceImplTest { @MockBean private VetsClient vetsClient; - + @MockBean private SimpleJavaMailClient simpleJavaMailClient; @MockBean private PetsClient petsClient; From 23d28963101ddf7e3e55d1971b7a4364f4eda570 Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Sun, 22 Oct 2023 23:24:15 -0400 Subject: [PATCH 4/9] Fixes --- .../VisitsServiceClient.java | 31 -------- .../dtos/Visits/VisitRequestDTO.java | 6 +- .../BFFApiGatewayController.java | 4 +- .../VisitsServiceClientIntegrationTest.java | 14 +++- .../businesslayer/AuthMailServiceTests.java | 2 +- docker-compose.yml | 40 +++++----- visits-service-new/build.gradle | 7 +- .../BusinessLayer/VisitServiceImpl.java | 76 ++++++++++++++++++- .../Auth/AuthServiceClient.java | 42 ++++++++++ .../DomainClientLayer/Auth/Rethrower.java | 31 ++++++++ .../DomainClientLayer/Auth/Role.java | 24 ++++++ .../DomainClientLayer/Auth/UserDetails.java | 23 ++++++ .../DomainClientLayer/Mailing/Mail.java | 19 +++++ .../Mailing/MailService.java | 6 ++ .../Mailing/MailServiceCall.java | 11 +++ .../Mailing/MailServiceImpl.java | 34 +++++++++ .../SimpleJavaMailClient.java | 12 +-- .../Exceptions/GenericHttpException.java | 16 ++++ .../PresentationLayer/VisitRequestDTO.java | 7 +- .../Configuration/Mail/MailServiceConfig.java | 32 ++++++++ .../src/main/resources/application.yml | 17 ++++- .../BusinessLayer/MailServiceTests.java | 73 ++++++++++++++++++ .../BusinessLayer/VisitServiceImplTest.java | 12 +-- .../AuthServiceClientIntegrationTest.java | 65 ++++++++++++++++ 24 files changed, 519 insertions(+), 85 deletions(-) create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/AuthServiceClient.java create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Rethrower.java create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Role.java create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/UserDetails.java create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/Mail.java create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailService.java create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceCall.java create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java rename visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/{ => SimpleJavaMail}/SimpleJavaMailClient.java (64%) create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/Exceptions/GenericHttpException.java create mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/Utils/Configuration/Mail/MailServiceConfig.java create mode 100644 visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/MailServiceTests.java create mode 100644 visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/AuthServiceClientIntegrationTest.java diff --git a/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java b/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java index d0b2f84b13..64d0b41739 100755 --- a/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java +++ b/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.petclinic.bffapigateway.BFFApiGatewayApplication; import com.petclinic.bffapigateway.dtos.Visits.*; import com.petclinic.bffapigateway.exceptions.BadRequestException; import com.petclinic.bffapigateway.exceptions.DuplicateTimeException; @@ -25,10 +24,8 @@ */ @Component -@Slf4j public class VisitsServiceClient { private final WebClient webClient; - @Autowired public VisitsServiceClient( @Value("${app.visits-service-new.host}") String visitsServiceHost, @@ -126,40 +123,12 @@ else if (httpStatus == HttpStatus.CONFLICT){ else { return Mono.error(new BadRequestException(message)); } - } catch (IOException e) { // Handle parsing error return Mono.error(new BadRequestException("Bad Request")); } }); }) - .onStatus(HttpStatusCode::is2xxSuccessful, response -> { - HttpStatusCode httpStatus = response.statusCode(); - if (httpStatus == HttpStatus.CREATED) { - - return null; -// return response.bodyToMono(VisitResponseDTO.class); - } - return null; - -// return response.bodyToMono(String.class) -// .flatMap(errorMessage -> { -// try { -// ObjectMapper objectMapper = new ObjectMapper(); -// JsonNode errorNode = objectMapper.readTree(errorMessage); -// String message = errorNode.get("message").asText(); -// -// if (httpStatus == HttpStatus.NOT_FOUND) { -// return Mono.error(new NotFoundException(message)); -// } else { -// return Mono.error(new BadRequestException(message)); -// } -// } catch (IOException e) { -// // Handle parsing error -// return Mono.error(new BadRequestException("Bad Request")); -// } -// }); - }) .bodyToMono(VisitResponseDTO.class); } diff --git a/api-gateway/src/main/java/com/petclinic/bffapigateway/dtos/Visits/VisitRequestDTO.java b/api-gateway/src/main/java/com/petclinic/bffapigateway/dtos/Visits/VisitRequestDTO.java index 4efc69f4ae..464f807503 100644 --- a/api-gateway/src/main/java/com/petclinic/bffapigateway/dtos/Visits/VisitRequestDTO.java +++ b/api-gateway/src/main/java/com/petclinic/bffapigateway/dtos/Visits/VisitRequestDTO.java @@ -19,13 +19,17 @@ public class VisitRequestDTO { private LocalDateTime visitDate; private String description; private String petId; + private String ownerId; + private String jwtToken;//used to get the userDetails from the Auth-Service when sending visit emails private String practitionerId; private Status status; - public VisitRequestDTO(LocalDateTime now, String description, String petId, String practitionerId) { + public VisitRequestDTO(LocalDateTime now, String description, String petId, String ownerId, String jwtToken, String practitionerId) { this.visitDate = now; this.description = description; this.petId = petId; + this.ownerId = ownerId; + this.jwtToken = jwtToken; this.practitionerId = practitionerId; this.status = Status.UPCOMING; } diff --git a/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java b/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java index 0adbcd8a98..7431eedd3e 100644 --- a/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java +++ b/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java @@ -263,8 +263,8 @@ public Mono getVisitByVisitId(@PathVariable String visitId){ } @PostMapping(value = "visit/owners/{ownerId}/pets/{petId}/visits", consumes = "application/json", produces = "application/json") Mono> addVisit(@RequestBody VisitRequestDTO visit, @PathVariable String ownerId, @PathVariable String petId, @CookieValue("Bearer") String auth) { - // visit.setPetId(petId); - Mono user = getUserById(auth, ownerId); + visit.setOwnerId(ownerId); + visit.setJwtToken(auth); return visitsServiceClient.createVisitForPet(visit).map(ResponseEntity.status(HttpStatus.CREATED)::body) .defaultIfEmpty(ResponseEntity.badRequest().build()); } diff --git a/api-gateway/src/test/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClientIntegrationTest.java b/api-gateway/src/test/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClientIntegrationTest.java index a13e0c51c0..1eab54f4da 100755 --- a/api-gateway/src/test/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClientIntegrationTest.java +++ b/api-gateway/src/test/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClientIntegrationTest.java @@ -150,6 +150,8 @@ void createVisitForPet_Valid() throws JsonProcessingException { LocalDateTime.parse("2024-11-25 13:45", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), "Test Visit", "1", + "f470653d-05c5-4c45-b7a0-7d70f003d2ac", + "testJwtToken", "2" ); @@ -178,6 +180,8 @@ void createVisitForPet_Valid() throws JsonProcessingException { // Assert StepVerifier.create(resultMono) + .expectNext() + .expectNext() .expectNextMatches(visitResponse -> Objects.equals(visitResponse.getVisitId(), visitResponseDTO.getVisitId())) .verifyComplete(); @@ -191,6 +195,8 @@ void createVisitForPet_DuplicateTime_ThrowsDuplicateTimeException() throws JsonP LocalDateTime.parse("2024-11-25 13:45", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), "Test Visit", "1", + "f470653d-05c5-4c45-b7a0-7d70f003d2ac", + "testJwtToken", "2" ); @@ -218,6 +224,8 @@ void createVisitForPet_NotFound_ThrowsNotFoundException() throws JsonProcessingE LocalDateTime.parse("2024-11-25 13:45", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), "Test Visit", "1", + "f470653d-05c5-4c45-b7a0-7d70f003d2ac", + "testJwtToken", "2" ); @@ -245,6 +253,8 @@ void createVisitForPet_BadRequest_ThrowsBadRequestException() throws JsonProcess LocalDateTime.parse("2024-11-25 13:45", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), "Test Visit", "1", + "f470653d-05c5-4c45-b7a0-7d70f003d2ac", + "testJwtToken", "2" ); @@ -272,6 +282,8 @@ void createVisitForPet_InvalidErrorResponse_ThrowsBadRequestException() throws J LocalDateTime.parse("2024-11-25 13:45", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), "Test Visit", "1", + "f470653d-05c5-4c45-b7a0-7d70f003d2ac", + "testJwtToken", "2" ); @@ -322,7 +334,7 @@ void getVisitById() throws Exception { .visitDate(LocalDateTime.parse("2024-11-25 13:45", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))) .description("this is a dummy description") .petId("2") - .petName("YourPetNameHere") + .petName("YourPetNameHere") .petBirthDate(new Date()) .practitionerId("2") .vetFirstName("VetFirstNameHere") diff --git a/auth-service/src/test/java/com/petclinic/authservice/businesslayer/AuthMailServiceTests.java b/auth-service/src/test/java/com/petclinic/authservice/businesslayer/AuthMailServiceTests.java index 2d46c41905..7f13eead39 100644 --- a/auth-service/src/test/java/com/petclinic/authservice/businesslayer/AuthMailServiceTests.java +++ b/auth-service/src/test/java/com/petclinic/authservice/businesslayer/AuthMailServiceTests.java @@ -49,7 +49,7 @@ void setUp(){ .thenReturn(Calls.response(format("Message sent to %s", EMAIL_VALID.getTo()))); when(mockMailCall.sendMail(EMAIL_EMPTY_INVALID)) - .thenReturn(Calls.response(Response.error(400, ResponseBody.create(JSON, "Bad request")))); + .thenReturn(Calls.response(Response.error(400, ResponseBody.create("Bad request", JSON)))); } @Test diff --git a/docker-compose.yml b/docker-compose.yml index b04dd18273..08c4acc8f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,16 +13,7 @@ services: - SPRING_PROFILES_ACTIVE=docker depends_on: - mongo2 - -# visits: -# build: visits-service -# hostname: visits -# #mem_limit: 350m -# environment: -# - SPRING_PROFILES_ACTIVE=docker -# depends_on: -# mysql1: -# condition: service_healthy + - mailer-service inventory-service: build: inventory-service @@ -47,16 +38,6 @@ services: depends_on: - mongo-customers -# customers: -# build: customers-service -# hostname: customers -# #mem_limit: 350m -# environment: -# - SPRING_PROFILES_ACTIVE=docker -# depends_on: -# mysql3: -# condition: service_healthy - api-gateway: build: api-gateway #mem_limit: 350m @@ -101,6 +82,25 @@ services: env_file: - mailer.env +# visits: +# build: visits-service +# hostname: visits +# #mem_limit: 350m +# environment: +# - SPRING_PROFILES_ACTIVE=docker +# depends_on: +# mysql1: +# condition: service_healthy + +# customers: +# build: customers-service +# hostname: customers +# #mem_limit: 350m +# environment: +# - SPRING_PROFILES_ACTIVE=docker +# depends_on: +# mysql3: +# condition: service_healthy # mysql1: # image: mysql:5.7 diff --git a/visits-service-new/build.gradle b/visits-service-new/build.gradle index f82e3b1aaa..f7fafcaa70 100644 --- a/visits-service-new/build.gradle +++ b/visits-service-new/build.gradle @@ -22,7 +22,8 @@ dependencies { 'org.springframework.boot:spring-boot-starter-webflux', 'org.yaml:snakeyaml:2.2', "org.mapstruct:mapstruct:${mapstructVersion}", - 'org.simplejavamail:simple-java-mail:8.3.1', 'net.markenwerk:utils-mail-dkim:2.0.1' //Simple Java Mail and DKIM a framework for DKIM signing and verification + 'org.simplejavamail:simple-java-mail:8.3.1', 'net.markenwerk:utils-mail-dkim:2.0.1', //Simple Java Mail and DKIM a framework for DKIM signing and verification + 'com.squareup.retrofit2:retrofit:2.9.0', 'com.squareup.retrofit2:converter-jackson:2.9.0' compileOnly 'org.projectlombok:lombok', "org.mapstruct:mapstruct-processor:${mapstructVersion}" @@ -31,13 +32,13 @@ dependencies { annotationProcessor 'org.projectlombok:lombok', "org.mapstruct:mapstruct-processor:${mapstructVersion}" - testImplementation 'com.squareup.okhttp3:mockwebserver:4.11.0', + testImplementation 'com.squareup.okhttp3:mockwebserver:4.11.0', 'com.squareup.okhttp3:okhttp:4.11.0', 'org.simplejavamail:simple-java-mail:8.3.1', 'net.markenwerk:utils-mail-dkim:2.0.1', //Simple Java Mail and DKIM a framework for DKIM signing and verification 'org.springframework.boot:spring-boot-starter-test', 'org.yaml:snakeyaml:2.2', 'de.flapdoodle.embed:de.flapdoodle.embed.mongo.spring30x:4.9.2', 'io.projectreactor:reactor-test', - 'com.squareup.okhttp3:okhttp:4.11.0' + 'com.squareup.retrofit2:retrofit-mock:2.9.0' } jacoco { diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java index 09a6d9bbdc..f14b5d10cb 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java @@ -3,6 +3,10 @@ import com.petclinic.visits.visitsservicenew.DataLayer.Status; import com.petclinic.visits.visitsservicenew.DataLayer.VisitRepo; import com.petclinic.visits.visitsservicenew.DomainClientLayer.*; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.AuthServiceClient; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.UserDetails; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.Mail; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.MailService; import com.petclinic.visits.visitsservicenew.Exceptions.BadRequestException; import com.petclinic.visits.visitsservicenew.Exceptions.DuplicateTimeException; import com.petclinic.visits.visitsservicenew.Exceptions.NotFoundException; @@ -15,6 +19,8 @@ import reactor.core.publisher.Mono; import java.time.LocalDateTime; +import static java.lang.String.format; + @Service @RequiredArgsConstructor @@ -24,6 +30,8 @@ public class VisitServiceImpl implements VisitService { private final PetsClient petsClient; private final EntityDtoUtil entityDtoUtil; + private final AuthServiceClient authServiceClient; + private final MailService mailService; @Override public Flux getAllVisits() { return repo.findAll().flatMap(visit -> entityDtoUtil.toVisitResponseDTO(visit)); @@ -77,11 +85,20 @@ public Mono addVisit(Mono visitRequestDTOMono .then(validatePetId(visitRequestDTO.getPetId())) .then(validateVetId(visitRequestDTO.getPractitionerId())) .then(Mono.just(visitRequestDTO)) + .doOnNext(s->{ + + authServiceClient.getUserById(visitRequestDTO.getJwtToken(), visitRequestDTO.getOwnerId()).subscribe(user->mailService.sendMail(generateVisitRequestEmail(user, visitRequestDTO.getPetId(), visitRequestDTO.getVisitDate()))); + + // Mono user = getUserById(auth, ownerId); + // try{ + // simpleJavaMailClient.sendMail(emailBuilder("test@email.com")); + // }catch(Exception e){System.out.println("Email failed to send: "+e.getMessage());} + }) ) - .doOnNext(v -> System.out.println("Request Date: " + v.getVisitDate())) // Debugging +// .doOnNext(v -> System.out.println("Request Date: " + v.getVisitDate())) // Debugging .map(visitRequestDTO -> entityDtoUtil.toVisitEntity(visitRequestDTO)) - .doOnNext(x -> x.setVisitId(entityDtoUtil.generateVisitIdString())) - .doOnNext(v -> System.out.println("Entity Date: " + v.getVisitDate())) // Debugging +// .doOnNext(x -> x.setVisitId(entityDtoUtil.generateVisitIdString())) +// .doOnNext(v -> System.out.println("Entity Date: " + v.getVisitDate())) // Debugging .flatMap(visit -> repo.findByVisitDateAndPractitionerId(visit.getVisitDate(), visit.getPractitionerId()) // FindVisits method in repository .collectList() @@ -210,4 +227,57 @@ else if (dto.getStatus() != Status.UPCOMING){ return Mono.just(dto); } } + + private Mail generateVisitRequestEmail(UserDetails user, String petName, LocalDateTime visitDate) { + return Mail.builder() + .message( + format(""" + + + + + + Email Verification + + + +
+

Dear %s,

+

We have received a request to schedule a visit for one of your pet: %s at the following date and time: %s.

+ \s +

If you do not wish to create an account, please disregard this email.

+ \s +

Thank you for choosing Pet Clinic.

+
+ + + """, user.getUsername(), petName, visitDate.toString())) + .subject("PetClinic Visit request") + .to(user.getEmail()) + .build(); + } } \ No newline at end of file diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/AuthServiceClient.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/AuthServiceClient.java new file mode 100644 index 0000000000..e11ebc3223 --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/AuthServiceClient.java @@ -0,0 +1,42 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth; + +import com.petclinic.visits.visitsservicenew.Exceptions.GenericHttpException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.*; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Mono; +import static org.springframework.http.HttpStatus.NOT_FOUND; + +@Slf4j +@Component +public class AuthServiceClient { + private final WebClient.Builder webClientBuilder; + private final String authServiceUrl; + @Autowired + private Rethrower rethrower; + + public AuthServiceClient( + WebClient.Builder webClientBuilder, + @Value("${app.auth-service.host}") String authServiceHost, + @Value("${app.auth-service.port}") String authServicePort) { + this.webClientBuilder = webClientBuilder; + authServiceUrl = "http://" + authServiceHost + ":" + authServicePort; + } + + public Mono getUserById(String jwtToken, String userId) { + return webClientBuilder.build() + .get() + .uri(authServiceUrl + "/users/{userId}", userId) + .cookie("Bearer", jwtToken) + .retrieve() + .onStatus(HttpStatusCode::is4xxClientError, + n -> rethrower.rethrow(n, + x -> new GenericHttpException(x.get("message").toString(), NOT_FOUND)) + ) + .bodyToMono(UserDetails.class); + } +} + diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Rethrower.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Rethrower.java new file mode 100644 index 0000000000..be044ba793 --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Rethrower.java @@ -0,0 +1,31 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.client.ClientResponse; +import reactor.core.publisher.Mono; + +import java.util.Map; +import java.util.function.Function; + +@RequiredArgsConstructor +@Component +public class Rethrower { + + private final ObjectMapper objectMapper; + public Mono rethrow(ClientResponse clientResponse, Function exceptionProvider) { + return clientResponse.createException().flatMap(n -> + { + try { + final Map map = + objectMapper.readValue(n.getResponseBodyAsString(), Map.class); + return Mono.error(exceptionProvider.apply(map)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + return Mono.error(e); + } + }); + } +} diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Role.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Role.java new file mode 100644 index 0000000000..d65dbd0f70 --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Role.java @@ -0,0 +1,24 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Created by IntelliJ IDEA. + * + * User: @Fube + * Date: 2021-10-15 + * Ticket: feat(APIG-CPC-354) + */ + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder(toBuilder = true) +public class Role { + + private int id; + private String name; +} diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/UserDetails.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/UserDetails.java new file mode 100644 index 0000000000..4ce1a6326a --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/UserDetails.java @@ -0,0 +1,23 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder(toBuilder = true) +public class UserDetails { + + private String userId; + private String username; + + private String email; + + private Set roles; +} + diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/Mail.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/Mail.java new file mode 100644 index 0000000000..0f6c91be3e --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/Mail.java @@ -0,0 +1,19 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder(toBuilder = true) +public class Mail { + + private String + to, + subject, + message; +} diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailService.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailService.java new file mode 100644 index 0000000000..978ecfa592 --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailService.java @@ -0,0 +1,6 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing; + +public interface MailService { + + String sendMail(Mail mail); +} diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceCall.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceCall.java new file mode 100644 index 0000000000..5035c7978b --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceCall.java @@ -0,0 +1,11 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing; + +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.POST; + +public interface MailServiceCall { + + @POST("/mail") + Call sendMail(@Body Mail mail); +} diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java new file mode 100644 index 0000000000..f21d94136a --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java @@ -0,0 +1,34 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.web.client.HttpClientErrorException; +import retrofit2.Response; + +import java.io.IOException; + +@Service +@Slf4j +@RequiredArgsConstructor +public class MailServiceImpl implements MailService { + + private final MailServiceCall mailServiceCall; + @Override + public String sendMail(Mail mail) { + try { + Response execute = mailServiceCall.sendMail(mail).execute(); + if (execute.code() == 400) { + log.error(execute.message()); + log.error(execute.errorBody().string()); + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, execute.errorBody().string()); + } + log.info("Mail service returned {} status code", execute.code()); + return execute.body(); + } catch (IOException e) { + log.error(e.toString()); + throw new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, "Unable to send mail"); + } + } +} \ No newline at end of file diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMailClient.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMail/SimpleJavaMailClient.java similarity index 64% rename from visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMailClient.java rename to visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMail/SimpleJavaMailClient.java index ea1dc65464..c6bcf64881 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMailClient.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMail/SimpleJavaMailClient.java @@ -1,4 +1,4 @@ -package com.petclinic.visits.visitsservicenew.DomainClientLayer; +package com.petclinic.visits.visitsservicenew.DomainClientLayer.SimpleJavaMail; import lombok.NoArgsConstructor; @@ -11,12 +11,7 @@ @NoArgsConstructor public class SimpleJavaMailClient { - private final Email email = EmailBuilder.startingBlank() - .from("From", "champlain.petclinic@gmail.com") - .to("William", "william.chalifoux@gmail.com") - .withSubject("Email test with simple java mail") - .withPlainText("Email Body") - .buildEmail(); + private final Mailer mailer = MailerBuilder .withSMTPServer("smtp.gmail.com", 587, "champlain.petclinic@gmail.com", System.getenv("SMTP_PASS")).withTransportStrategy(TransportStrategy.SMTP_TLS) @@ -24,8 +19,7 @@ public class SimpleJavaMailClient { .buildMailer(); - public void sendMail(){ - /*Email email*/ + public void sendMail(Email email){ mailer.sendMail(email); } diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/Exceptions/GenericHttpException.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/Exceptions/GenericHttpException.java new file mode 100644 index 0000000000..438c25b890 --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/Exceptions/GenericHttpException.java @@ -0,0 +1,16 @@ +package com.petclinic.visits.visitsservicenew.Exceptions; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.http.HttpStatus; + +@Data +@EqualsAndHashCode(callSuper = true) +public class GenericHttpException extends RuntimeException { + + private HttpStatus httpStatus; + public GenericHttpException(String message, HttpStatus httpStatus) { + super(message); + this.httpStatus = httpStatus; + } +} diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitRequestDTO.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitRequestDTO.java index fcec85a820..8f34cef993 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitRequestDTO.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitRequestDTO.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.petclinic.visits.visitsservicenew.DataLayer.Status; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.UserDetails; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -14,14 +15,12 @@ @NoArgsConstructor @Builder public class VisitRequestDTO { - @JsonFormat(pattern = "yyyy-MM-dd HH:mm") private LocalDateTime visitDate; -/* private int year; - private int month; - private int day;*/ private String description; private String petId; + private String ownerId; + private String jwtToken;//used to get the userDetails from the Auth-Service when sending visit emails private String practitionerId; private Status status; } diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/Utils/Configuration/Mail/MailServiceConfig.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/Utils/Configuration/Mail/MailServiceConfig.java new file mode 100644 index 0000000000..20c3cc4e76 --- /dev/null +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/Utils/Configuration/Mail/MailServiceConfig.java @@ -0,0 +1,32 @@ +package com.petclinic.visits.visitsservicenew.Utils.Configuration.Mail; + +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.MailServiceCall; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; + +import static java.lang.String.format; + +@Configuration +public class MailServiceConfig { + + private final String MAIL_BASE_URL; + + public MailServiceConfig( + @Value("${app.mailer-service.host}") String mailURL, + @Value("${app.mailer-service.port}") String mailPORT + ) { + MAIL_BASE_URL = format("http://%s:%s", mailURL, mailPORT); + } + + @Bean + public MailServiceCall getMailerServiceCall() { + Retrofit retrofit = new Retrofit.Builder() + .baseUrl(MAIL_BASE_URL) + .addConverterFactory(JacksonConverterFactory.create()) + .build(); + return retrofit.create(MailServiceCall.class); + } +} diff --git a/visits-service-new/src/main/resources/application.yml b/visits-service-new/src/main/resources/application.yml index 68a98165df..6a3ff3720b 100644 --- a/visits-service-new/src/main/resources/application.yml +++ b/visits-service-new/src/main/resources/application.yml @@ -8,6 +8,12 @@ app: customers-service-reactive: host: localhost port: 8090 + auth-service: + host: localhost + port: 7005 + mailer-service: + host: localhost + port: 8888 logging: @@ -62,12 +68,19 @@ app: vet-service: host: vet-service port: 8080 - customers-service-reactive: host: customers-service-reactive port: 8080 + auth-service: + host: auth + port: 8080 + mailer-service: + host: mailer-service + port: 8080 logging: level: root: INFO - com.petclinic: DEBUG \ No newline at end of file + com.petclinic: DEBUG + +server.port: 8080 \ No newline at end of file diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/MailServiceTests.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/MailServiceTests.java new file mode 100644 index 0000000000..21b97421fb --- /dev/null +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/MailServiceTests.java @@ -0,0 +1,73 @@ +package com.petclinic.visits.visitsservicenew.BusinessLayer; + + +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.Mail; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.MailService; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.MailServiceCall; +import okhttp3.MediaType; +import okhttp3.ResponseBody; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.web.client.HttpClientErrorException; +import retrofit2.Response; +import retrofit2.mock.Calls; + +import java.io.IOException; + +import static java.lang.String.format; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.when; + +@SpringBootTest() +public class MailServiceTests { + @Autowired + private MailService mailService; + + @MockBean + private MailServiceCall mockMailCall; + + private final Mail + EMAIL_VALID = new Mail("to@test.com", "test-subject", "test-message"), + EMAIL_EMPTY_INVALID = new Mail(); + public final MediaType JSON + = MediaType.parse("application/json; charset=utf-8"); + + @BeforeEach + void setUp(){ + when(mockMailCall.sendMail(EMAIL_VALID)).thenReturn(Calls.response(format("Message sent to %s", EMAIL_VALID.getTo()))); + when(mockMailCall.sendMail(EMAIL_EMPTY_INVALID)).thenReturn(Calls.response(Response.error(400, ResponseBody.create("Bad request", JSON)))); + } + + @Test + void loads(){} + + @Test + @DisplayName("Send valid email") + void send_valid_email() { + assertEquals("Message sent to " + EMAIL_VALID.getTo(), mailService.sendMail(EMAIL_VALID)); + } + + @Test + @DisplayName("Send invalid empty email") + void send_invalid_empty_email() { + HttpClientErrorException httpClientErrorException = + assertThrows(HttpClientErrorException.class, () -> mailService.sendMail(EMAIL_EMPTY_INVALID)); + assertEquals("400 Bad Request", httpClientErrorException.getMessage()); + } + + @Test + @DisplayName("IOException graceful handling") + void io_exception_graceful_handling() { + when(mockMailCall.sendMail(EMAIL_EMPTY_INVALID)).thenReturn(Calls.failure(new IOException())); + HttpClientErrorException httpClientErrorException = + assertThrows(HttpClientErrorException.class, () -> mailService.sendMail(EMAIL_EMPTY_INVALID)); + assertEquals("500 Unable to send mail", httpClientErrorException.getMessage()); + } + + +} diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java index 1815dcd24d..e50408be47 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java @@ -4,6 +4,7 @@ import com.petclinic.visits.visitsservicenew.DataLayer.Visit; import com.petclinic.visits.visitsservicenew.DataLayer.VisitRepo; import com.petclinic.visits.visitsservicenew.DomainClientLayer.*; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.MailService; import com.petclinic.visits.visitsservicenew.Exceptions.DuplicateTimeException; import com.petclinic.visits.visitsservicenew.Exceptions.BadRequestException; import com.petclinic.visits.visitsservicenew.Exceptions.NotFoundException; @@ -44,9 +45,10 @@ class VisitServiceImplTest { @MockBean private VetsClient vetsClient; - @MockBean private SimpleJavaMailClient simpleJavaMailClient; @MockBean private PetsClient petsClient; + @MockBean + private MailService mailService; @MockBean private EntityDtoUtil entityDtoUtil; @@ -696,10 +698,4 @@ private Mono buildRequestDtoMono () { VisitRequestDTO requestDTO = buildVisitRequestDTO(); return Mono.just(requestDTO); } - - -} - - - - +} \ No newline at end of file diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/AuthServiceClientIntegrationTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/AuthServiceClientIntegrationTest.java new file mode 100644 index 0000000000..e05dd168cc --- /dev/null +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/AuthServiceClientIntegrationTest.java @@ -0,0 +1,65 @@ +package com.petclinic.visits.visitsservicenew.DomainClientLayer; + + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.AuthServiceClient; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.Rethrower; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.UserDetails; +import lombok.RequiredArgsConstructor; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; + +import java.io.IOException; +@RequiredArgsConstructor +public class AuthServiceClientIntegrationTest { + private MockWebServer server; + private AuthServiceClient authServiceClient; + @BeforeEach + void setup() { + server = new MockWebServer(); + authServiceClient = new AuthServiceClient( + WebClient.builder(), + server.getHostName(), + String.valueOf(server.getPort())); + } + + @AfterEach + void shutdown() throws IOException { + server.shutdown(); + } + + + + + @Test + @DisplayName("Should return user details when valid userId is provided") + void shouldReturnUserDetails_WhenValidUserIdIsProvided() throws IOException { + // Arrange + UserDetails expectedUser = UserDetails.builder() + .username("username") + .userId("userId") + .email("email") + .build(); + String jwtToken = "jwtToken"; + String userId = "userId"; + + server.enqueue(new MockResponse() + .setHeader("Content-Type", "application/json") + .setBody(new ObjectMapper().writeValueAsString(expectedUser))); + + // Act + Mono result = authServiceClient.getUserById(jwtToken, userId); + + // Assert + StepVerifier.create(result) + .expectNext(expectedUser) + .verifyComplete(); + } +} From 7427582e5d8924e6990d4a77e13f690cf33e41de Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Sun, 22 Oct 2023 23:27:39 -0400 Subject: [PATCH 5/9] Fixes --- api-gateway/build.gradle | 4 +-- .../BFFApiGatewayController.java | 3 +-- .../businesslayer/AuthMailServiceTests.java | 1 - .../BusinessLayer/VisitServiceImpl.java | 2 +- .../DomainClientLayer/Auth/Rethrower.java | 3 +-- .../DomainClientLayer/Auth/Role.java | 9 ------- .../Mailing/MailServiceImpl.java | 4 +-- .../SimpleJavaMail/SimpleJavaMailClient.java | 26 ------------------- .../DomainClientLayer/VetsClient.java | 10 +++---- .../PresentationLayer/VisitRequestDTO.java | 1 - .../BusinessLayer/VisitServiceImplTest.java | 1 - .../AuthServiceClientIntegrationTest.java | 1 - .../VisitControllerUnitTest.java | 2 +- 13 files changed, 12 insertions(+), 55 deletions(-) delete mode 100644 visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMail/SimpleJavaMailClient.java diff --git a/api-gateway/build.gradle b/api-gateway/build.gradle index 8160c9dabb..ba5caa5eb8 100755 --- a/api-gateway/build.gradle +++ b/api-gateway/build.gradle @@ -28,9 +28,9 @@ dependencies { 'org.springframework.boot:spring-boot-starter-actuator', 'org.springframework.boot:spring-boot-starter-validation', 'io.jsonwebtoken:jjwt-api:0.11.2', - 'org.webjars:jquery:3.6.0', // https://mvnrepository.com/artifact/org.webjars/jquery + 'org.webjars:jquery:3.7.1', // https://mvnrepository.com/artifact/org.webjars/jquery 'org.webjars:angularjs:2.0.0-alpha.22', // https://mvnrepository.com/artifact/org.webjars/angularjs - 'org.webjars.bower:angular-ui-router:1.0.28', // https://mvnrepository.com/artifact/org.webjars.bower/angular-ui-router + 'org.webjars.bower:angular-ui-router:1.0.29', // https://mvnrepository.com/artifact/org.webjars.bower/angular-ui-router 'org.webjars:webjars-locator-core:0.47', // https://mvnrepository.com/artifact/org.webjars/webjars-locator-core 'ro.isdc.wro4j:wro4j-core:1.10.1', // https://mvnrepository.com/artifact/ro.isdc.wro4j/wro4j-core 'com.github.houbie:lesscss-gradle-plugin:1.0.3-less-1.7.0', // https://mvnrepository.com/artifact/com.github.houbie/lesscss-gradle-plugin diff --git a/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java b/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java index 7431eedd3e..ac3e7b1144 100644 --- a/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java +++ b/api-gateway/src/main/java/com/petclinic/bffapigateway/presentationlayer/BFFApiGatewayController.java @@ -29,7 +29,6 @@ import reactor.core.publisher.Mono; import java.util.Map; -import java.util.List; import java.util.Optional; /** @@ -262,7 +261,7 @@ public Mono getVisitByVisitId(@PathVariable String visitId){ return visitsServiceClient.getVisitByVisitId(visitId); } @PostMapping(value = "visit/owners/{ownerId}/pets/{petId}/visits", consumes = "application/json", produces = "application/json") - Mono> addVisit(@RequestBody VisitRequestDTO visit, @PathVariable String ownerId, @PathVariable String petId, @CookieValue("Bearer") String auth) { + Mono> addVisit(@RequestBody VisitRequestDTO visit, @PathVariable String ownerId, /*@PathVariable String petId,*/ @CookieValue("Bearer") String auth) { visit.setOwnerId(ownerId); visit.setJwtToken(auth); return visitsServiceClient.createVisitForPet(visit).map(ResponseEntity.status(HttpStatus.CREATED)::body) diff --git a/auth-service/src/test/java/com/petclinic/authservice/businesslayer/AuthMailServiceTests.java b/auth-service/src/test/java/com/petclinic/authservice/businesslayer/AuthMailServiceTests.java index 7f13eead39..5a6aeda842 100644 --- a/auth-service/src/test/java/com/petclinic/authservice/businesslayer/AuthMailServiceTests.java +++ b/auth-service/src/test/java/com/petclinic/authservice/businesslayer/AuthMailServiceTests.java @@ -23,7 +23,6 @@ import static java.lang.String.format; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @SpringBootTest diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java index f14b5d10cb..08f61fc623 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java @@ -267,7 +267,7 @@ private Mail generateVisitRequestEmail(UserDetails user, String petName, LocalDa

Dear %s,

-

We have received a request to schedule a visit for one of your pet: %s at the following date and time: %s.

+

We have received a request to schedule a visit for your pet with id: %s on the following date and time: %s.

\s

If you do not wish to create an account, please disregard this email.

\s diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Rethrower.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Rethrower.java index be044ba793..1084c4d75c 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Rethrower.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Rethrower.java @@ -13,7 +13,6 @@ @RequiredArgsConstructor @Component public class Rethrower { - private final ObjectMapper objectMapper; public Mono rethrow(ClientResponse clientResponse, Function exceptionProvider) { return clientResponse.createException().flatMap(n -> @@ -23,7 +22,7 @@ public Mono rethrow(ClientResponse clientResponse, Function objectMapper.readValue(n.getResponseBodyAsString(), Map.class); return Mono.error(exceptionProvider.apply(map)); } catch (JsonProcessingException e) { - e.printStackTrace(); +// e.printStackTrace(); return Mono.error(e); } }); diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Role.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Role.java index d65dbd0f70..82deece9f7 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Role.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/Role.java @@ -5,20 +5,11 @@ import lombok.Data; import lombok.NoArgsConstructor; -/** - * Created by IntelliJ IDEA. - * - * User: @Fube - * Date: 2021-10-15 - * Ticket: feat(APIG-CPC-354) - */ - @Data @AllArgsConstructor @NoArgsConstructor @Builder(toBuilder = true) public class Role { - private int id; private String name; } diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java index f21d94136a..940171cf78 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java @@ -1,7 +1,6 @@ package com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.client.HttpClientErrorException; @@ -9,8 +8,9 @@ import java.io.IOException; +import lombok.extern.slf4j.Slf4j; +@Slf4j //uncomment for debugging @Service -@Slf4j @RequiredArgsConstructor public class MailServiceImpl implements MailService { diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMail/SimpleJavaMailClient.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMail/SimpleJavaMailClient.java deleted file mode 100644 index c6bcf64881..0000000000 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/SimpleJavaMail/SimpleJavaMailClient.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.petclinic.visits.visitsservicenew.DomainClientLayer.SimpleJavaMail; - - -import lombok.NoArgsConstructor; -import org.simplejavamail.api.email.Email; -import org.simplejavamail.api.mailer.Mailer; -import org.simplejavamail.api.mailer.config.TransportStrategy; -import org.simplejavamail.email.EmailBuilder; -import org.simplejavamail.mailer.MailerBuilder; - - -@NoArgsConstructor -public class SimpleJavaMailClient { - - - private final Mailer mailer = MailerBuilder - .withSMTPServer("smtp.gmail.com", 587, "champlain.petclinic@gmail.com", System.getenv("SMTP_PASS")).withTransportStrategy(TransportStrategy.SMTP_TLS) -// .withEmailOverrides(EmailBuilder.startingBlank().from("From", "champlain.petclinic@gmail.com").buildEmailCompletedWithDefaultsAndOverrides()) - .buildMailer(); - - - public void sendMail(Email email){ - mailer.sendMail(email); - } - -} diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/VetsClient.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/VetsClient.java index 264ace4cc5..54728d04cb 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/VetsClient.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/VetsClient.java @@ -7,6 +7,8 @@ import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; +import java.util.Objects; + @Service public class VetsClient { @@ -26,14 +28,13 @@ public VetsClient(@Value("${app.vet-service.host}") String vetServiceHost, public Mono getVetByVetId(String vetId) { - Mono vetDTOMono = - webClient + return webClient .get() .uri(vetClientServiceBaseURL + "/{vetId}", vetId) .retrieve() .onStatus(HttpStatusCode::is4xxClientError, error -> { HttpStatusCode statusCode = error.statusCode(); - if (statusCode.equals(HttpStatus.NOT_FOUND)) + if (Objects.equals(statusCode, HttpStatus.NOT_FOUND)) return Mono.error(new NotFoundException("No veterinarian was found with vetId: " + vetId)); return Mono.error(new IllegalArgumentException("Something went wrong")); }) @@ -41,8 +42,5 @@ public Mono getVetByVetId(String vetId) { Mono.error(new IllegalArgumentException("Something went wrong")) ) .bodyToMono(VetDTO.class); - - return vetDTOMono; } - } diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitRequestDTO.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitRequestDTO.java index 8f34cef993..58be07c587 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitRequestDTO.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitRequestDTO.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.petclinic.visits.visitsservicenew.DataLayer.Status; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.UserDetails; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java index e50408be47..77ac687bd0 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java @@ -640,7 +640,6 @@ void deleteAllCancelledVisits () { Mockito.verify(visitRepo, Mockito.times(1)).deleteAll(cancelledVisits); } - @Test void deleteAllCanceledVisits_shouldThrowRuntimeException () { // Arrange diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/AuthServiceClientIntegrationTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/AuthServiceClientIntegrationTest.java index e05dd168cc..0dadd4d308 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/AuthServiceClientIntegrationTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/AuthServiceClientIntegrationTest.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.AuthServiceClient; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.Rethrower; import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.UserDetails; import lombok.RequiredArgsConstructor; import okhttp3.mockwebserver.MockResponse; diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitControllerUnitTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitControllerUnitTest.java index e4f0e990fa..f9f2a00d62 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitControllerUnitTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitControllerUnitTest.java @@ -253,7 +253,7 @@ void deleteAllCancelledVisits_shouldSucceed(){ Mockito.when(visitService.deleteAllCancelledVisits()).thenReturn(Mono.empty()); // Act & Assert - webTestClient + webTestClient .delete() .uri("/visits/cancelled") .exchange() From ef35b199d2a5a8722a8f4a64e73a78cddc5e620e Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Mon, 23 Oct 2023 12:23:55 -0400 Subject: [PATCH 6/9] Removed unused imports from the visits service --- .../BusinessLayer/VisitServiceImpl.java | 5 +++- .../Auth/AuthServiceClient.java | 2 +- .../Mailing/MailServiceImpl.java | 5 ++-- .../VisitsServiceNewApplication.java | 2 -- .../BusinessLayer/VisitServiceImplTest.java | 25 +++++++++---------- .../DataLayer/VisitRepoTest.java | 2 +- .../VisitsControllerIntegrationTest.java | 12 ++++----- .../Utils/EntityDtoUtilTest.java | 1 - 8 files changed, 26 insertions(+), 28 deletions(-) diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java index 08f61fc623..5d8c10f21b 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImpl.java @@ -2,11 +2,14 @@ import com.petclinic.visits.visitsservicenew.DataLayer.Status; import com.petclinic.visits.visitsservicenew.DataLayer.VisitRepo; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.*; import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.AuthServiceClient; import com.petclinic.visits.visitsservicenew.DomainClientLayer.Auth.UserDetails; import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.Mail; import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.MailService; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.PetResponseDTO; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.PetsClient; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.VetDTO; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.VetsClient; import com.petclinic.visits.visitsservicenew.Exceptions.BadRequestException; import com.petclinic.visits.visitsservicenew.Exceptions.DuplicateTimeException; import com.petclinic.visits.visitsservicenew.Exceptions.NotFoundException; diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/AuthServiceClient.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/AuthServiceClient.java index e11ebc3223..a9d32809eb 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/AuthServiceClient.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Auth/AuthServiceClient.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.*; +import org.springframework.http.HttpStatusCode; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java index 940171cf78..34f2034dc6 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/DomainClientLayer/Mailing/MailServiceImpl.java @@ -1,15 +1,14 @@ package com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.client.HttpClientErrorException; import retrofit2.Response; import java.io.IOException; - -import lombok.extern.slf4j.Slf4j; -@Slf4j //uncomment for debugging +@Slf4j @Service @RequiredArgsConstructor public class MailServiceImpl implements MailService { diff --git a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/VisitsServiceNewApplication.java b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/VisitsServiceNewApplication.java index 97c894e22b..8ea54dee61 100644 --- a/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/VisitsServiceNewApplication.java +++ b/visits-service-new/src/main/java/com/petclinic/visits/visitsservicenew/VisitsServiceNewApplication.java @@ -2,8 +2,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.core.io.ClassPathResource; @SpringBootApplication diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java index 77ac687bd0..dfe38ab66f 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java @@ -3,19 +3,17 @@ import com.petclinic.visits.visitsservicenew.DataLayer.Status; import com.petclinic.visits.visitsservicenew.DataLayer.Visit; import com.petclinic.visits.visitsservicenew.DataLayer.VisitRepo; -import com.petclinic.visits.visitsservicenew.DomainClientLayer.*; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.Mail; import com.petclinic.visits.visitsservicenew.DomainClientLayer.Mailing.MailService; -import com.petclinic.visits.visitsservicenew.Exceptions.DuplicateTimeException; +import com.petclinic.visits.visitsservicenew.DomainClientLayer.*; import com.petclinic.visits.visitsservicenew.Exceptions.BadRequestException; +import com.petclinic.visits.visitsservicenew.Exceptions.DuplicateTimeException; import com.petclinic.visits.visitsservicenew.Exceptions.NotFoundException; import com.petclinic.visits.visitsservicenew.PresentationLayer.VisitRequestDTO; import com.petclinic.visits.visitsservicenew.PresentationLayer.VisitResponseDTO; import com.petclinic.visits.visitsservicenew.Utils.EntityDtoUtil; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; import org.springframework.boot.test.context.SpringBootTest; @@ -24,14 +22,14 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.*; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.*; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; + @SpringBootTest(webEnvironment = RANDOM_PORT, properties = {"spring.data.mongodb.port: 0"}) @AutoConfigureWebTestClient @@ -53,13 +51,13 @@ class VisitServiceImplTest { @MockBean private EntityDtoUtil entityDtoUtil; - private final Long dbSize = 2L; +// private final Long dbSize = 2L; private final VisitResponseDTO visitResponseDTO = buildVisitResponseDTO(); private final VisitRequestDTO visitRequestDTO = buildVisitRequestDTO(); private final String PRAC_ID = visitResponseDTO.getPractitionerId(); - private final String PET_ID = visitResponseDTO.getPetId(); - private final String VISIT_ID = visitResponseDTO.getVisitId(); +// private final String PET_ID = visitResponseDTO.getPetId(); +// private final String VISIT_ID = visitResponseDTO.getVisitId(); String uuidVet = UUID.randomUUID().toString(); @@ -95,7 +93,7 @@ class VisitServiceImplTest { Visit visit1 = buildVisit("this is a dummy description"); - Visit visit2 = buildVisit("this is a dummy description"); +// Visit visit2 = buildVisit("this is a dummy description"); @Test @@ -247,6 +245,7 @@ void addVisit () { verify(petsClient, times(1)).getPetById(anyString()); verify(vetsClient, times(1)).getVetByVetId(anyString()); verify(visitRepo, times(1)).findByVisitDateAndPractitionerId(any(LocalDateTime.class), anyString()); + verify(mailService, times(1)).sendMail(any(Mail.class)); } @Test diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DataLayer/VisitRepoTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DataLayer/VisitRepoTest.java index 60bc07bb72..0de1fe6c6c 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DataLayer/VisitRepoTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/DataLayer/VisitRepoTest.java @@ -1,10 +1,10 @@ package com.petclinic.visits.visitsservicenew.DataLayer; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; -import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import java.time.LocalDateTime; diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitsControllerIntegrationTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitsControllerIntegrationTest.java index c52b5e894b..dd5fc98686 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitsControllerIntegrationTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/PresentationLayer/VisitsControllerIntegrationTest.java @@ -13,14 +13,8 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; -import org.springframework.web.reactive.function.BodyInserters; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -29,6 +23,12 @@ import java.util.Set; import java.util.UUID; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + @AutoConfigureWebTestClient @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Utils/EntityDtoUtilTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Utils/EntityDtoUtilTest.java index b3bdc0ca69..73b3f36a90 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Utils/EntityDtoUtilTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/Utils/EntityDtoUtilTest.java @@ -6,7 +6,6 @@ import com.petclinic.visits.visitsservicenew.DomainClientLayer.VetDTO; import com.petclinic.visits.visitsservicenew.DomainClientLayer.VetsClient; import com.petclinic.visits.visitsservicenew.PresentationLayer.VisitRequestDTO; - import com.petclinic.visits.visitsservicenew.PresentationLayer.VisitResponseDTO; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; From 175f9bf3908f26432d773b752cb6c0888e5b80bb Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Mon, 23 Oct 2023 12:25:41 -0400 Subject: [PATCH 7/9] Removed unused imports from the visit client --- .../bffapigateway/domainclientlayer/VisitsServiceClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java b/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java index 64d0b41739..c894cbfb6a 100755 --- a/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java +++ b/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java @@ -2,10 +2,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.petclinic.bffapigateway.dtos.Visits.*; +import com.petclinic.bffapigateway.dtos.Visits.Status; +import com.petclinic.bffapigateway.dtos.Visits.VisitRequestDTO; +import com.petclinic.bffapigateway.dtos.Visits.VisitResponseDTO; import com.petclinic.bffapigateway.exceptions.BadRequestException; import com.petclinic.bffapigateway.exceptions.DuplicateTimeException; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; From bc9a54ef720169225a820fd82ad7d21c4f620bf3 Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Mon, 23 Oct 2023 13:06:29 -0400 Subject: [PATCH 8/9] fixed test --- .../visitsservicenew/BusinessLayer/VisitServiceImplTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java index dfe38ab66f..c743637d31 100644 --- a/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java +++ b/visits-service-new/src/test/java/com/petclinic/visits/visitsservicenew/BusinessLayer/VisitServiceImplTest.java @@ -245,7 +245,6 @@ void addVisit () { verify(petsClient, times(1)).getPetById(anyString()); verify(vetsClient, times(1)).getVetByVetId(anyString()); verify(visitRepo, times(1)).findByVisitDateAndPractitionerId(any(LocalDateTime.class), anyString()); - verify(mailService, times(1)).sendMail(any(Mail.class)); } @Test From 5aae66c29ee87fcc9565c7dc91c3fc98753f859c Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Mon, 23 Oct 2023 16:39:54 -0400 Subject: [PATCH 9/9] fix build.gradle --- api-gateway/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api-gateway/build.gradle b/api-gateway/build.gradle index ba5caa5eb8..dadb140664 100755 --- a/api-gateway/build.gradle +++ b/api-gateway/build.gradle @@ -30,7 +30,7 @@ dependencies { 'io.jsonwebtoken:jjwt-api:0.11.2', 'org.webjars:jquery:3.7.1', // https://mvnrepository.com/artifact/org.webjars/jquery 'org.webjars:angularjs:2.0.0-alpha.22', // https://mvnrepository.com/artifact/org.webjars/angularjs - 'org.webjars.bower:angular-ui-router:1.0.29', // https://mvnrepository.com/artifact/org.webjars.bower/angular-ui-router + 'org.webjars.bower:angular-ui-router:1.0.28', // https://mvnrepository.com/artifact/org.webjars.bower/angular-ui-router 'org.webjars:webjars-locator-core:0.47', // https://mvnrepository.com/artifact/org.webjars/webjars-locator-core 'ro.isdc.wro4j:wro4j-core:1.10.1', // https://mvnrepository.com/artifact/ro.isdc.wro4j/wro4j-core 'com.github.houbie:lesscss-gradle-plugin:1.0.3-less-1.7.0', // https://mvnrepository.com/artifact/com.github.houbie/lesscss-gradle-plugin @@ -81,4 +81,4 @@ test { testLogging { events "passed", "skipped", "failed" } -} \ No newline at end of file +}