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
30 changes: 21 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>dev.vality</groupId>
<artifactId>service-parent-pom</artifactId>
<version>3.1.7</version>
<version>3.1.9</version>
</parent>

<artifactId>daway</artifactId>
Expand All @@ -33,6 +33,18 @@
<flyway.postgresql.transactional.lock>false</flyway.postgresql.transactional.lock>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>2.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!--spring -->
<dependency>
Expand Down Expand Up @@ -165,12 +177,12 @@
<dependency>
<groupId>dev.vality</groupId>
<artifactId>damsel</artifactId>
<version>1.674-368f05b</version>
<version>1.682-dfd6648</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>fistful-proto</artifactId>
<version>1.185-b30fa2a</version>
<version>1.188-f7ce08e</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
Expand Down Expand Up @@ -202,12 +214,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>testcontainers-annotations</artifactId>
<version>2.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
Expand All @@ -219,6 +225,12 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>testcontainers-annotations</artifactId>
<version>4.1.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public void handle(TimestampedChange timestampedChange, MachineEvent event) {
withdrawal.setAmount(cash.getAmount());
withdrawal.setCurrencyCode(cash.getCurrency().getSymbolicCode());
withdrawal.setWithdrawalStatus(WithdrawalStatus.pending);
if (withdrawalDamsel.isSetContactInfo() && withdrawalDamsel.getContactInfo().isSetEmail()) {
withdrawal.setCustomerId(withdrawalDamsel.getContactInfo().email);
}
if (withdrawalDamsel.getRoute() != null && withdrawalDamsel.getRoute().isSetTerminalId()) {
withdrawal.setTerminalId(String.valueOf(withdrawalDamsel.getRoute().getTerminalId()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE dw.withdrawal ADD COLUMN IF NOT EXISTS customer_id character varying;
2 changes: 1 addition & 1 deletion src/test/java/dev/vality/daway/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

@Slf4j
@PostgresqlSpringBootITest
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_CLASS)
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
class IntegrationTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package dev.vality.daway.config;

import dev.vality.daway.kafka.KafkaProducer;
import dev.vality.testcontainers.annotations.DefaultSpringBootTest;
import dev.vality.testcontainers.annotations.KafkaTestConfig;
import dev.vality.testcontainers.annotations.kafka.KafkaTestcontainerSingleton;
import dev.vality.testcontainers.annotations.postgresql.PostgresqlTestcontainerSingleton;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;

import java.lang.annotation.ElementType;
Expand Down Expand Up @@ -42,7 +43,8 @@
"kafka.topics.limit-config.id",
"kafka.topics.exrate.id"}
)
@DefaultSpringBootTest
@SpringBootTest
@KafkaTestConfig
@Import(KafkaProducer.class)
public @interface KafkaPostgresqlSpringBootITest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.vality.testcontainers.annotations.postgresql.PostgresqlTestcontainerSingleton;
import org.springframework.boot.test.autoconfigure.jooq.JooqTest;
import org.springframework.boot.test.context.SpringBootTest;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.vality.daway.config;

import dev.vality.testcontainers.annotations.DefaultSpringBootTest;
import dev.vality.testcontainers.annotations.postgresql.PostgresqlTestcontainerSingleton;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -10,7 +11,7 @@

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@SpringBootTest
@PostgresqlTestcontainerSingleton
@DefaultSpringBootTest
public @interface PostgresqlSpringBootITest {
}
5 changes: 3 additions & 2 deletions src/test/java/dev/vality/daway/dao/DaoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,17 @@ void invoiceCartDaoTest() {

@Test
void paymentRecurrentInfoDaoTest() {
Random random = new Random();
jdbcTemplate.execute("truncate table dw.payment_recurrent_info cascade");
List<PaymentRecurrentInfo> list = RandomBeans.randomListOf(2, PaymentRecurrentInfo.class);
List<PaymentRecurrentInfo> list = RandomBeans.randomListOf(random.nextLong(), 2, PaymentRecurrentInfo.class);
list.forEach(statusInfo -> statusInfo.setCurrent(true));
paymentRecurrentInfoDao.saveBatch(list);
PaymentRecurrentInfo first = list.get(0);
assertEquals(first, paymentRecurrentInfoDao.get(first.getInvoiceId(), first.getPaymentId()));
PaymentRecurrentInfo second = list.get(1);
assertEquals(second, paymentRecurrentInfoDao.get(second.getInvoiceId(), second.getPaymentId()));

PaymentRecurrentInfo third = RandomBeans.random(PaymentRecurrentInfo.class);
PaymentRecurrentInfo third = RandomBeans.random(random.nextLong(), PaymentRecurrentInfo.class);
third.setId(first.getId() + 1);
third.setCurrent(false);
third.setInvoiceId(first.getInvoiceId());
Expand Down
11 changes: 7 additions & 4 deletions src/test/java/dev/vality/daway/dao/partition/DaoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.Set;

import static dev.vality.daway.domain.tables.Invoice.INVOICE;
Expand Down Expand Up @@ -110,10 +111,11 @@ void invoiceStatusInfoDaoTest() {

@Test
void paymentDaoTest() {
Payment first = RandomBeans.random(Payment.class);
Random random = new Random();
Payment first = RandomBeans.random(random.nextLong(100), Payment.class);
first.setId(1L);
first.setEventCreatedAt(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS));
Payment second = RandomBeans.random(Payment.class);
Payment second = RandomBeans.random(random.nextLong(100),Payment.class);
second.setId(2L);
second.setEventCreatedAt(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS));
paymentDao.saveBatch(Arrays.asList(first, second));
Expand Down Expand Up @@ -145,9 +147,10 @@ void paymentStatusInfoDaoTest() {

@Test
void paymentPayerInfoDaoTest() {
PaymentPayerInfo first = RandomBeans.random(PaymentPayerInfo.class);
Random random = new Random();
PaymentPayerInfo first = RandomBeans.random(random.nextLong(100), PaymentPayerInfo.class);
first.setId(1L);
PaymentPayerInfo second = RandomBeans.random(PaymentPayerInfo.class);
PaymentPayerInfo second = RandomBeans.random(random.nextLong(100), PaymentPayerInfo.class);
second.setId(2L);
paymentPayerInfoDao.saveBatch(Arrays.asList(first, second));
assertEquals(first, paymentPayerInfoDao.get(first.getInvoiceId(), first.getPaymentId()));
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/dev/vality/daway/kafka/KafkaProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import dev.vality.damsel.domain_config_v2.HistoricalCommit;
import dev.vality.machinegun.eventsink.MachineEvent;
import dev.vality.machinegun.eventsink.SinkEvent;
import dev.vality.testcontainers.annotations.kafka.config.KafkaProducerConfig;
import dev.vality.testcontainers.annotations.KafkaTestConfig;
import dev.vality.testcontainers.annotations.kafka.config.KafkaProducerTestConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.thrift.TBase;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -17,7 +18,7 @@
import java.util.Collections;

@TestComponent
@Import(KafkaProducerConfig.class)
@Import(KafkaProducerTestConfig.class)
@Slf4j
public class KafkaProducer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.jupiter.api.Assertions.*;

@PostgresqlSpringBootITest
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_CLASS)
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
class IntegrationInvoicingServiceTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.test.context.jdbc.Sql;

import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand All @@ -23,7 +24,7 @@
import static org.junit.jupiter.api.Assertions.*;

@PostgresqlSpringBootITest
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_CLASS)
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
class InvoiceWrapperServiceTest {

@Autowired
Expand Down Expand Up @@ -59,11 +60,12 @@ void duplicationTest() {
}

private List<InvoiceWrapper> prepareInvoiceWrappers() {
Random random = new Random();
List<InvoiceWrapper> invoiceWrappers = IntStream.range(1, 5)
.mapToObj(x -> new InvoiceWrapper(
RandomBeans.random(Invoice.class, "id"),
RandomBeans.random(InvoiceStatusInfo.class, "id", "invoiceId"),
RandomBeans.randomListOf(3, InvoiceCart.class, "id", "invoiceId")))
RandomBeans.random(random.nextLong(), Invoice.class, "id"),
RandomBeans.random(random.nextLong(), InvoiceStatusInfo.class, "id", "invoiceId"),
RandomBeans.randomListOf(random.nextLong(), 3, InvoiceCart.class, "id", "invoiceId")))
.collect(Collectors.toList());

invoiceWrappers.forEach(iw -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import java.time.temporal.ChronoUnit;
import java.util.HashSet;
import java.util.List;
import java.util.Random;

import static dev.vality.daway.utils.JdbcUtil.countEntities;
import static dev.vality.daway.utils.JdbcUtil.countPaymentEntity;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;

@PostgresqlSpringBootITest
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_CLASS)
@Sql(scripts = {"classpath:sql/partition_idx.sql"}, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
class PaymentWrapperServiceTest {

@Autowired
Expand Down Expand Up @@ -88,14 +89,15 @@ void duplicationTest() {
}

private List<PaymentWrapper> preparePaymentWrappers() {
Random random = new Random();
List<PaymentWrapper> paymentWrappers = RandomBeans.randomListOf(2, PaymentWrapper.class);
paymentWrappers.stream()
.map(PaymentWrapper::getPayment)
.forEach(payment -> payment.setEventCreatedAt(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS)));
paymentWrappers.forEach(pw -> {
pw.setCashFlowWrapper(new CashFlowWrapper(
RandomBeans.random(CashFlowLink.class),
RandomBeans.randomListOf(3, CashFlow.class)
RandomBeans.randomListOf(random.nextLong(100), 3, CashFlow.class)
));
pw.getCashFlowWrapper().getCashFlows().forEach(cf -> cf.setObjType(PaymentChangeType.payment));
PaymentWrapperTestUtil.setCurrent(pw, true);
Expand Down
5 changes: 3 additions & 2 deletions src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<root level="warn">
<appender-ref ref="CONSOLE"/>
</root>
<logger name="com.empayre" level="ALL"/>
<logger name="dev.vality" level="ALL"/>
<logger name="com.empayre" level="INFO"/>
<logger name="dev.vality" level="INFO"/>
<logger name="org.apache" level="ERROR"/>
</configuration>
Loading