From 6fe35a37f0da3fae25791da6fc0c45aa56058eda Mon Sep 17 00:00:00 2001 From: Mariana Azevedo Date: Sun, 23 Aug 2020 20:31:26 -0300 Subject: [PATCH] Refactoring code. --- Procfile | 2 +- README.md | 20 ++--- pom.xml | 2 +- .../v1/statistic/StatisticController.java | 8 +- .../v1/transaction/TransactionController.java | 87 +++++++++++-------- .../DuplicateStatisticsException.java | 6 ++ .../model/enumeration/PageOrderEnum.java | 17 +++- .../statistic/StatisticRepository.java | 10 +++ .../ratelimiting/APIUsagePlansService.java | 2 +- .../impl/APIUsagePlansServiceImpl.java | 2 +- .../service/statistic/StatisticService.java | 6 +- .../statistic/impl/StatisticServiceImpl.java | 2 +- .../transaction/TransactionService.java | 8 +- .../impl/TransactionServiceImpl.java | 2 +- .../interceptor/RateLimitInterceptor.java | 2 +- .../statistic/StatisticControllerTest.java | 2 +- .../statistic/StatisticServiceTest.java | 4 +- 17 files changed, 120 insertions(+), 62 deletions(-) diff --git a/Procfile b/Procfile index 2a6043c..e91e699 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: java -jar -Dspring.profiles.active=prod -Dserver.port=$PORT target/financial-java-api-3.0.3-SNAPSHOT.jar \ No newline at end of file +web: java -jar -Dspring.profiles.active=prod -Dserver.port=$PORT target/financial-java-api-3.1.0-SNAPSHOT.jar \ No newline at end of file diff --git a/README.md b/README.md index 2a0a2ec..88ff0bb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This API provides HTTP endpoint's and tools for the following: `POST/financial/v1/transaction` -This endpoint is called to create a new transaction. +This end-point is called to create a new transaction. **Body:** @@ -59,12 +59,12 @@ Returns an empty body with one of the following: * 404 - Not Found: The requested resource doesn't exist. * 409 - Conflict: The request conflicts with another request (perhaps due to using the same idempotent key). * 422 – Unprocessable Entity: if any of the fields are not parsable or the transaction date is in the future. -* 429 - Too Many Requests: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. +* 429 - Too Many Requests: Too many requests hit the API too quickly. We recommend an exponential back-off of your requests. * 500, 502, 503, 504 - Server Errors: something went wrong on API end (These are rare). `PUT/financial/v1/transaction/{id}` -This endpoint is called to update a transaction. +This end-point is called to update a transaction. **Body:** @@ -103,11 +103,11 @@ the one that was updated. `GET/financial/v1/transactions` -This endpoint returns all transactions created. +This end-point returns all transactions created. `DELETE/financial/v1/transaction/{id}` -This endpoint causes a transaction for a specific id to be deleted, accepting an empty request body and return a 204 status code. +This end-point causes a transaction for a specific id to be deleted, accepting an empty request body and return a 204 status code. **Where:** @@ -115,7 +115,7 @@ This endpoint causes a transaction for a specific id to be deleted, accepting an `GET/financial/v1/statistics` -This endpoint returns the statistics based on the transactions created. +This end-point returns the statistics based on the transactions created. **Returns:** @@ -151,7 +151,7 @@ This endpoint returns the statistics based on the transactions created. `links` - self-linking URL for the statistic. It is automatically generated. -All `BigDecimal` values always contain exactly two decimal places, eg: `15.385` is returned as `15.39`. +All `BigDecimal` values always contain exactly two decimal places, e.g: `15.385` is returned as `15.39`. ### Technologies used @@ -179,7 +179,7 @@ The API also was developed to run with an `jar`. In order to generate this `jar` mvn package ``` -It will clean, compile and generate a `jar` at target directory, e.g. `financial-java-api-3.0.3-SNAPSHOT.jar` +It will clean, compile and generate a `jar` at target directory, e.g. `financial-java-api-3.1.0-SNAPSHOT.jar` ### Execution @@ -196,7 +196,7 @@ spring.datasource.username= spring.datasource.password= ``` -When the application is running **Flyway** will create the necessary tables for the creation of the words and the execution of the compare between the endpoints. In the test profile, the application uses **H2** database (data in memory). +When the application is running **Flyway** will create the necessary tables for the creation of the words and the execution of the compare between the end-points. In the test profile, the application uses **H2** database (data in memory). ### Test @@ -217,7 +217,7 @@ mvn integration-test In order to run the API, run the jar simply as following: ```bash -java -jar financial-java-api-3.0.3-SNAPSHOT.jar --spring.profiles.active=prod +java -jar financial-java-api-3.1.0-SNAPSHOT.jar --spring.profiles.active=prod ``` or diff --git a/pom.xml b/pom.xml index 3c24090..14d1ed1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.github.mariazevedo88 financial-java-api - 3.0.3-SNAPSHOT + 3.1.0-SNAPSHOT jar financial-java-api diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/statistic/StatisticController.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/statistic/StatisticController.java index 24a829b..04ace7d 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/statistic/StatisticController.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/statistic/StatisticController.java @@ -27,7 +27,7 @@ import io.swagger.annotations.ApiOperation; /** - * SpringBoot RestController that creates all service endpoints related to the statistics. + * SpringBoot RestController that creates all service end-points related to the statistics. * * @author Mariana Azevedo * @since 09/09/2019 @@ -55,6 +55,8 @@ public StatisticController(StatisticService statisticService, * @since 03/04/2020 * * @param apiVersion + * @param apiKey + * * @return ResponseEntity with a Response object and the HTTP status * * HTTP Status: @@ -96,7 +98,7 @@ public ResponseEntity> create(@RequestHeader(value=Financ * @since 03/04/2020 * * @param transactions - * @return a Statistic object + * @return a Statistic object */ private Statistic createStatistics(List transactions) { @@ -123,7 +125,7 @@ private Statistic createStatistics(List transactions) { * @since 03/04/2020 * * @param statistic - * @return a StatisticDTO object + * @return a StatisticDTO object */ private StatisticDTO convertEntityToDTO(Statistic statistic) { diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/transaction/TransactionController.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/transaction/TransactionController.java index 90fea12..3743cdb 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/transaction/TransactionController.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/transaction/TransactionController.java @@ -46,7 +46,7 @@ import lombok.extern.log4j.Log4j2; /** - * SpringBoot RestController that creates all service endpoints related to the transaction. + * SpringBoot RestController that creates all service end-points related to the transaction. * * @author Mariana Azevedo * @since 08/09/2019 @@ -69,14 +69,15 @@ public TransactionController(TransactionService transactionService) { * @author Mariana Azevedo * @since 02/04/2020 * - * @param apiVersion + * @param apiVersion - API version at the moment + * @param apiKey - API Key to access the routes * @param dto, where: id - transaction id; nsu - identification number of a sales transaction using cards. May be null if transaction was paid in cash; - * autorizationNumber - is a one-time code used in the processing of online transactions; amount – transaction amount; a string of arbitrary length that is + * authorizationNumber - is a one-time code used in the processing of online transactions; amount – transaction amount; a string of arbitrary length that is * parsable as a BigDecimal; transactionDate – transaction time in the ISO 8601 format YYYY-MM-DDThh:mm:ss.sssZ in the Local timezone; type - transaction type: * CARD (credit-card) or MONEY (paid in cash). * @param result - Bind result * - * @return ResponseEntity with a Response object and the HTTP status + * @return ResponseEntity with a Response object and the HTTP status * * HTTP Status: * @@ -94,8 +95,8 @@ public TransactionController(TransactionService transactionService) { @PostMapping @ApiOperation(value = "Route to create a transaction") public ResponseEntity> create(@RequestHeader(value=FinancialApiUtil.HEADER_FINANCIAL_API_VERSION, defaultValue="${api.version}") - String apiVersion, @RequestHeader(value=FinancialApiUtil.HEADER_API_KEY, defaultValue="${api.key}") String apiKey, @Valid @RequestBody TransactionDTO dto, - BindingResult result) throws NotParsableContentException { + String apiVersion, @RequestHeader(value=FinancialApiUtil.HEADER_API_KEY, defaultValue="${api.key}") String apiKey, + @Valid @RequestBody TransactionDTO dto, BindingResult result) throws NotParsableContentException { Response response = new Response<>(); @@ -127,14 +128,15 @@ public ResponseEntity> create(@RequestHeader(value=Fina * @author Mariana Azevedo * @since 02/04/2020 * - * @param apiVersion - * @param dto, where: id - transaction id; nsu - identification number of a sales transaction using cards. May be null if transaction was paid in cash; + * @param apiVersion - API version at the moment + * @param apiKey - API Key to access the routes + * @param dto, where: id - transaction id; NSU - identification number of a sales transaction using cards. May be null if transaction was paid in cash; * autorizationNumber - is a one-time code used in the processing of online transactions; amount – transaction amount; a string of arbitrary length that is * parsable as a BigDecimal; transactionDate – transaction time in the ISO 8601 format YYYY-MM-DDThh:mm:ss.sssZ in the Local timezone; type - transaction type: * CARD (credit-card) or MONEY (paid in cash). * @param result - Bind result * - * @return ResponseEntity with a Response object and the HTTP status + * @return ResponseEntity with a Response object and the HTTP status * * HTTP Status: * @@ -191,7 +193,14 @@ public ResponseEntity> update(@RequestHeader(value=Fina * @author Mariana Azevedo * @since 02/04/2020 * - * @return ResponseEntity with a Response> object and the HTTP status + * @param apiVersion - API version at the moment + * @param apiKey - API Key to access the routes + * @param startDate - the start date of the search + * @param endDate - the end date of the search + * @param page - the page that will be return in the search + * @param order - the sort order that the results should be shown: ASC - ascending order; DESC - descending order + * + * @return ResponseEntity with a Response> object and the HTTP status * * HTTP Status: * @@ -215,7 +224,7 @@ public ResponseEntity>> findAllBetweenDates(@Reque LocalDateTime endDateTime = FinancialApiUtil.convertLocalDateToLocalDateTime(endDate); Page transactions = transactionService.findBetweenDates(startDateTime, endDateTime, - page, PageOrderEnum.getDirection(order)); + page, PageOrderEnum.getSortDirection(order)); if (transactions.isEmpty()) { throw new TransactionNotFoundException("There are no transactions registered between startDate=" + startDate @@ -241,14 +250,16 @@ public ResponseEntity>> findAllBetweenDates(@Reque } /** - * Method that search for all the transactions given a nsu. + * Method that search for all the transactions given a NSU. * * @author Mariana Azevedo * @since 02/04/2020 * - * @param apiVersion - * @param transactionNSU - * @return ResponseEntity with a Response object and the HTTP status + * @param apiVersion - API version at the moment + * @param apiKey - API Key to access the routes + * @param transactionNSU - the NSU of the transaction + * + * @return ResponseEntity with a Response object and the HTTP status * * HTTP Status: * @@ -264,8 +275,8 @@ public ResponseEntity>> findAllBetweenDates(@Reque @GetMapping(value = "/byNsu/{nsu}") @ApiOperation(value = "Route to find transactions by the NSU in the API") public ResponseEntity>> findByNsu(@RequestHeader(value=FinancialApiUtil.HEADER_FINANCIAL_API_VERSION, defaultValue="${api.version}") - String apiVersion, @RequestHeader(value=FinancialApiUtil.HEADER_API_KEY, defaultValue="${api.key}") String apiKey, @PathVariable("nsu") String transactionNSU) - throws TransactionNotFoundException { + String apiVersion, @RequestHeader(value=FinancialApiUtil.HEADER_API_KEY, defaultValue="${api.key}") String apiKey, + @PathVariable("nsu") String transactionNSU) throws TransactionNotFoundException { Response> response = new Response<>(); List transactions = transactionService.findByNsu(transactionNSU); @@ -297,9 +308,11 @@ public ResponseEntity>> findByNsu(@RequestHeader(v /** * Method that search a transactions by the id. * - * @param apiVersion - * @param transactionId - * @return ResponseEntity with a Response object and the HTTP status + * @param apiVersion - API version at the moment + * @param apiKey - API Key to access the routes + * @param transactionId - the id of the transaction + * + * @return ResponseEntity with a Response object and the HTTP status * * HTTP Status: * @@ -315,8 +328,8 @@ public ResponseEntity>> findByNsu(@RequestHeader(v @GetMapping(value = "/{id}") @ApiOperation(value = "Route to find a transaction by your id in the API") public ResponseEntity> findById(@RequestHeader(value=FinancialApiUtil.HEADER_FINANCIAL_API_VERSION, defaultValue="${api.version}") - String apiVersion, @RequestHeader(value=FinancialApiUtil.HEADER_API_KEY, defaultValue="${api.key}") String apiKey, @PathVariable("id") Long transactionId) - throws TransactionNotFoundException { + String apiVersion, @RequestHeader(value=FinancialApiUtil.HEADER_API_KEY, defaultValue="${api.key}") String apiKey, + @PathVariable("id") Long transactionId) throws TransactionNotFoundException { Response response = new Response<>(); Transaction transaction = transactionService.findById(transactionId); @@ -338,8 +351,11 @@ public ResponseEntity> findById(@RequestHeader(value=Fi * @author Mariana Azevedo * @since 02/04/2020 * - * @param transactionId - * @return ResponseEntity with a Response object and the HTTP status + * @param apiVersion - API version at the moment + * @param apiKey - API Key to access the routes + * @param transactionId - the id of the transaction + * + * @return ResponseEntity with a Response object and the HTTP status * * HTTP Status: * @@ -347,7 +363,7 @@ public ResponseEntity> findById(@RequestHeader(value=Fi * 400 - Bad Request: The request was unacceptable, often due to missing a required parameter. * 404 - Not Found: The requested resource doesn't exist. * 409 - Conflict: The request conflicts with another request (perhaps due to using the same idempotent key). - * 429 - Too Many Requests: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. + * 429 - Too Many Requests: Too many requests hit the API too quickly. We recommend an exponential back-off of your requests. * 500, 502, 503, 504 - Server Errors: something went wrong on Goldgem's end (These are rare). * * @throws TransactionNotFoundException @@ -355,8 +371,8 @@ public ResponseEntity> findById(@RequestHeader(value=Fi @DeleteMapping(value = "/{id}") @ApiOperation(value = "Route to delete a transaction in the API") public ResponseEntity> delete(@RequestHeader(value=FinancialApiUtil.HEADER_FINANCIAL_API_VERSION, defaultValue="${api.version}") - String apiVersion, @RequestHeader(value=FinancialApiUtil.HEADER_API_KEY, defaultValue="${api.key}") String apiKey, @PathVariable("id") Long transactionId) - throws TransactionNotFoundException { + String apiVersion, @RequestHeader(value=FinancialApiUtil.HEADER_API_KEY, defaultValue="${api.key}") String apiKey, + @PathVariable("id") Long transactionId) throws TransactionNotFoundException { Response response = new Response<>(); Transaction transaction = transactionService.findById(transactionId); @@ -372,13 +388,13 @@ public ResponseEntity> delete(@RequestHeader(value=FinancialApi } /** - * Method to convert an Transaction DTO to an Transaction entity. + * Method to convert an Transaction DTO to a Transaction entity. * * @author Mariana Azevedo * @since 03/04/2020 * * @param dto - * @return a Transaction object + * @return a Transaction object */ private Transaction convertDTOToEntity(TransactionDTO dto) { @@ -387,13 +403,13 @@ private Transaction convertDTOToEntity(TransactionDTO dto) { } /** - * Method to convert an Transaction entity to an Transaction DTO. + * Method to convert an Transaction entity to a Transaction DTO. * * @author Mariana Azevedo * @since 03/04/2020 * * @param transaction - * @return a TransactionDTO object + * @return a TransactionDTO object */ private TransactionDTO convertEntityToDTO(Transaction transaction) { @@ -421,12 +437,15 @@ private void createSelfLink(Transaction transaction, TransactionDTO transactionD * @author Mariana Azevedo * @since 03/04/2020 * - * @param apiVersion + * @param apiVersion - API version at the moment + * @param apiKey - API Key to access the routes * @param transactionDTO * @throws TransactionNotFoundException */ - private void createSelfLinkInCollections(String apiVersion, String apiKey, final TransactionDTO transactionDTO) throws TransactionNotFoundException { - Link selfLink = linkTo(methodOn(TransactionController.class).findById(apiVersion, apiKey, transactionDTO.getId())).withSelfRel(); + private void createSelfLinkInCollections(String apiVersion, String apiKey, final TransactionDTO transactionDTO) + throws TransactionNotFoundException { + Link selfLink = linkTo(methodOn(TransactionController.class).findById(apiVersion, apiKey, + transactionDTO.getId())).withSelfRel(); transactionDTO.add(selfLink); } diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/exception/DuplicateStatisticsException.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/exception/DuplicateStatisticsException.java index 024e547..b46d8b6 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/exception/DuplicateStatisticsException.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/exception/DuplicateStatisticsException.java @@ -1,5 +1,11 @@ package io.github.mariazevedo88.financialjavaapi.exception; +/** + * Class that implements DuplicateStatisticsException in the API + * + * @author Mariana Azevedo + * @since 23/08/2020 + */ public class DuplicateStatisticsException extends Exception { private static final long serialVersionUID = 6082551323004629906L; diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/model/enumeration/PageOrderEnum.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/model/enumeration/PageOrderEnum.java index 71d9879..755a3d1 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/model/enumeration/PageOrderEnum.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/model/enumeration/PageOrderEnum.java @@ -1,5 +1,12 @@ package io.github.mariazevedo88.financialjavaapi.model.enumeration; +/** + * Enum that classifies the ascending order or descending order + * in the sort operations in API routes. + * + * @author Mariana Azevedo + * @since 23/08/2020 + */ public enum PageOrderEnum { ASC("ASC"), DESC("DESC"); @@ -14,7 +21,15 @@ public String getValue() { return value; } - public static PageOrderEnum getDirection(String value){ + /** + * Method to get the sort order of a search result. + * + * @author Mariana Azevedo + * @since 23/08/2020 + * + * @return PageOrderEnum object + */ + public static PageOrderEnum getSortDirection(String value){ if(ASC.getValue().equals(value)) { return ASC; } diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/repository/statistic/StatisticRepository.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/repository/statistic/StatisticRepository.java index 43b99b8..7278c55 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/repository/statistic/StatisticRepository.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/repository/statistic/StatisticRepository.java @@ -19,6 +19,16 @@ @Repository public interface StatisticRepository extends JpaRepository{ + /** + * Method that search for a statistic that already exists on the API. + * + * @param sum + * @param avg + * @param max + * @param min + * @param count + * @return Optional object + */ @Query(value = "select s.id, s.sum, s.avg, s.max, s.min, s.count from Statistic s " + "where s.sum = :sum and s.avg = :avg and s.max = :max and s.min = :min " + "and s.count = :count") diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/APIUsagePlansService.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/APIUsagePlansService.java index 660c1a5..9ad244f 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/APIUsagePlansService.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/APIUsagePlansService.java @@ -4,7 +4,7 @@ import io.github.bucket4j.Bucket; /** - * Service Interface that provides methods for manipulating API Usage Plans. + * Interface that provides methods for manipulating API Usage Plans. * * @author Mariana Azevedo * @since 11/06/2020 diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/impl/APIUsagePlansServiceImpl.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/impl/APIUsagePlansServiceImpl.java index b34e83a..f9cc062 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/impl/APIUsagePlansServiceImpl.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/impl/APIUsagePlansServiceImpl.java @@ -12,7 +12,7 @@ import io.github.mariazevedo88.financialjavaapi.service.ratelimiting.APIUsagePlansService; /** - * Class that implements the API usage plans service methods + * Class that implements the API usage plans service methods. * * @author Mariana Azevedo * @since 11/06/2020 diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/StatisticService.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/StatisticService.java index 508f97e..64104e2 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/StatisticService.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/StatisticService.java @@ -6,7 +6,7 @@ import io.github.mariazevedo88.financialjavaapi.model.statistic.Statistic; /** - * Service Interface that provides methods for manipulating Statistics objects. + * Interface that provides methods for manipulating Statistics objects. * * @author Mariana Azevedo * @since 08/09/2019 @@ -14,7 +14,7 @@ public interface StatisticService { /** - * Method that saves a statistic + * Method that saves a statistic. * * @author Mariana Azevedo * @since 08/06/2020 @@ -25,7 +25,7 @@ public interface StatisticService { Statistic save(Statistic statistic); /** - * Method that verifies if the statistics already exists in the database + * Method that verifies if the statistics already exists in the database. * * @author Mariana Azevedo * @since 11/06/2020 diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/impl/StatisticServiceImpl.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/impl/StatisticServiceImpl.java index f839f44..0ad1d2f 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/impl/StatisticServiceImpl.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/impl/StatisticServiceImpl.java @@ -35,8 +35,8 @@ public Statistic save(Statistic statistic) { } /** - * @throws DuplicateStatisticsException * @see StatisticService#verifyIfStatisticsIsSame(BigDecimal, BigDecimal, BigDecimal, BigDecimal, long) + * @throws DuplicateStatisticsException */ @Override public Statistic verifyIfStatisticsIsSame(BigDecimal sum, BigDecimal avg, BigDecimal max, diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/TransactionService.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/TransactionService.java index 251f637..4a7a877 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/TransactionService.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/TransactionService.java @@ -71,11 +71,17 @@ public interface TransactionService { List findAll(); /** - * Method that find all transactions in a period of time + * Method that find all transactions in a period of time. * * @author Mariana Azevedo * @since 21/08/2020 * + * @param startDate - the start date of the search + * @param endDate - the end date of the search + * @param page - the page that will be return in the search + * @param order - the sort order that the results should be shown: + * ASC - ascending order; DESC - descending order + * * @return Page object */ Page findBetweenDates(LocalDateTime startDate, LocalDateTime endDate, int page, diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/impl/TransactionServiceImpl.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/impl/TransactionServiceImpl.java index 0a38571..eaa1990 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/impl/TransactionServiceImpl.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/impl/TransactionServiceImpl.java @@ -63,8 +63,8 @@ public void deleteById(Long transactionId) { } /** - * @throws TransactionNotFoundException * @see TransactionService#findById(Long) + * @throws TransactionNotFoundException */ @Override @Cacheable(value="transactionIdCache", key="#id") diff --git a/src/main/java/io/github/mariazevedo88/financialjavaapi/util/interceptor/RateLimitInterceptor.java b/src/main/java/io/github/mariazevedo88/financialjavaapi/util/interceptor/RateLimitInterceptor.java index f2ef421..89b7b99 100644 --- a/src/main/java/io/github/mariazevedo88/financialjavaapi/util/interceptor/RateLimitInterceptor.java +++ b/src/main/java/io/github/mariazevedo88/financialjavaapi/util/interceptor/RateLimitInterceptor.java @@ -63,7 +63,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons response.addHeader(FinancialApiUtil.HEADER_RETRY_AFTER, String.valueOf(waitForRefill)); response.sendError(HttpStatus.TOO_MANY_REQUESTS.value(), "You have exhausted your API Request Quota"); // 429 - log.error("You have exhausted your API Request Quota"); + log.info("You have exhausted your API Request Quota"); return false; } diff --git a/src/test/java/io/github/mariazevedo88/financialjavaapi/test/controller/statistic/StatisticControllerTest.java b/src/test/java/io/github/mariazevedo88/financialjavaapi/test/controller/statistic/StatisticControllerTest.java index bf7ea19..63f7f1c 100644 --- a/src/test/java/io/github/mariazevedo88/financialjavaapi/test/controller/statistic/StatisticControllerTest.java +++ b/src/test/java/io/github/mariazevedo88/financialjavaapi/test/controller/statistic/StatisticControllerTest.java @@ -64,7 +64,7 @@ private void setUp() { } /** - * Method that tests to save a Statistic in the API + * Method that tests to save a Statistic in the API. * * @author Mariana Azevedo * @since 05/04/2020 diff --git a/src/test/java/io/github/mariazevedo88/financialjavaapi/test/service/statistic/StatisticServiceTest.java b/src/test/java/io/github/mariazevedo88/financialjavaapi/test/service/statistic/StatisticServiceTest.java index 9e4f070..93bf4e7 100644 --- a/src/test/java/io/github/mariazevedo88/financialjavaapi/test/service/statistic/StatisticServiceTest.java +++ b/src/test/java/io/github/mariazevedo88/financialjavaapi/test/service/statistic/StatisticServiceTest.java @@ -22,7 +22,7 @@ import io.github.mariazevedo88.financialjavaapi.service.statistic.StatisticService; /** - * Class that implements tests of the StatisticService funcionalities. + * Class that implements tests of the StatisticService features. * * @author Mariana Azevedo * @since 05/04/2020 @@ -46,7 +46,7 @@ public class StatisticServiceTest { private StatisticRepository repository; /** - * Method that test the service that save a Wallet and a WalletItem in the API. + * Method that test the service that save a Statistic in the API. * * @author Mariana Azevedo * @since 24/03/2020