From 537b0f2fda617485ff543e049a3ad80034975af5 Mon Sep 17 00:00:00 2001 From: Nenad Jeckovic Date: Fri, 8 Mar 2024 15:34:44 +0100 Subject: [PATCH] Fix sonar cloud code smells --- .../java/com/productdock/adapter/in/web/DeleteBookApi.java | 2 +- .../adapter/out/kafka/DeletedBookMessagePublisher.java | 4 ---- .../port/out/messaging/DeleteBookMessagingOutPort.java | 1 - .../productdock/application/service/DeleteBookService.java | 3 +-- .../com/productdock/adapter/in/web/DeleteBookApiShould.java | 2 +- .../application/service/DeleteBookServiceShould.java | 2 +- 6 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/productdock/adapter/in/web/DeleteBookApi.java b/src/main/java/com/productdock/adapter/in/web/DeleteBookApi.java index 0920f34..c728684 100644 --- a/src/main/java/com/productdock/adapter/in/web/DeleteBookApi.java +++ b/src/main/java/com/productdock/adapter/in/web/DeleteBookApi.java @@ -13,7 +13,7 @@ public record DeleteBookApi(DeleteBookUseCase deleteBookUseCase) { @DeleteMapping("/{bookId}") - public void DeleteBook(@PathVariable("bookId") Long bookId){ + public void deleteBook(@PathVariable("bookId") Long bookId){ log.debug("DELETE request recieved with book id: {}", bookId); deleteBookUseCase.deleteBook(bookId); } diff --git a/src/main/java/com/productdock/adapter/out/kafka/DeletedBookMessagePublisher.java b/src/main/java/com/productdock/adapter/out/kafka/DeletedBookMessagePublisher.java index 4c7cb1f..ed91357 100644 --- a/src/main/java/com/productdock/adapter/out/kafka/DeletedBookMessagePublisher.java +++ b/src/main/java/com/productdock/adapter/out/kafka/DeletedBookMessagePublisher.java @@ -1,13 +1,9 @@ package com.productdock.adapter.out.kafka; import com.fasterxml.jackson.core.JsonProcessingException; -import com.productdock.adapter.out.kafka.mapper.AddedBookMessageMapper; import com.productdock.adapter.out.kafka.publisher.KafkaPublisher; -import com.productdock.application.port.out.messaging.BookCatalogMessagingOutPort; import com.productdock.application.port.out.messaging.DeleteBookMessagingOutPort; -import com.productdock.domain.Book; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/com/productdock/application/port/out/messaging/DeleteBookMessagingOutPort.java b/src/main/java/com/productdock/application/port/out/messaging/DeleteBookMessagingOutPort.java index 5cf0358..42862fa 100644 --- a/src/main/java/com/productdock/application/port/out/messaging/DeleteBookMessagingOutPort.java +++ b/src/main/java/com/productdock/application/port/out/messaging/DeleteBookMessagingOutPort.java @@ -1,7 +1,6 @@ package com.productdock.application.port.out.messaging; import com.fasterxml.jackson.core.JsonProcessingException; -import com.productdock.domain.Book; import java.util.concurrent.ExecutionException; diff --git a/src/main/java/com/productdock/application/service/DeleteBookService.java b/src/main/java/com/productdock/application/service/DeleteBookService.java index 4f1b22d..eefa16a 100644 --- a/src/main/java/com/productdock/application/service/DeleteBookService.java +++ b/src/main/java/com/productdock/application/service/DeleteBookService.java @@ -45,7 +45,6 @@ private String createRentalMessage(BookRentalStateDto bookRentals){ } String status = bookRentals.status().toString().toLowerCase(); String userName = bookRentals.user().fullName(); - String message = "Book is " + status + " by " + userName + "."; - return message; + return "Book is " + status + " by " + userName + "."; } } diff --git a/src/test/java/com/productdock/adapter/in/web/DeleteBookApiShould.java b/src/test/java/com/productdock/adapter/in/web/DeleteBookApiShould.java index ba9063a..e5ca570 100644 --- a/src/test/java/com/productdock/adapter/in/web/DeleteBookApiShould.java +++ b/src/test/java/com/productdock/adapter/in/web/DeleteBookApiShould.java @@ -22,7 +22,7 @@ public class DeleteBookApiShould { @Test void deleteBook(){ - deleteBookApi.DeleteBook(DEFAULT_BOOK_ID); + deleteBookApi.deleteBook(DEFAULT_BOOK_ID); verify(deleteBookUseCase).deleteBook(DEFAULT_BOOK_ID); } diff --git a/src/test/java/com/productdock/application/service/DeleteBookServiceShould.java b/src/test/java/com/productdock/application/service/DeleteBookServiceShould.java index 82a85fd..c55fdca 100644 --- a/src/test/java/com/productdock/application/service/DeleteBookServiceShould.java +++ b/src/test/java/com/productdock/application/service/DeleteBookServiceShould.java @@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class DeleteBookServiceShould { +class DeleteBookServiceShould { private static final UserProfileDto USER_PROFILE_DTO = new UserProfileDto("Mocked name", null, null); private static final BookRentalStateDto RENTAL_DTO = new BookRentalStateDto(USER_PROFILE_DTO, null, null);