Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/neo/tx/dto/TransactionRequestDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,22 @@ public class TransactionRequestDto {
@Schema(description = "Optional card fingerprint", example = "fp_9d82kdk29d")
@Size(max = 64)
public String cardFingerprint;

@Override
public String toString() {
return "TransactionRequestDto{" +
"externalId=" + externalId +
", userId=" + userId +
", merchantId=" + merchantId +
", deviceId='" + deviceId + '\'' +
", amount=" + amount +
", currency='" + currency + '\'' +
", initialized=" + initialized +
", merchantCategory='" + merchantCategory + '\'' +
", channel='" + channel + '\'' +
", ipAddress='" + ipAddress + '\'' +
", country='" + country + '\'' +
", cardFingerprint='" + cardFingerprint + '\'' +
'}';
}
}
14 changes: 14 additions & 0 deletions src/main/java/com/neo/tx/dto/ValidationResponseDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,18 @@ public ValidationResponseDto(int score, RiskLevel riskLevel, Decision decision,
this.decision = decision;
this.validationResults = validationResults;
}

@Override
public String toString() {
return "ValidationResponseDto{" +
"id=" + id +
", transactionId=" + transactionId +
", score=" + score +
", riskLevel=" + riskLevel +
", decision=" + decision +
", validationResults=" + validationResults +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
'}';
}
}
11 changes: 10 additions & 1 deletion src/main/java/com/neo/tx/dto/ValidationResultDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ public ValidationResultDto(String code, String description, int scoreDelta) {
this.description = description;
this.scoreDelta = scoreDelta;
}
}

@Override
public String toString() {
return "ValidationResultDto{" +
"code='" + code + '\'' +
", description='" + description + '\'' +
", scoreDelta=" + scoreDelta +
'}';
}
}
19 changes: 9 additions & 10 deletions src/main/java/com/neo/tx/enums/RiskCountry.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,23 @@ public enum RiskCountry {
ZAMBIA("ZMB"),
ZIMBABWE("ZWE");

private final String alpha3;

RiskCountry(String alpha3) {
this.alpha3 = alpha3;
}

public String getAlpha3() {
return alpha3;
}

private static final Map<String, RiskCountry> ALPHA3_MAP =
Arrays.stream(values())
.collect(Collectors.toUnmodifiableMap(
RiskCountry::getAlpha3,
Function.identity()
));
private final String alpha3;

RiskCountry(String alpha3) {
this.alpha3 = alpha3;
}

public static boolean contains(String code) {
return ALPHA3_MAP.containsKey(code);
}

public String getAlpha3() {
return alpha3;
}
}
1 change: 0 additions & 1 deletion src/main/java/com/neo/tx/message_broker/Publisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.neo.tx.model.OutboxEvent;
import com.neo.tx.repository.EventOutboxRepository;
import jakarta.transaction.Transactional;
import org.apache.juli.logging.Log;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
Expand Down
33 changes: 20 additions & 13 deletions src/main/java/com/neo/tx/model/OutboxEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,30 @@ public enum Status {NEW, SENT, FAILED}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "aggregate_type", nullable = false, length = 64)
private String aggregateType;

@Column(name = "aggregate_id", nullable = false, length = 64)
private String aggregateId;

@Column(name = "event_type", nullable = false, length = 128)
private String eventType;

@Column(name = "topic", nullable = false, length = 255)
private String topic;

@Column(name = "event_key", nullable = false, length = 128)
private String eventKey;

@JdbcTypeCode(SqlTypes.JSON)
@Column(name = "payload", columnDefinition = "jsonb", nullable = false)
private String payload;

@Enumerated(EnumType.STRING)
@Column(name = "status", nullable = false, length = 16)
private Status status;

@Column(name = "attempts", nullable = false)
private Integer attempts;

@Column(name = "last_error")
private String lastError;

@Column(name = "available_at", nullable = false)
private Instant availableAt;

@Column(name = "created_at", nullable = false, updatable = false)
private Instant createdAt;

@Column(name = "updated_at", nullable = false)
private Instant updatedAt;

Expand Down Expand Up @@ -181,4 +169,23 @@ public Instant getUpdatedAt() {
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
}

@Override
public String toString() {
return "OutboxEvent{" +
"id=" + id +
", aggregateType='" + aggregateType + '\'' +
", aggregateId='" + aggregateId + '\'' +
", eventType='" + eventType + '\'' +
", topic='" + topic + '\'' +
", eventKey='" + eventKey + '\'' +
", payload='" + payload + '\'' +
", status=" + status +
", attempts=" + attempts +
", lastError='" + lastError + '\'' +
", availableAt=" + availableAt +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
'}';
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/neo/tx/model/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,26 @@ public Instant getUpdatedAt() {
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}

@Override
public String toString() {
return "Transaction{" +
"id=" + id +
", externalId=" + externalId +
", userId=" + userId +
", amount=" + amount +
", currency='" + currency + '\'' +
", initialized=" + initialized +
", merchantCategory='" + merchantCategory + '\'' +
", merchantId=" + merchantId +
", channel='" + channel + '\'' +
", ipAddress='" + ipAddress + '\'' +
", country='" + country + '\'' +
", deviceId='" + deviceId + '\'' +
", cardFingerprint='" + cardFingerprint + '\'' +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
", validation=" + validation +
'}';
}
}
14 changes: 14 additions & 0 deletions src/main/java/com/neo/tx/model/Validation.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,18 @@ public Instant getUpdatedAt() {
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}

@Override
public String toString() {
return "Validation{" +
"id=" + id +
", transaction=" + transaction +
", score=" + score +
", riskLevel=" + riskLevel +
", decision=" + decision +
", triggeredValidators=" + triggeredValidators +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.neo.tx.repository.specification;

import com.neo.tx.model.OutboxEvent;
import com.neo.tx.model.Validation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

public interface EventOutboxJpaRepository extends JpaRepository<OutboxEvent, Long>, JpaSpecificationExecutor<OutboxEvent> {

}
Empty file.
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
package com.neo.tx.integration;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

@SpringBootTest
@Testcontainers
@ActiveProfiles("test")
@AutoConfigureMockMvc
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractIntegrationTest {
public abstract class IntegrationTestConfig {

@Autowired
JdbcTemplate jdbc;

@BeforeEach
void clean() {
jdbc.execute("TRUNCATE TABLE validation RESTART IDENTITY CASCADE");
jdbc.execute("TRUNCATE TABLE transaction RESTART IDENTITY CASCADE");
jdbc.execute("TRUNCATE TABLE event_outbox RESTART IDENTITY CASCADE");
}

@Container
@SuppressWarnings("resource")
private static final PostgreSQLContainer<?> POSTGRES = new PostgreSQLContainer<>("postgres:17.7-alpine")
.withDatabaseName("test_transaction")
.withUsername("test_marshmallow")
.withPassword("test_tasty");

static {
POSTGRES.start();
}

@DynamicPropertySource
static void configureDataSource(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", POSTGRES::getJdbcUrl);
registry.add("spring.datasource.username", POSTGRES::getUsername);
registry.add("spring.datasource.password", POSTGRES::getPassword);
registry.add("spring.liquibase.enabled", () -> "true");
}
}
}

This file was deleted.

Loading