Skip to content

Commit

Permalink
Merge pull request #3 from mariazevedo88/fix/lombokAnnotationsAndReadme
Browse files Browse the repository at this point in the history
Fixing lombok annotations and markdown on README.md.
  • Loading branch information
Mariana Azevedo authored Apr 10, 2020
2 parents dfa837d + 087083c commit d8dc772
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: java -jar -Dspring.profiles.active=prod -Dserver.port=$PORT target/financial-java-api-2.0.0-SNAPSHOT.jar
web: java -jar -Dspring.profiles.active=prod -Dserver.port=$PORT target/financial-java-api-2.0.1-SNAPSHOT.jar
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ This endpoint is called to create a new transaction.

**Body:**

<code>
```json
{
"nsu": "123456",
"authorizationNumber": "010203",
"amount": "22.88",
"transactionDate": "2020-04-05T09:59:51.312Z",
"type": "CARD",
}
</code>
```

**Where:**

Expand Down Expand Up @@ -68,7 +68,7 @@ This endpoint is called to update a transaction.

**Body:**

<code>
```json
{
"id": 1,
"nsu": "123456",
Expand All @@ -77,12 +77,12 @@ This endpoint is called to update a transaction.
"transactionDate": "2020-04-05T09:59:51.312Z",
"type": "CARD"
}
</code>
```

Must be submitted the object that will be modified. Must return a transaction specified by ID and all fields recorded above, including links and
the one that was updated.

<code>
```json
{
"data": {
"id": 1,
Expand All @@ -99,7 +99,7 @@ the one that was updated.
]
}
}
</code>
```

`GET/financial/v1/transactions`

Expand All @@ -119,7 +119,7 @@ This endpoint returns the statistics based on the transactions created.

**Returns:**

<code>
```json
{
"data": {
"sum": "150.06",
Expand All @@ -135,7 +135,7 @@ This endpoint returns the statistics based on the transactions created.
]
}
}
</code>
```

**Where:**

Expand All @@ -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, eg: `15.385` is returned as `15.39`.

### Technologies used

Expand All @@ -160,33 +160,36 @@ This project was developed with:
* **Java 11 (Java Development Kit - JDK: 11.0.3)**
* **Spring Boot 2.2.6**
* **Spring Framework 2.2.6**
* **Maven**
* **JUnit 5**
* **PostgreSQL 9.6.17**
* **Surfire**
* **PostgreSQL 12**
* **Flyway 6.0.8**
* **Swagger 2.9.2**
* **Model Mapper 2.3.6**
* **Heroku**

### Compile and Package

The API also was developed to run with an jar. In order to generate this jar, you should run:
The API also was developed to run with an `jar`. In order to generate this `jar`, you should run:

```
```bash
mvn package
```

It will clean, compile and generate a jar at target directory, e.g. `financial-java-api-2.0.0-SNAPSHOT.jar`
It will clean, compile and generate a `jar` at target directory, e.g. `financial-java-api-2.0.1-SNAPSHOT.jar`

### Execution

You need to have **PostgreSQL 9.6.17 or above** installed on your machine to run the API on `dev` profile. After installed, on the `pgAdmin` create a database named `financial`. If you don't have `pgAdmin` installed you can run on the `psql` console the follow command:

```
```sql
CREATE database financial;
```

After creating the API database, you need to add your **Postgres** root `username` and `password` in the `application.properties` file on `src/main/resource`. The lines that must be modified are as follows:

```
```properties
spring.datasource.username=
spring.datasource.password=
```
Expand All @@ -197,27 +200,27 @@ When the application is running **Flyway** will create the necessary tables for

* For unit test phase, you can run:

```
```bash
mvn test
```

* To run all tests (including Integration Tests):

```
```bash
mvn integration-test
```

### Run

In order to run the API, run the jar simply as following:

```
java -jar financial-java-api-2.0.0-SNAPSHOT.jar --spring.profiles.active=prod
```bash
java -jar financial-java-api-2.0.1-SNAPSHOT.jar --spring.profiles.active=prod
```

or

```
```bash
mvn spring-boot:run -Dspring.profiles.active=prod
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

<name>financial-java-api</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,26 @@
* @author Mariana Azevedo
* @since 01/04/2020
*/
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class StatisticDTO extends RepresentationModel<StatisticDTO> {

@Getter
@Setter
private Long id;

@Getter
@Setter
@NotNull(message="Sum cannot be null")
private BigDecimal sum;

@Getter
@Setter
@NotNull(message="Avg cannot be null")
private BigDecimal avg;

@Getter
@Setter
@NotNull(message="Max cannot be null")
private BigDecimal max;

@Getter
@Setter
@NotNull(message="Min cannot be null")
private BigDecimal min;

@Getter
@Setter
@NotNull(message="Count cannot be null")
private long count;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,27 @@
* @author Mariana Azevedo
* @since 01/04/2020
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class TransactionDTO extends RepresentationModel<TransactionDTO> {

@Getter
@Setter
private Long id;

@Getter
@Setter
@NotNull(message="Nsu cannot be null")
@Length(min=6, message="Nsu must contain at least 6 characters")
private String nsu;

@Getter
@Setter
private String authorizationNumber;

@Getter
@Setter
@DateTimeFormat(iso = ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
@NotNull(message="TransactionDate cannot be null")
private Date transactionDate;

@Getter
@Setter
@NotNull(message="Amount cannot be null")
private BigDecimal amount;

@Getter
@Setter
@NotNull(message="Type cannot be null")
private TransactionTypeEnum type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
*
* @param <T>
*/
@Getter
@Setter
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Response<T> {

@Getter
@Setter
private T data;

@Getter
@Setter
private Object errors;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
* @author Mariana Azevedo
* @since 01/04/2020
*/
@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor
public class ResponseError {

@Getter
@Setter
@NotNull(message="Timestamp cannot be null")
private LocalDateTime timestamp;

@Getter
@Setter
@NotNull(message="Details cannot be null")
private String details;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @since 01/04/2020
*/
@Entity
@Getter
@Setter
@Table(name = "statistics")
@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -30,33 +32,21 @@ public class Statistic implements Serializable {
private static final long serialVersionUID = -7804600023031651840L;

@Id
@Getter
@Setter
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Getter
@Setter
@Column(name = "transactions_sum")
private BigDecimal sum;

@Getter
@Setter
@Column(name = "transactions_avg")
private BigDecimal avg;

@Getter
@Setter
@Column(name = "transactions_max")
private BigDecimal max;

@Getter
@Setter
@Column(name = "transactions_min")
private BigDecimal min;

@Getter
@Setter
@Column(name = "transactions_count")
private long count;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,32 @@
* @since 01/04/2020
*/
@Entity
@Table(name = "transaction")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "transaction")
public class Transaction implements Serializable {

private static final long serialVersionUID = -3656431259068389491L;

@Id
@Getter
@Setter
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Getter
@Setter
@NotNull
private String nsu;

@Getter
@Setter
private String authorizationNumber;

@Getter
@Setter
@NotNull
@DateTimeFormat(iso = ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private Date transactionDate;

@Getter
@Setter
@NotNull
private BigDecimal amount;

@Getter
@Setter
@NotNull
@Enumerated(EnumType.STRING)
private TransactionTypeEnum type;
Expand Down

0 comments on commit d8dc772

Please sign in to comment.