Merge pull request #30 from rbkmoney/ft/JD-733/remove_p2p

JD-733: upd proto, migrate to Java 15 and JUnit5
This commit is contained in:
mr-impossibru 2021-10-20 17:01:55 +03:00 committed by GitHub
commit fda74ddddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 53 additions and 48 deletions

7
Jenkinsfile vendored
View File

@ -5,12 +5,11 @@ build('fraudbusters-mg-connector', 'java-maven') {
def javaServicePipeline def javaServicePipeline
runStage('load JavaService pipeline') { runStage('load JavaService pipeline') {
javaServicePipeline = load("build_utils/jenkins_lib/pipeJavaService.groovy") javaServicePipeline = load("build_utils/jenkins_lib/pipeJavaServiceInsideDocker.groovy")
} }
def serviceName = env.REPO_NAME def serviceName = env.REPO_NAME
def mvnArgs = '-DjvmArgs="-Xmx256m"' def mvnArgs = '-DjvmArgs="-Xmx256m"'
def useJava11 = true
javaServicePipeline(serviceName, useJava11, mvnArgs) javaServicePipeline(serviceName, mvnArgs)
} }

@ -1 +1 @@
Subproject commit 24aa772730be966667adb285a09fcb494d4f218e Subproject commit be44d69fc87b22a0bb82d98d6eae7658d1647f98

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.rbkmoney</groupId> <groupId>com.rbkmoney</groupId>
<artifactId>service-parent-pom</artifactId> <artifactId>service-parent-pom</artifactId>
<version>1.2.7</version> <version>2.0.9</version>
</parent> </parent>
<artifactId>fraudbusters-mg-connector</artifactId> <artifactId>fraudbusters-mg-connector</artifactId>
@ -25,7 +25,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<machinegun-proto.version>1.18-d814d69</machinegun-proto.version> <machinegun-proto.version>1.18-d814d69</machinegun-proto.version>
<fraudbusters-proto.version>1.96-81934f5</fraudbusters-proto.version> <fraudbusters-proto.version>1.97-28a6a95</fraudbusters-proto.version>
<fistful-proto.version>1.128-d331fce</fistful-proto.version> <fistful-proto.version>1.128-d331fce</fistful-proto.version>
</properties> </properties>
@ -131,13 +131,13 @@
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId> <artifactId>testcontainers</artifactId>
<version>1.15.0</version> <version>1.16.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId> <artifactId>kafka</artifactId>
<version>1.15.0</version> <version>1.16.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -21,13 +21,13 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.thrift.TException; import org.apache.thrift.TException;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.stubbing.OngoingStubbing; import org.mockito.stubbing.OngoingStubbing;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.io.IOException; import java.io.IOException;
import java.time.Duration; import java.time.Duration;
@ -40,7 +40,7 @@ import static org.mockito.Mockito.any;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@Slf4j @Slf4j
@RunWith(SpringRunner.class) @ExtendWith(SpringExtension.class)
@SpringBootTest(classes = FraudbustersMgConnectorApplication.class, @SpringBootTest(classes = FraudbustersMgConnectorApplication.class,
properties = { properties = {
"stream.withdrawal.debug=false", "stream.withdrawal.debug=false",

View File

@ -19,13 +19,13 @@ import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.config.SslConfigs; import org.apache.kafka.common.config.SslConfigs;
import org.apache.kafka.common.serialization.StringDeserializer; import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.thrift.TException; import org.apache.thrift.TException;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -40,8 +40,8 @@ import static org.mockito.ArgumentMatchers.any;
//Test for real big data set //Test for real big data set
//Need get truststore pcsng-kafka by devops //Need get truststore pcsng-kafka by devops
@Slf4j @Slf4j
@Ignore @Disabled
@RunWith(SpringRunner.class) @ExtendWith(SpringExtension.class)
@SpringBootTest(classes = FraudbustersMgConnectorApplication.class) @SpringBootTest(classes = FraudbustersMgConnectorApplication.class)
public class IntegrationTest extends KafkaAbstractTest { public class IntegrationTest extends KafkaAbstractTest {

View File

@ -1,5 +1,6 @@
package com.rbkmoney.fraudbusters.mg.connector; package com.rbkmoney.fraudbusters.mg.connector;
import com.rbkmoney.fraudbusters.mg.connector.extension.KafkaExtension;
import com.rbkmoney.fraudbusters.mg.connector.serde.deserializer.MachineEventDeserializer; import com.rbkmoney.fraudbusters.mg.connector.serde.deserializer.MachineEventDeserializer;
import com.rbkmoney.kafka.common.serialization.ThriftSerializer; import com.rbkmoney.kafka.common.serialization.ThriftSerializer;
import com.rbkmoney.machinegun.eventsink.SinkEvent; import com.rbkmoney.machinegun.eventsink.SinkEvent;
@ -13,16 +14,14 @@ import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.StringDeserializer; import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer; import org.apache.kafka.common.serialization.StringSerializer;
import org.junit.ClassRule; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.testcontainers.containers.KafkaContainer;
import java.time.Duration; import java.time.Duration;
import java.util.Collections; import java.util.Collections;
@ -31,13 +30,12 @@ import java.util.Properties;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@Slf4j @Slf4j
@RunWith(SpringRunner.class) @ExtendWith({SpringExtension.class, KafkaExtension.class})
@SpringBootTest(webEnvironment = RANDOM_PORT) @SpringBootTest(webEnvironment = RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@ContextConfiguration(initializers = KafkaAbstractTest.Initializer.class) @ContextConfiguration(initializers = KafkaAbstractTest.Initializer.class)
public abstract class KafkaAbstractTest { public abstract class KafkaAbstractTest {
public static final String KAFKA_DOCKER_VERSION = "5.0.1";
public static final String MG_EVENT = "mg-event"; public static final String MG_EVENT = "mg-event";
public static final String MG_WITHDRAWAL = "mg-withdrawal"; public static final String MG_WITHDRAWAL = "mg-withdrawal";
public static final String PAYMENT = "payment"; public static final String PAYMENT = "payment";
@ -45,12 +43,9 @@ public abstract class KafkaAbstractTest {
public static final String CHARGEBACK = "chargeback"; public static final String CHARGEBACK = "chargeback";
public static final String WITHDRAWAL = "withdrawal"; public static final String WITHDRAWAL = "withdrawal";
@ClassRule
public static KafkaContainer kafka = new KafkaContainer(KAFKA_DOCKER_VERSION).withEmbeddedZookeeper();
public static <T> Consumer<String, T> createConsumer() { public static <T> Consumer<String, T> createConsumer() {
Properties props = new Properties(); Properties props = new Properties();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, KafkaExtension.KAFKA.getBootstrapServers());
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, MachineEventDeserializer.class); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, MachineEventDeserializer.class);
props.put(ConsumerConfig.GROUP_ID_CONFIG, "test"); props.put(ConsumerConfig.GROUP_ID_CONFIG, "test");
@ -60,7 +55,7 @@ public abstract class KafkaAbstractTest {
public static <T> Consumer<String, T> createPaymentConsumer(Class clazz) { public static <T> Consumer<String, T> createPaymentConsumer(Class clazz) {
Properties props = new Properties(); Properties props = new Properties();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, KafkaExtension.KAFKA.getBootstrapServers());
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, clazz); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, clazz);
props.put(ConsumerConfig.GROUP_ID_CONFIG, "test"); props.put(ConsumerConfig.GROUP_ID_CONFIG, "test");
@ -70,7 +65,7 @@ public abstract class KafkaAbstractTest {
public static <T> Producer<String, T> createProducer() { public static <T> Producer<String, T> createProducer() {
Properties props = new Properties(); Properties props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, KafkaExtension.KAFKA.getBootstrapServers());
props.put(ProducerConfig.CLIENT_ID_CONFIG, "CLIENT"); props.put(ProducerConfig.CLIENT_ID_CONFIG, "CLIENT");
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ThriftSerializer.class); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ThriftSerializer.class);
@ -93,7 +88,7 @@ public abstract class KafkaAbstractTest {
@Override @Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) { public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
TestPropertyValues TestPropertyValues
.of("kafka.bootstrap.servers=" + kafka.getBootstrapServers()) .of("kafka.bootstrap.servers=" + KafkaExtension.KAFKA.getBootstrapServers())
.applyTo(configurableApplicationContext.getEnvironment()); .applyTo(configurableApplicationContext.getEnvironment());
initTopic(MG_EVENT); initTopic(MG_EVENT);
initTopic(PAYMENT); initTopic(PAYMENT);

View File

@ -0,0 +1,23 @@
package com.rbkmoney.fraudbusters.mg.connector.extension;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.utility.DockerImageName;
public class KafkaExtension implements BeforeAllCallback {
public static KafkaContainer KAFKA;
private static final String CONFLUENT_IMAGE_NAME = "confluentinc/cp-kafka";
private static final String CONFLUENT_PLATFORM_VERSION = "6.0.3";
@Override
public void beforeAll(ExtensionContext extensionContext) {
KAFKA = new org.testcontainers.containers.KafkaContainer(DockerImageName
.parse(CONFLUENT_IMAGE_NAME)
.withTag(CONFLUENT_PLATFORM_VERSION))
.withEmbeddedZookeeper();
KAFKA.start();
}
}

View File

@ -17,12 +17,12 @@ import com.rbkmoney.fraudbusters.mg.connector.service.WalletClientService;
import com.rbkmoney.fraudbusters.mg.connector.service.WithdrawalClientService; import com.rbkmoney.fraudbusters.mg.connector.service.WithdrawalClientService;
import com.rbkmoney.machinegun.eventsink.MachineEvent; import com.rbkmoney.machinegun.eventsink.MachineEvent;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit.jupiter.SpringExtension;
import static com.rbkmoney.fraudbusters.mg.connector.mapper.impl.WithdrawalBeanUtils.*; import static com.rbkmoney.fraudbusters.mg.connector.mapper.impl.WithdrawalBeanUtils.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -30,7 +30,7 @@ import static org.mockito.Mockito.when;
@Slf4j @Slf4j
@RunWith(SpringRunner.class) @ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {FistfulAccountToDomainAccountConverter.class, @ContextConfiguration(classes = {FistfulAccountToDomainAccountConverter.class,
FistfulCashToDomainCashConverter.class, FistfulCashToDomainCashConverter.class,
FistfulCurrencyToDomainCurrencyConverter.class, FistfulCurrencyToDomainCurrencyConverter.class,

View File

@ -13,7 +13,6 @@ import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.geck.serializer.kit.mock.MockMode; import com.rbkmoney.geck.serializer.kit.mock.MockMode;
import com.rbkmoney.geck.serializer.kit.mock.MockTBaseProcessor; import com.rbkmoney.geck.serializer.kit.mock.MockTBaseProcessor;
import com.rbkmoney.geck.serializer.kit.tbase.TBaseHandler; import com.rbkmoney.geck.serializer.kit.tbase.TBaseHandler;
import org.jetbrains.annotations.NotNull;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;

View File

@ -43,17 +43,6 @@ public class MgEventSinkFlowGenerator {
return sinkEvents; return sinkEvents;
} }
public static List<SinkEvent> generateSuccessNotFullFlow(String sourceId) {
List<SinkEvent> sinkEvents = new ArrayList<>();
Long sequenceId = 0L;
sinkEvents.add(createSinkEvent(createMessageCreateInvoice(sourceId, sequenceId++)));
sinkEvents.add(createSinkEvent(createMessagePaymentPending(sourceId, sequenceId++)));
sinkEvents.add(createSinkEvent(createMessagePaymentPending(sourceId, sequenceId++)));
sinkEvents.add(createSinkEvent(createMessagePaymentPending(sourceId, sequenceId++)));
sinkEvents.add(createSinkEvent(createMessagePaymentProcessed(sourceId, sequenceId)));
return sinkEvents;
}
public static List<SinkEvent> generateRefundedFlow(String sourceId) { public static List<SinkEvent> generateRefundedFlow(String sourceId) {
List<SinkEvent> sinkEvents = new ArrayList<>(); List<SinkEvent> sinkEvents = new ArrayList<>();
Long sequenceId = 0L; Long sequenceId = 0L;