Skip to content

Instantly share code, notes, and snippets.

Avatar
🇧🇷

Elias Nogueira eliasnogueira

🇧🇷
View GitHub Profile
@eliasnogueira
eliasnogueira / modern_testing_tools.md
Last active February 2, 2023 07:34
Modern Testing Tools for Java Developers
View modern_testing_tools.md

Title

Modern Testing Tools for Java Developers

Description

We are, constantly, evolving the codebase by applying the best development practices, approaches, and design patterns. There's a lot of support from frameworks and libraries to do this during the SDLC.

New versions of the API framework appear, adding the last trending and here we go again: changing our code to adopt these new things. How awesome it is! We are improving!

How about one of the most important and, sometimes, missed things: quality! How the quality evolves within the adoption of new versions of development frameworks and libraries?

@eliasnogueira
eliasnogueira / service-container.yaml
Created January 2, 2023 18:30
Example of a service container
View service-container.yaml
jobs:
build:
runs-on: ubuntu-latest
services:
credit-api:
image: eliasnogueira/combined-credit-api:latest
ports:
- 8088:8088
@eliasnogueira
eliasnogueira / docker-compose.yml
Created November 25, 2022 16:00
[JavaAdvent] Docker compose file to copy the necessary Wiremock files and build the Docker image
View docker-compose.yml
version: '3.9'
services:
wiremock:
build:
context: ./
dockerfile: Dockerfile
image: wiremock-custom
container_name: wiremock-credit-restriction-api
ports:
@eliasnogueira
eliasnogueira / Dockerfile
Last active November 25, 2022 15:57
[JavaAdvent] Example of Dockerfile for Wiremock
View Dockerfile
FROM anapsix/alpine-java:8
RUN apk add --update curl && \
rm -rf /var/cache/apk/*
ENV WM_PACKAGE wiremock-jre8-standalone
ARG WM_VERSION=2.35.0
RUN mkdir /$WM_PACKAGE
WORKDIR /$WM_PACKAGE
@eliasnogueira
eliasnogueira / restrictions_response_200.json
Created November 24, 2022 19:38
[JavaAdvent] Response for the Restriction API
View restrictions_response_200.json
{
"message": "CPF 97093236014 has a restriction"
}
@eliasnogueira
eliasnogueira / simulation_with_restriction_response.json
Created November 24, 2022 19:32
[JavaAdvent] Response body for the Simulation with a Restriction
View simulation_with_restriction_response.json
{
"message": "CPF has a restriciton"
}
@eliasnogueira
eliasnogueira / simulation_with_restriction.json
Created November 24, 2022 15:51
[JavaAdvent] Simulation with a restriction
View simulation_with_restriction.json
{
"name" : "Simulation request containing a restriction",
"request" : {
"url" : "/api/v1/simulations/",
"method" : "POST",
"bodyPatterns" : [
{
"equalToJson" : {
"cpf": "97093236014"
}
@eliasnogueira
eliasnogueira / restricitons_complete.json
Created November 24, 2022 15:50
[JavaAdvent] Restriction response
View restricitons_complete.json
{
"name" : "Restriction request for a CPF with restriction",
"request" : {
"url" : "/api/v1/restrictions/97093236014",
"method" : "GET"
},
"response" : {
"status" : 200,
"bodyFileName" : "restrictions_response_200.json",
"headers" : {
@eliasnogueira
eliasnogueira / post.sh
Last active November 24, 2022 15:45
[JavaAdvent] Post example, trying to create a simulation where the CPF has a restriction
View post.sh
curl -X 'POST' \
  'http://localhost:8089/api/v1/simulations/' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
   "cpf": "97093236014",
   "email": "john.doe@gmail.com",
   "name": "John Doe",
   "installments": 3,
   "insurance": true,
@eliasnogueira
eliasnogueira / SimulationsController.java
Created November 24, 2022 15:42
[JavaAdvent] Method that connects to the Restriction API and return the appropriate result
View SimulationsController.java
private void checkForRestriction(String cpf) throws SimulationException {
RestTemplate template = new RestTemplateBuilder().errorHandler(new RestTemplateErrorHandler()).build();
String restrictionsEndpoint = String.format("%s:%s%s", env.getProperty("restrictions.host"),
env.getProperty("restrictions.port"), env.getProperty("restrictions.path"));
var response = template.getForObject(restrictionsEndpoint, MessageDto.class, cpf);
if (response != null) throw new ResponseStatusException(HttpStatus.FORBIDDEN, response.message());
}