Skip to content

Instantly share code, notes, and snippets.

View rafaelpontezup's full-sized avatar

Rafael Ponte rafaelpontezup

View GitHub Profile
@rafaelpontezup
rafaelpontezup / links.md
Created August 3, 2020 14:50 — forked from giggio/links.md
Links palestra "Usando um ambiente Linux completo no Windows com WSL e VSCode"
@rafaelpontezup
rafaelpontezup / AssociarPropostasAosCartoesJob.java
Last active February 19, 2021 21:25
Bootcamp: Exercicio de Agendamento de Tarefas implementado nas sessões de check-outs estendidas
package br.com.zup.edu.nossocartao.propostas.cards.jobs;
import br.com.zup.edu.nossocartao.propostas.cards.CardRepository;
import br.com.zup.edu.nossocartao.propostas.cards.integration.CardsClient;
import br.com.zup.edu.nossocartao.propostas.cards.integration.FindCardByProposalIdResponse;
import br.com.zup.edu.nossocartao.propostas.cards.model.Card;
import br.com.zup.edu.nossocartao.propostas.proposals.ProposalRepository;
import br.com.zup.edu.nossocartao.propostas.proposals.model.Proposal;
import br.com.zup.edu.nossocartao.propostas.proposals.model.ProposalStatus;
import org.springframework.beans.factory.annotation.Autowired;
@rafaelpontezup
rafaelpontezup / Instituicoes.kt
Last active March 2, 2021 20:54
[Desafio PIX] Todas as instituições do BCB em um Map com Kotlin
package br.com.zup.edu.pix
import java.lang.IllegalStateException
/**
* Representa todas as instituições financeiras passíveis de trabalhar com Pix
* https://www.bcb.gov.br/pom/spb/estatistica/port/ASTR003.pdf (line 229 - 60701190 ITAÚ UNIBANCO S.A)
*/
class Instituicoes {
@rafaelpontezup
rafaelpontezup / desafio-pix-testes-de-integracao-abordagens.md
Created March 17, 2021 21:21
Desafio Pix: abordagens nos testes de integração

Para escrever os testes de integração dos endpoints gRPC eu tive basicamente que levantar o contexto do Micronaut (com @MicronautTest) juntamente com um banco H2 em vez do PostgreSQL pois meu schema é MUITO simples e não valeria o custo de levantar um PostgreSQL via TestContainers. Por haver muita integração com os serviços satélites ITAU-ERP e BCB, eu mockei ambos.

No fim, eu segui duas abordagem na hora de escrever os cenários de testes:

  1. Para o endpoint RegistraChaveEndpoint, eu adentrei sua classe Service para extrair os cenários de testes, ou seja, todos os cenários foram concebidos a partir das classes de Endpoint + Service. No fim, escrevi uma única classe com todos os testes: [RegistraChaveEndpointTest](https://github.com/zup-academy/orange-stack-pix-keymanager-grpc/blob/master/src/test/kotlin/br/com/zup/edu/pix/registra/RegistraChaveEndpoin
@rafaelpontezup
rafaelpontezup / bean-validation.kt
Created July 13, 2021 14:24
Bean Validation: entendendo como funciona
// Bean Validations = spec = PDF -> Hibernate-Validator -> JAR
@Intropected
data class ProdutoRequest(
@field:NotNull val codigo: Int, // obrigatorio
@field:NotBlank @field:Size(max=42) val nome: String // obrigatorio e tamanho maximo de 42
)
@rafaelpontezup
rafaelpontezup / sprint-1-troubleshooting.md
Last active September 6, 2021 17:09
Sprints: construindo treinamento de troubleshooting

Treinamento Troubleshooting: Primeiros Socorros

Sprint #1 - 05/07 12/07 a 23/07

  • Integrantes: Yuri Matheus e Rafael Ponte (eu)
  • treinamento com 4 modulos
  • Divisao dos modulos para 1a sprint
    • 2 primeiros modulos para o release do treinamento
    • Yuri ficou com modulo de JVM
  • Rafael ficou com modulo de Persistencia
@rafaelpontezup
rafaelpontezup / pre-req.js
Created May 3, 2022 13:36 — forked from faermanj/pre-req.js
Postman OIDC
var auth_username = pm.variables.get("auth_username")
var auth_password = pm.variables.get("auth_password")
var client_id = pm.variables.get("client_id")
var client_secret = pm.variables.get("client_secret")
var authBody = `username=${auth_username}&password=${auth_password}&grant_type=password&client_id=${client_id}&client_secret=${client_secret}`;
console.log(authBody)
var force_refresh = true
var token_expires_in = pm.environment.get("token_expires_in");
var token_created = pm.environment.get("token_created");
@rafaelpontezup
rafaelpontezup / NewAuthorController.java
Last active August 19, 2022 22:38
Example of Spring Boot REST Controller using SpringDoc OpenAPI
package br.com.zup.edu.app10.samples.authors;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.headers.Header;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.slf4j.Logger;
@rafaelpontezup
rafaelpontezup / plugin.yaml
Last active August 29, 2022 13:42
Stackspot: playing with edit-xml
hooks:
- type: edit-xml
trigger: after-render
path: pom.xml
encoding: UTF-8
namespaces:
- name: ns
value: "http://maven.apache.org/POM/4.0.0"
- name: xsi
value: "http://www.w3.org/2001/XMLSchema-instance"
@rafaelpontezup
rafaelpontezup / LockManager.kt
Created October 4, 2022 20:25 — forked from soudmaijer/LockManager.kt
Postgres transaction-level advisory lock implementation that uses Spring JDBC
import org.slf4j.LoggerFactory
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Propagation
import org.springframework.transaction.annotation.Transactional
import java.time.Duration
interface LockManager {
fun <T> tryWithLock(key: Long, timeout: Duration, function: () -> T): T
}