Skip to content

Commit

Permalink
upd: conflito de idempotencia para transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdev01 committed Dec 28, 2024
1 parent 28649d6 commit 6369218
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/main/java/io/github/jpdev/asaassdk/http/Asaas.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public static void setToken(String token) {
Asaas.token = token;
}

public static void clear() {
Asaas.token = null;
Asaas.restClient = null;
}

public static void setTimeout(Integer timeout) {
Asaas.timeout = timeout;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.math.BigDecimal;
import java.util.List;
import java.util.Random;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -26,7 +27,7 @@ static void setup() {
@DisplayName("Integração | Criação de transação Pix com chave")
@Order(1)
void testCreatePixKey() {
BigDecimal value = BigDecimal.valueOf(0.01);
BigDecimal value = Money.create(new Random(100).nextDouble());

Transfer transfer = Transfer.pixAddressKeyCreator()
.setPixAddressKey("+5547999999999")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void testInformedToken() {
@Test
@DisplayName("Teste de token incorreto")
void testIncorrectToken() {
assumeTrue(Asaas.getRestClient() != null, "Token da API não configurado.");

Asaas.setToken("incorrectToken");
Asaas.clear();
Asaas.initSandbox("incorrectToken");
assertThrowsExactly(ConnectionException.class, () -> Payment.reader().read());
Asaas.clear();
}
}

0 comments on commit 6369218

Please sign in to comment.