Skip to content

Commit

Permalink
Merge pull request #195 from eliasnogueira/library-updates
Browse files Browse the repository at this point in the history
Library updates
  • Loading branch information
eliasnogueira authored Oct 27, 2024
2 parents 4be600d + 094beab commit e72cb9d
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 27 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.10] - 27-10-2024

## Changed

- Removed Lombok
- Java 23 adoption
- Updated the following libraries
- `spring-boot-starter-parent -> 3.3.5`
- `jib-maven-plugin -> 3.4.4`
- `junit -> 5.11.3`
- `datafaker -> 2.4.1`
- `testcontainers -> 1.20.3`

## [1.3.10] - 16-10-2024

## Changed
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM amazoncorretto:22-alpine-jdk
FROM amazoncorretto:23-alpine-jdk
EXPOSE 8080
ARG JAR_FILE=target/*.jar
ADD ${JAR_FILE} app.jar
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.4</version>
<version>3.3.5</version>
</parent>

<groupId>com.eliasogueira.credit</groupId>
<artifactId>combined-credit-api</artifactId>
<version>1.13.10</version>
<version>1.13.11</version>

<distributionManagement>
<repository>
Expand All @@ -23,7 +23,7 @@
</distributionManagement>

<properties>
<java.version>22</java.version>
<java.version>23</java.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven.compiler.proc>full</maven.compiler.proc>
<maven-surefire-plugin.version>3.5.1</maven-surefire-plugin.version>
Expand All @@ -35,13 +35,13 @@
<hibernate-jpamodelgen.version>6.6.1.Final</hibernate-jpamodelgen.version>
<jakarta-xml-bind-api.version>4.0.2</jakarta-xml-bind-api.version>
<h2.version>2.3.232</h2.version>
<jib-maven-plugin.version>3.4.3</jib-maven-plugin.version>
<jib-maven-plugin.version>3.4.4</jib-maven-plugin.version>

<junit.version>5.11.2</junit.version>
<junit.version>5.11.3</junit.version>
<restassured.version>5.5.0</restassured.version>
<assertj.version>3.26.3</assertj.version>
<datafaker.version>2.4.0</datafaker.version>
<testcontainers.version>1.20.2</testcontainers.version>
<datafaker.version>2.4.1</datafaker.version>
<testcontainers.version>1.20.3</testcontainers.version>

<!-- transitive vulnerable dependencies -->
<commons-compress>1.27.1</commons-compress>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/eliasnogueira/credit/LoadDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package com.eliasnogueira.credit;

import com.eliasnogueira.credit.entity.Restriction;
import com.eliasnogueira.credit.entity.Simulation;
import com.eliasnogueira.credit.entity.SimulationBuilder;
import com.eliasnogueira.credit.entity.Type;
import com.eliasnogueira.credit.repository.RestrictionRepository;
import com.eliasnogueira.credit.repository.SimulationRepository;
Expand Down Expand Up @@ -62,9 +62,9 @@ private Map<String, String> dataToInsert() {
@Bean
CommandLineRunner initRestrictionDatabase(SimulationRepository simulationRepository) {
return args -> {
simulationRepository.save(Simulation.builder().cpf("66414919004").name("Tom").email("[email protected]")
simulationRepository.save(new SimulationBuilder().cpf("66414919004").name("Tom").email("[email protected]")
.amount(new BigDecimal(11000)).installments(3).insurance(true).build());
simulationRepository.save(Simulation.builder().cpf("17822386034").name("John").email("[email protected]")
simulationRepository.save(new SimulationBuilder().cpf("17822386034").name("John").email("[email protected]")
.amount(new BigDecimal(20000)).installments(5).insurance(false).build());
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.eliasnogueira.credit.dto.SimulationDto;
import com.eliasnogueira.credit.dto.v1.MessageDto;
import com.eliasnogueira.credit.entity.Simulation;
import com.eliasnogueira.credit.entity.SimulationBuilder;
import com.eliasnogueira.credit.exception.RestTemplateErrorHandler;
import com.eliasnogueira.credit.exception.SimulationException;
import com.eliasnogueira.credit.repository.SimulationRepository;
Expand Down Expand Up @@ -79,7 +80,7 @@ public List<Simulation> getSimulation(@RequestParam(name = "name", required = fa
List<Simulation> simulationsFound;

Example<Simulation> example =
Example.of(Simulation.builder().name(name).build(),
Example.of(new SimulationBuilder().name(name).build(),
ExampleMatcher.matchingAny().
withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains()));

Expand Down
35 changes: 31 additions & 4 deletions src/main/java/com/eliasnogueira/credit/entity/Restriction.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@Entity
public class Restriction {

Expand All @@ -47,4 +43,35 @@ public Restriction(String cpf, String type) {
this.cpf = cpf;
this.type = type;
}

public Restriction() {
}

public Long getId() {
return this.id;
}

public String getCpf() {
return this.cpf;
}

public String getType() {
return this.type;
}

public void setId(Long id) {
this.id = id;
}

public void setCpf(String cpf) {
this.cpf = cpf;
}

public void setType(String type) {
this.type = type;
}

public String toString() {
return "Restriction(id=" + this.getId() + ", cpf=" + this.getCpf() + ", type=" + this.getType() + ")";
}
}
80 changes: 70 additions & 10 deletions src/main/java/com/eliasnogueira/credit/entity/Simulation.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) today.year Elias Nogueira
* Copyright (c) 2020 Elias Nogueira
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -36,18 +36,9 @@
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

@Data
@Builder(access = AccessLevel.PUBLIC)
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(uniqueConstraints = {
@UniqueConstraint(name = "cpf_unique", columnNames = "cpf")
Expand Down Expand Up @@ -81,4 +72,73 @@ public class Simulation {

@NotNull(message = "One of the insurance options must be selected")
private Boolean insurance;

public Simulation() {
}

public Simulation(Long id, String name, String cpf, String email, BigDecimal amount, Integer installments, Boolean insurance) {
this.id = id;
this.name = name;
this.cpf = cpf;
this.email = email;
this.amount = amount;
this.installments = installments;
this.insurance = insurance;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getCpf() {
return cpf;
}

public void setCpf(String cpf) {
this.cpf = cpf;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public BigDecimal getAmount() {
return amount;
}

public void setAmount(BigDecimal amount) {
this.amount = amount;
}

public Integer getInstallments() {
return installments;
}

public void setInstallments(Integer installments) {
this.installments = installments;
}

public Boolean getInsurance() {
return insurance;
}

public void setInsurance(Boolean insurance) {
this.insurance = insurance;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* MIT License
*
* Copyright (c) 2024 Elias Nogueira
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.eliasnogueira.credit.entity;

import java.math.BigDecimal;

public class SimulationBuilder {

private Long id;
private String name;
private String cpf;
private String email;
private BigDecimal amount;
private Integer installments;
private Boolean insurance;

public SimulationBuilder id(Long id) {
this.id = id;
return this;
}

public SimulationBuilder name(String name) {
this.name = name;
return this;
}

public SimulationBuilder cpf(String cpf) {
this.cpf = cpf;
return this;
}

public SimulationBuilder email(String email) {
this.email = email;
return this;
}

public SimulationBuilder amount(BigDecimal amount) {
this.amount = amount;
return this;
}

public SimulationBuilder installments(Integer installments) {
this.installments = installments;
return this;
}

public SimulationBuilder insurance(Boolean insurance) {
this.insurance = insurance;
return this;
}

public Simulation build() {
return new Simulation(id, name, cpf, email, amount, installments, insurance);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* MIT License
*
* Copyright (c) 2023 Elias Nogueira
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.eliasnogueira.credit.tests;

import com.eliasnogueira.credit.data.model.Simulation;
Expand Down
2 changes: 1 addition & 1 deletion system.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java.runtime.version=22
java.runtime.version=23

0 comments on commit e72cb9d

Please sign in to comment.