From 56a7cc819bb243127245ba9cfa14d95e4eac7271 Mon Sep 17 00:00:00 2001 From: William Chalifoux Date: Sun, 22 Oct 2023 23:27:39 -0400 Subject: [PATCH] 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 9d52aeeb11..77ccc5cb76 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 @@ -30,7 +30,6 @@ import reactor.core.publisher.Mono; import java.util.Map; -import java.util.List; import java.util.Optional; /** @@ -263,7 +262,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 07f994e823..b61955fdbd 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 @@ -645,7 +645,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()