JD-733: upd proto, migrate to Java 15 and JUnit5

This commit is contained in:
v.hramov 2021-10-20 16:33:24 +03:00
parent 99c3c383f7
commit af4dd19e4f
No known key found for this signature in database
GPG Key ID: B921FAEB29A65794
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
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 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>
<groupId>com.rbkmoney</groupId>
<artifactId>service-parent-pom</artifactId>
<version>1.2.7</version>
<version>2.0.9</version>
</parent>
<artifactId>fraudbusters-mg-connector</artifactId>
@ -25,7 +25,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<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>
</properties>
@ -131,13 +131,13 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.15.0</version>
<version>1.16.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<version>1.15.0</version>
<version>1.16.0</version>
<scope>test</scope>
</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.ConsumerRecords;
import org.apache.thrift.TException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.stubbing.OngoingStubbing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
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.time.Duration;
@ -40,7 +40,7 @@ import static org.mockito.Mockito.any;
import static org.mockito.Mockito.when;
@Slf4j
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = FraudbustersMgConnectorApplication.class,
properties = {
"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.serialization.StringDeserializer;
import org.apache.thrift.TException;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest;
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.IOException;
@ -40,8 +40,8 @@ import static org.mockito.ArgumentMatchers.any;
//Test for real big data set
//Need get truststore pcsng-kafka by devops
@Slf4j
@Ignore
@RunWith(SpringRunner.class)
@Disabled
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = FraudbustersMgConnectorApplication.class)
public class IntegrationTest extends KafkaAbstractTest {

View File

@ -1,5 +1,6 @@
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.kafka.common.serialization.ThriftSerializer;
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.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;
import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.testcontainers.containers.KafkaContainer;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.time.Duration;
import java.util.Collections;
@ -31,13 +30,12 @@ import java.util.Properties;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@Slf4j
@RunWith(SpringRunner.class)
@ExtendWith({SpringExtension.class, KafkaExtension.class})
@SpringBootTest(webEnvironment = RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@ContextConfiguration(initializers = KafkaAbstractTest.Initializer.class)
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_WITHDRAWAL = "mg-withdrawal";
public static final String PAYMENT = "payment";
@ -45,12 +43,9 @@ public abstract class KafkaAbstractTest {
public static final String CHARGEBACK = "chargeback";
public static final String WITHDRAWAL = "withdrawal";
@ClassRule
public static KafkaContainer kafka = new KafkaContainer(KAFKA_DOCKER_VERSION).withEmbeddedZookeeper();
public static <T> Consumer<String, T> createConsumer() {
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.VALUE_DESERIALIZER_CLASS_CONFIG, MachineEventDeserializer.class);
props.put(ConsumerConfig.GROUP_ID_CONFIG, "test");
@ -60,7 +55,7 @@ public abstract class KafkaAbstractTest {
public static <T> Consumer<String, T> createPaymentConsumer(Class clazz) {
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.VALUE_DESERIALIZER_CLASS_CONFIG, clazz);
props.put(ConsumerConfig.GROUP_ID_CONFIG, "test");
@ -70,7 +65,7 @@ public abstract class KafkaAbstractTest {
public static <T> Producer<String, T> createProducer() {
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.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ThriftSerializer.class);
@ -93,7 +88,7 @@ public abstract class KafkaAbstractTest {
@Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
TestPropertyValues
.of("kafka.bootstrap.servers=" + kafka.getBootstrapServers())
.of("kafka.bootstrap.servers=" + KafkaExtension.KAFKA.getBootstrapServers())
.applyTo(configurableApplicationContext.getEnvironment());
initTopic(MG_EVENT);
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.machinegun.eventsink.MachineEvent;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
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 org.junit.Assert.*;
@ -30,7 +30,7 @@ import static org.mockito.Mockito.when;
@Slf4j
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {FistfulAccountToDomainAccountConverter.class,
FistfulCashToDomainCashConverter.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.MockTBaseProcessor;
import com.rbkmoney.geck.serializer.kit.tbase.TBaseHandler;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.nio.ByteBuffer;

View File

@ -43,17 +43,6 @@ public class MgEventSinkFlowGenerator {
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) {
List<SinkEvent> sinkEvents = new ArrayList<>();
Long sequenceId = 0L;