Skip to content

Commit

Permalink
Merge pull request #15 from mariazevedo88/dev/partialResponse
Browse files Browse the repository at this point in the history
Dev/partial response
  • Loading branch information
Mariana Azevedo authored Sep 18, 2020
2 parents ab393d1 + 7fe21d3 commit 287fe14
Show file tree
Hide file tree
Showing 22 changed files with 413 additions and 234 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ This API provides HTTP endpoint's and tools for the following:
* Create a Transaction: `POST/financial/v1/transactions`
* Update a Transaction: `PUT/financial/v1/transactions`
* Delete a Transaction (by id): `DELETE/financial/v1/transactions/1`
* Get report of all transactions created: `GET/financial/v1/transactions`
* Get report of transactions in a period of time (sorted and paginated): `GET/financial/v1/transactions?startDate=2020-01-01&endDate=2020-09-18&order=DESC&page=2`
* Find a unique transaction by id: `GET/financial/v1/transactions/1`
* Find a unique transaction by id, but filtering JSON fields: `GET/financial/v1/transactions/1?fields=id,nsu,transactionDate,amount`
* Find transactions by NSU (Unique sequential number): `GET/financial/v1/transactions/byNsu/{nsuNumber}`
* Get Statistics about the transactions of the API: `GET/financial/v1/statistics`

Expand Down Expand Up @@ -101,9 +102,10 @@ the one that was updated.
}
```

`GET/financial/v1/transactions`
`GET/financial/v1/transactions?startDate=2020-01-01&endDate=2020-01-18&order=DESC&page=2`

This end-point returns all transactions created.
This end-point returns transactions created within the period specified in the request. E.g: in the above query, we are looking for
all transactions carried out between 01-18 January 2020. Also, the result should return in descending order and only the page 2.

`DELETE/financial/v1/transaction/{id}`

Expand Down Expand Up @@ -158,7 +160,7 @@ All `BigDecimal` values always contain exactly two decimal places, e.g: `15.385`
This project was developed with:

* **Java 11 (Java Development Kit - JDK: 11.0.7)**
* **Spring Boot 2.3.3**
* **Spring Boot 2.3.4**
* **Spring Admin Client 2.3.0**
* **Maven**
* **JUnit 5**
Expand All @@ -170,6 +172,7 @@ This project was developed with:
* **Heroku**
* **EhCache**
* **Bucket4j 4.10.0**
* **Partialize 20.05**

### Compile and Package

Expand Down
194 changes: 104 additions & 90 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.github.mariazevedo88</groupId>
<artifactId>financial-java-api</artifactId>
<version>3.1.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>financial-java-api</name>
<description>A financial API for managing transactions</description>

<developers>
<developer>
<name>Mariana Azevedo</name>
<email>[email protected]</email>
<timezone>UTC-03:00</timezone>
</developer>
</developers>

<properties>
<java.version>11</java.version>
<swagger.version>3.0.0</swagger.version>
<modelmapper.version>2.3.8</modelmapper.version>
<bucket4j.version>4.10.0</bucket4j.version>
<spring.admin.version>2.3.0</spring.admin.version>
<partialize.version>release~20.05</partialize.version>
</properties>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/>
<version>2.3.4.RELEASE</version>
<relativePath />
</parent>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -45,8 +54,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -57,63 +66,68 @@
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${swagger.version}</version>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring.admin.version}</version>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring.admin.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>${modelmapper.version}</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>${modelmapper.version}</version>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId>
<version>${bucket4j.version}</version>
</dependency>
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId>
<version>${bucket4j.version}</version>
<groupId>com.github.thibaultmeyer</groupId>
<artifactId>partialize</artifactId>
<version>${partialize.version}</version>
</dependency>
</dependencies>

Expand All @@ -123,59 +137,59 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-integration-test-resources</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/it/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-integration-test-resources</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/it/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,8 @@ public class FinancialJavaApiIntegrationTest {
public void testCreateTransactionNSU123456() throws ParseException {

//id=1
TransactionDTO dtoNsu123456 = new TransactionDTO();
dtoNsu123456.setNsu("123456");
dtoNsu123456.setAuthorizationNumber("014785");
dtoNsu123456.setTransactionDate(FinancialApiUtil.
getLocalDateTimeFromString("2020-08-21T18:32:04.150Z"));
dtoNsu123456.setAmount(new BigDecimal(100d));
dtoNsu123456.setType(TransactionTypeEnum.CARD);
TransactionDTO dtoNsu123456 = new TransactionDTO(null, "123456", "014785", FinancialApiUtil.
getLocalDateTimeFromString("2020-08-21T18:32:04.150Z"), new BigDecimal(100d), TransactionTypeEnum.CARD);

final HttpHeaders headers = new HttpHeaders();
headers.set("X-api-key", "FX001-ZBSY6YSLP");
Expand All @@ -76,12 +71,8 @@ public void testCreateTransactionNSU123456() throws ParseException {
public void testCreateTransactionNSU258963() throws ParseException {

//id=2
TransactionDTO dtoNsu258963 = new TransactionDTO();
dtoNsu258963.setNsu("258963");
dtoNsu258963.setTransactionDate(FinancialApiUtil.
getLocalDateTimeFromString("2020-08-21T18:32:04.150Z"));
dtoNsu258963.setAmount(new BigDecimal(2546.93));
dtoNsu258963.setType(TransactionTypeEnum.MONEY);
TransactionDTO dtoNsu258963 = new TransactionDTO(null, "258963", null, FinancialApiUtil.
getLocalDateTimeFromString("2020-08-21T18:32:04.150Z"), new BigDecimal(2546.93), TransactionTypeEnum.MONEY);

final HttpHeaders headers = new HttpHeaders();
headers.set("X-api-key", "FX001-ZBSY6YSLP");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package io.github.mariazevedo88.financialjavaapi;

import java.time.LocalDateTime;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import lombok.extern.log4j.Log4j2;

/**
* Class that starts the application
*
* @author Mariana Azevedo
* @since 03/04/2020
*/
@Log4j2
@SpringBootApplication
public class FinancialJavaApiApplication {

public static void main(String[] args) {
SpringApplication.run(FinancialJavaApiApplication.class, args);
log.info("FinancialJavaAPI started successfully at {}", LocalDateTime.now());
}

}
Loading

0 comments on commit 287fe14

Please sign in to comment.