INT-102: preliminary refactoring (#14)

This commit is contained in:
Anatoly Karlov 2022-04-18 19:41:26 +07:00 committed by GitHub
parent 989bc610e5
commit 070b454347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 149 additions and 162 deletions

View File

@ -7,4 +7,4 @@ on:
jobs:
build:
uses: valitydev/base-workflow/.github/workflows/maven-library-build.yml@v1
uses: valitydev/java-workflow/.github/workflows/maven-library-build.yml@v1

View File

@ -8,9 +8,10 @@ on:
jobs:
deploy:
uses: valitydev/base-workflow/.github/workflows/maven-library-deploy.yml@v1
uses: valitydev/java-workflow/.github/workflows/maven-library-deploy.yml@v1
secrets:
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_TOKEN }}
deploy-secret-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
deploy-secret-key-password: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
deploy-secret-key-password: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
mm-webhook-url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}

158
pom.xml
View File

@ -8,7 +8,7 @@
<parent>
<groupId>dev.vality</groupId>
<artifactId>library-parent-pom</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<relativePath/>
</parent>
@ -51,28 +51,27 @@
<adapter-thrift-lib.version>1.0.0</adapter-thrift-lib.version>
<adapter-client-lib.version>1.0.1</adapter-client-lib.version>
<spring>5.3.14</spring>
<spring-boot>2.3.8.RELEASE</spring-boot>
<spring>5.3.19</spring>
<spring-boot>2.6.6</spring-boot>
<apache.commons.lang3.version>3.9</apache.commons.lang3.version>
<apache.commons.codec.version>1.12</apache.commons.codec.version>
<apache.commons.lang3.version>3.12.0</apache.commons.lang3.version>
<apache.commons.codec.version>1.15</apache.commons.codec.version>
<slf4j.version>1.7.30</slf4j.version>
<lombok.version>1.18.22</lombok.version>
<jackson.version>2.11.2</jackson.version>
<woody.version>[1.0.4,)</woody.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
<jaxb-core.version>2.3.0.1</jaxb-core.version>
<jaxb-impl.version>2.3.2</jaxb-impl.version>
<slf4j.version>1.7.36</slf4j.version>
<lombok.version>1.18.24</lombok.version>
<jackson.version>2.13.2</jackson.version>
<woody.version>1.0.4</woody.version>
<jaxb-core.version>3.0.2</jaxb-core.version>
<jaxb-impl.version>3.0.2</jaxb-impl.version>
<javax.activation-api.version>1.2.0</javax.activation-api.version>
<logback.version>1.2.3</logback.version>
<logback.version>1.2.11</logback.version>
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
<validation-api.version>2.0.1.Final</validation-api.version>
<damsel.version>1.541-df3e38d</damsel.version>
<damsel.version>1.558-3efe7df</damsel.version>
<cds-proto.version>1.66-01353ce</cds-proto.version>
<logstash-logback-encoder.version>5.3</logstash-logback-encoder.version>
<logstash-logback-encoder.version>7.1.1</logstash-logback-encoder.version>
<error-mapping-java.version>1.0.0</error-mapping-java.version>
</properties>
@ -101,19 +100,52 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback-encoder.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet-api.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>3.0.2</version>
<scope>runtime</scope>
</dependency>
<!-- Spring -->
@ -121,24 +153,28 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>${spring-boot}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>${spring-boot}</version>
<scope>provided</scope>
</dependency>
<!-- RBK.Money -->
<!-- dev.vality -->
<dependency>
<groupId>dev.vality</groupId>
<artifactId>damsel</artifactId>
@ -149,6 +185,12 @@
<groupId>dev.vality.adapter-thrift-lib</groupId>
<artifactId>damsel-utils</artifactId>
<version>${adapter-thrift-lib.version}</version>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
@ -181,84 +223,28 @@
<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<!-- Other -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb-core.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb-impl.version}</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>${javax.activation-api.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet-api.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -1,14 +1,13 @@
package dev.vality.adapter.common.utils.mpi.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@Getter
@Setter
@ToString

View File

@ -1,14 +1,13 @@
package dev.vality.adapter.common.utils.mpi.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@Getter
@Setter
@ToString

View File

@ -1,14 +1,13 @@
package dev.vality.adapter.common.utils.mpi.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@Getter
@Setter
@ToString

View File

@ -1,14 +1,13 @@
package dev.vality.adapter.common.utils.mpi.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@Getter
@Setter
@ToString

View File

@ -5,13 +5,13 @@ import dev.vality.adapter.common.utils.mpi.model.Message;
import dev.vality.adapter.common.utils.mpi.model.PaRes;
import dev.vality.adapter.common.utils.mpi.model.TX;
import dev.vality.adapter.common.utils.mpi.model.ThreeDSecure;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;
import java.util.Optional;

View File

@ -5,8 +5,8 @@ import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.LoggerContextVO;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
@ -15,14 +15,14 @@ import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class PatternMaskingLayoutTest {
private PatternMaskingLayout patternMaskingLayout = new PatternMaskingLayout();
@Before
@BeforeEach
public void init() {
patternMaskingLayout.setPattern("%-5p [%d{ISO8601}] %m%n");
String[] maskPatterns = {"\\b\\d{6}([\\d\\s]{2,9})\\d{4}\\b", "(\\b\\d{3}\\b)"};

View File

@ -2,13 +2,13 @@ package dev.vality.adapter.common.model;
import com.fasterxml.jackson.databind.ObjectMapper;
import dev.vality.adapter.common.mapper.SimpleObjectMapper;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
public class AdapterContextTest {

View File

@ -5,10 +5,10 @@ import dev.vality.cds.storage.ExpDate;
import dev.vality.damsel.domain.BankCard;
import dev.vality.damsel.domain.BankCardExpDate;
import dev.vality.java.cds.utils.model.CardDataProxyModel;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static dev.vality.adapter.common.utils.converter.BankCardUtils.*;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BankCardUtilsTest {

View File

@ -1,14 +1,15 @@
package dev.vality.adapter.common.utils.converter;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class PaymentDataConverterTest {
@Test
public void prepareOrder() {
String prepareOrder = PaymentDataConverter.prepareOrder("1CXKmuvVqEq6", "937");
Assert.assertTrue(Long.parseLong(prepareOrder) > 0);
assertTrue(Long.parseLong(prepareOrder) > 0);
}
}

View File

@ -1,10 +1,10 @@
package dev.vality.adapter.common.utils.converter;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class PostBodyConverterTest {

View File

@ -1,9 +1,9 @@
package dev.vality.adapter.common.utils.encryption;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static dev.vality.adapter.common.utils.encryption.HmacEncryption.calculateHMacSha256;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class HmacEncryptionTest {
@ -16,7 +16,7 @@ public class HmacEncryptionTest {
public void testHMacSha256() {
String expectedHMac = "3fd9ee801d3aeda5d33af83580279ef920ad78e8883a0b9bc3942c74129db2f0";
String hmac = calculateHMacSha256(message, secret);
assertEquals("HMAC SHA256 is not equal expected", expectedHMac, hmac);
assertEquals(expectedHMac, hmac);
}
}

View File

@ -1,7 +1,8 @@
package dev.vality.adapter.common.utils.generator;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public final class IpGeneratorTest {
@ -11,16 +12,16 @@ public final class IpGeneratorTest {
public void checkAndGenerate() {
String expectedIp = "127.0.0.1";
String resultIp = IpGenerator.checkAndGenerate("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
Assert.assertEquals(expectedIp, resultIp);
assertEquals(expectedIp, resultIp);
resultIp = IpGenerator.checkAndGenerate("");
Assert.assertEquals(expectedIp, resultIp);
assertEquals(expectedIp, resultIp);
resultIp = IpGenerator.checkAndGenerate(null);
Assert.assertEquals(expectedIp, resultIp);
assertEquals(expectedIp, resultIp);
resultIp = IpGenerator.checkAndGenerate(IP_V4);
Assert.assertEquals(IP_V4, resultIp);
assertEquals(IP_V4, resultIp);
}
}

View File

@ -1,24 +1,24 @@
package dev.vality.adapter.common.utils.mpi.constant;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class EciDecodeStateTest {
@Test
public void isEciDecodeEnabled() {
Map<String, String> options = new HashMap<>();
assertFalse("Default disabled", EciDecodeState.isEnabled(options));
assertFalse(EciDecodeState.isEnabled(options));
options.put(EciDecodeState.ECI_DECODE, EciDecodeState.ENABLED);
assertTrue("Excepted enabled", EciDecodeState.isEnabled(options));
assertTrue(EciDecodeState.isEnabled(options));
options.put(EciDecodeState.ECI_DECODE, EciDecodeState.DISABLED);
assertFalse("Excepted disabled", EciDecodeState.isEnabled(options));
assertFalse(EciDecodeState.isEnabled(options));
}
}

View File

@ -4,10 +4,11 @@ import dev.vality.adapter.common.utils.mpi.model.Message;
import dev.vality.adapter.common.utils.mpi.model.PaRes;
import dev.vality.adapter.common.utils.mpi.model.TX;
import dev.vality.adapter.common.utils.mpi.model.ThreeDSecure;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertNotNull;
public class ThreeDSecureUtilsTest {

View File

@ -1,9 +1,9 @@
package dev.vality.adapter.common.utils.mpi.utils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class UncompressDecoderTest {

View File

@ -2,16 +2,17 @@ package dev.vality.adapter.common.utils.times;
import dev.vality.adapter.common.model.PollingInfo;
import dev.vality.adapter.common.state.backoff.BackOffExecution;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.time.Instant;
import java.util.HashMap;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ExponentialBackOffPollingServiceTest {
ExponentialBackOffPollingService exponentialBackOffPollingService =
new ExponentialBackOffPollingService<PollingInfo>();
ExponentialBackOffPollingService<PollingInfo> exponentialBackOffPollingService =
new ExponentialBackOffPollingService<>();
@Test
public void testPrepareBackOffExecution() throws InterruptedException {
@ -19,11 +20,11 @@ public class ExponentialBackOffPollingServiceTest {
BackOffExecution backOffExecution =
exponentialBackOffPollingService.prepareBackOffExecution(pollingInfo, new HashMap<>());
Long result = backOffExecution.nextBackOff();
Assert.assertEquals(2, result.longValue());
assertEquals(2, result.longValue());
pollingInfo.setMaxDateTimePolling(Instant.now());
backOffExecution = exponentialBackOffPollingService.prepareBackOffExecution(pollingInfo, new HashMap<>());
result = backOffExecution.nextBackOff();
Assert.assertEquals(2, result.longValue());
assertEquals(2, result.longValue());
}
@Test
@ -34,15 +35,15 @@ public class ExponentialBackOffPollingServiceTest {
BackOffExecution backOffExecution =
exponentialBackOffPollingService.prepareBackOffExecution(pollingInfo, new HashMap<>());
Long result = backOffExecution.nextBackOff();
Assert.assertEquals(2, result.longValue());
assertEquals(2, result.longValue());
Thread.sleep(result * 1000L);
int nextInterval = exponentialBackOffPollingService.prepareNextPollingInterval(pollingInfo, new HashMap<>());
Assert.assertEquals(4, nextInterval);
assertEquals(4, nextInterval);
Thread.sleep(nextInterval * 1000L);
nextInterval = exponentialBackOffPollingService.prepareNextPollingInterval(pollingInfo, new HashMap<>());
Assert.assertEquals(8, nextInterval);
assertEquals(8, nextInterval);
}
@Test
@ -55,15 +56,15 @@ public class ExponentialBackOffPollingServiceTest {
BackOffExecution backOffExecution =
exponentialBackOffPollingService.prepareBackOffExecution(pollingInfo, options);
Long result = backOffExecution.nextBackOff();
Assert.assertEquals(1, result.longValue());
assertEquals(1, result.longValue());
Thread.sleep(result * 1000L);
int nextInterval = exponentialBackOffPollingService.prepareNextPollingInterval(pollingInfo, options);
Assert.assertEquals(2, nextInterval);
assertEquals(2, nextInterval);
Thread.sleep(nextInterval * 1000L);
nextInterval = exponentialBackOffPollingService.prepareNextPollingInterval(pollingInfo, options);
Assert.assertEquals(4, nextInterval);
assertEquals(4, nextInterval);
}
@Test
@ -76,14 +77,14 @@ public class ExponentialBackOffPollingServiceTest {
BackOffExecution backOffExecution =
exponentialBackOffPollingService.prepareBackOffExecution(pollingInfo, options);
Long result = backOffExecution.nextBackOff();
Assert.assertEquals(2, result.longValue());
assertEquals(2, result.longValue());
Thread.sleep(result * 1000L);
int nextInterval = exponentialBackOffPollingService.prepareNextPollingInterval(pollingInfo, options);
Assert.assertEquals(2, nextInterval);
assertEquals(2, nextInterval);
Thread.sleep(nextInterval * 1000L);
nextInterval = exponentialBackOffPollingService.prepareNextPollingInterval(pollingInfo, options);
Assert.assertEquals(2, nextInterval);
assertEquals(2, nextInterval);
}
}