Skip to content

Commit

Permalink
bugfix: condition uk placa
Browse files Browse the repository at this point in the history
  • Loading branch information
skatesham committed May 18, 2023
1 parent 4b8d063 commit bb5d625
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# API Car with FIPE integration
![coverag](https://img.shields.io/badge/coverage-85%25-darkgreen)
![coverag](https://img.shields.io/badge/coverage-92%25-darkgreen)

API register vehicle indexed by brand and model with external client app price search.
![alt text][8]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package core.demo.app.infrastucture.messaging;
package core.demo.app.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import core.demo.app.domain.veiculo.exceptions.VeiculoAlreadyExistException;
import core.demo.app.domain.veiculo.model.VeiculoEntity;
import core.demo.app.domain.veiculo.model.VeiculoRepository;
import core.demo.app.domain.veiculo.model.VeiculoRequestedSender;
import core.demo.app.infrastucture.clients.FipeClient;
import core.demo.app.infrastucture.clients.FipePriceRequest;
import core.demo.app.interfaces.veiculo.VeiculoRequest;
Expand Down Expand Up @@ -42,8 +43,10 @@ public class VeiculoService {
public VeiculoEntity scheduleCreation(final VeiculoRequest veiculoRequest) {
log.trace("action=veiculo-creation status=start placa={}", veiculoRequest.getPlaca());

this.veiculoRepository.findByPlaca(veiculoRequest.getPlaca())
.orElseThrow(() -> new VeiculoAlreadyExistException(veiculoRequest.getPlaca()));
final var veiculoByPlacaFoundOpt = this.veiculoRepository.findByPlaca(veiculoRequest.getPlaca());
if (veiculoByPlacaFoundOpt.isPresent()) {
throw new VeiculoAlreadyExistException(veiculoRequest.getPlaca());
}

final MarcaEntity marca = marcaRepository.findByFipeId(veiculoRequest.getMarcaId())
.orElseThrow(() -> new EntityNotFoundException("Not found marca=" + veiculoRequest.getMarcaId()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package core.demo.app.domain.veiculo;
package core.demo.app.domain.veiculo.model;

import core.demo.app.domain.utils.JsonUtils;
import core.demo.app.domain.veiculo.model.VeiculoEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void setUp() {
@Sql("classpath:/truncate-database.sql")
@Sql("classpath:/mocks/db/setup-schema.sql")
@Sql("classpath:/mocks/db/setup-vehicle.sql")
void mustIntegrateVeihicleCreationAndReadSavedValue() throws JsonProcessingException {
void mustIntegrateVehicleCreationAndReadSavedValue() throws JsonProcessingException {
VeiculoRequest request = VeiculoRequestTemplates
.defaultBuilder()
.placa("NEW-1234")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void setUp() {
@Test
@Sql("classpath:/truncate-database.sql")
@Sql("classpath:/mocks/db/setup-schema.sql")
void mustValidadeAndProduceVeiculoCreationRequested() {
void mustValidateAndProduceVeiculoCreationRequested() {
// arrange
VeiculoRequest request = VeiculoRequestTemplates.build();

Expand Down
18 changes: 3 additions & 15 deletions src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@ logging.level.core.chapadaguides=TRACE
#spring.jpa.properties.hibernate.format_sql=true
#logging.level.org.hibernate.SQL=DEBUG
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG
logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE
spring.jpa.properties.hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
# Storage
google.credential.file=123
google.storage.projectId=chapada-guides
storage.bucket.profiles=profiles
storage.bucket.guide-documents=guide-documents
# Email
source.host=http://localhost:8080
source.front.host=http://localhost:5173
# Payment
payment.mercado-pago.access-token=""
## Testing Scheduled (Last probable)
bcg.job.cron.disable-guide-plan=1 1 1 1 1 ?
#logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG
#logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE
#spring.jpa.properties.hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
## Clients
spring.cloud.loadbalancer.ribbon.enable=false
# Wiremock Client
Expand Down

0 comments on commit bb5d625

Please sign in to comment.