Skip to content
Merged

fix #29

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: 0 additions & 4 deletions src/main/java/dev/vality/binbase/config/BatchConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
Expand All @@ -30,7 +29,6 @@
import org.springframework.batch.item.support.builder.ClassifierCompositeItemProcessorBuilder;
import org.springframework.batch.item.xml.StaxEventItemReader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
Expand All @@ -40,8 +38,6 @@
import java.util.Map;

@Configuration
@EnableBatchProcessing
@EnableAutoConfiguration
@RequiredArgsConstructor
public class BatchConfig {

Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ management:
server:
port: ${management.port}
metrics:
export:
prometheus:
enabled: false
tags:
application: wb-list-manager
endpoint:
Expand All @@ -40,6 +37,10 @@ management:
web:
exposure:
include: health,info,prometheus
prometheus:
metrics:
export:
enabled: false

client:
cds:
Expand Down
45 changes: 11 additions & 34 deletions src/test/java/dev/vality/binbase/batch/BatchUploadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

import dev.vality.binbase.config.PostgresqlTest;
import dev.vality.binbase.domain.CountryCode;
import dev.vality.damsel.binbase.*;
import dev.vality.damsel.binbase.BinNotFound;
import dev.vality.damsel.binbase.BinbaseSrv;
import dev.vality.damsel.binbase.CardType;
import dev.vality.damsel.binbase.Last;
import dev.vality.damsel.binbase.Reference;
import dev.vality.damsel.binbase.ResponseData;
import dev.vality.woody.thrift.impl.http.THSpawnClientBuilder;
import org.apache.thrift.TException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.TestPropertySource;

import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;


//@TestPropertySource(properties = {"batch.file_path=classpath:/data/binbase/case1", "batch.strict_mode=false"})
@TestPropertySource(properties = {"batch.file_path=classpath:/data/binbase/case1", "batch.strict_mode=false"})
@PostgresqlTest
@SpringBootTest(webEnvironment = RANDOM_PORT)
class BatchUploadTest {
Expand All @@ -36,29 +36,6 @@ class BatchUploadTest {

private BinbaseSrv.Iface binbaseClient;

private static Path tempDir;

@BeforeAll
static void init() throws Exception {
tempDir = Files.createTempDirectory("binbase-case1");

Resource[] resources = new PathMatchingResourcePatternResolver()
.getResources("classpath:/data/binbase/case1/*.csv");

for (Resource resource : resources) {
Path dest = tempDir.resolve(resource.getFilename());
Files.copy(resource.getInputStream(), dest, StandardCopyOption.REPLACE_EXISTING);
}

System.out.println("✅ Copied test CSVs to: " + tempDir.toAbsolutePath());
}

@DynamicPropertySource
static void overrideProps(DynamicPropertyRegistry registry) {
registry.add("batch.file_path", () -> tempDir.toAbsolutePath().toString());
registry.add("batch.strict_mode", () -> "false");
}

@BeforeEach
public void setup() throws URISyntaxException {
binbaseClient = new THSpawnClientBuilder()
Expand Down
11 changes: 2 additions & 9 deletions src/test/resources/data/binbase/case1/V1_binbase_1.2.0.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
bin,countryCode,cardType,version
100001,USA,credit,3
100001,USA,credit_or_debit,2
100001,CA,,1
100115,,,
100117,,,
430288,AW,,1
4302885002,AW,,4

100001;PRIVATE LABEL;CENTRAL SUPPLIES - TDFS;;;CANADA;CA;CAN;124;;;;;
100115;UATP;;;;;;;0;;;;;
5 changes: 2 additions & 3 deletions src/test/resources/data/binbase/case1/V2_binbase_1.2.5.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
bin,countryCode,cardType,version
100001,USA,credit_or_debit,3
100117,USA,credit,1
100001;PRIVATE LABEL;CENTRAL SUPPLIES - TDFS;DEBIT OR CREDIT;;CANADA;US;USA;840;;;;;
100117;UATP;AMERICAN AIRLINES (AA);CREDIT;;UNITED STATES;US;USA;840;;;;;
7 changes: 3 additions & 4 deletions src/test/resources/data/binbase/case1/V3_binbase_1.3.0.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bin,countryCode,cardType,version
100001,USA,credit,3
100117,USA,credit,1
999999,USA,credit,1
100001;UATP;AMERICAN AIRLINES (AA);CREDIT;;UNITED STATES;US;USA;840;;;;;
100117;UATP;AMERICAN AIRLINES (AA);CREDIT;;UNITED STATES;US;USA;840;;;;;
999999;UATP;AMERICAN AIRLINES (AA);CREDIT;;UNITED STATES;US;USA;840;;;;;
4 changes: 2 additions & 2 deletions src/test/resources/data/binbase/case1/V4_binbase_1.3.5.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bin,countryCode,cardType,version
4302885,ABW,credit,1
4302885;VISA;ARUBA;CREDIT;PLATINUM;ARUBA;AW;ABW;533;HTTP://WWW.ARUBABANK.COM/;(+297) 527 7777;;;
4302885;VISA;ARUBA BANK N.V.;CREDIT;PLATINUM;ARUBA;AW;ABW;533;HTTP://WWW.ARUBABANK.COM/;(+297) 527 7777;;;
5 changes: 2 additions & 3 deletions src/test/resources/data/binbase/case1/V5_binbase_1.4.0.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
bin,countryCode,cardType,version
430288,ABW,credit,1
4302885,ABW,credit,2
430288;VISA;ARUBA N.V.;CREDIT;PLATINUM;ARUBA;AW;ABW;533;HTTP://WWW.ARUBABANK.COM/;(+297) 527 7777;;;
4302885;VISA;BANK N.V.;CREDIT;PLATINUM;ARUBA;AW;ABW;533;HTTP://WWW.ARUBABANK.COM/;(+297) 527 7777;;;
61 changes: 30 additions & 31 deletions src/test/resources/data/binbase/case1/V6_binbase_1.8.5.csv
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
bin,countryCode,cardType,version
1244,BRA,,1
2102,CHN,credit,1
2195,CHN,debit,1
2201,CHN,debit,1
2239,CHN,debit,1
2361,CHN,credit,1
4078,USA,debit,1
4080,USA,debit,1
7343,BRA,debit,1
10051,ITA,debit,1
10053,ITA,debit,1
10108,ITA,debit,1
10150,ITA,debit,1
10258,ITA,debit,1
10300,ITA,debit,1
10309,ITA,debit,1
11300,PHL,debit,1
11301,PHL,debit,1
11302,PHL,debit,1
11303,PHL,debit,1
11304,PHL,debit,1
11305,PHL,debit,1
11306,PHL,debit,1
11308,PHL,debit,1
11309,PHL,debit,1
12004,BGR,debit,1
12047,ARG,debit,1
20010,CHN,debit,1
20083,ITA,debit,1
20084,ITA,debit,1
124411;PRIVATE LABEL;BANCO BRADESCO;;;BRAZIL;BR;BRA;76
210211;PRIVATE LABEL;CHINA MERCHANTS BANK;CREDIT;STANDARD;CHINA;CN;CHN;156
219511;PRIVATE LABEL;CHINA MERCHANTS BANK;DEBIT;;CHINA;CN;CHN;156
220111;PRIVATE LABEL;CHINA MERCHANTS BANK;DEBIT;;CHINA;CN;CHN;156
223911;PRIVATE LABEL;CHINA MERCHANTS BANK;DEBIT;;CHINA;CN;CHN;156
236111;PRIVATE LABEL;CHINA MERCHANTS BANK;CREDIT;STANDARD;CHINA;CN;CHN;156
407811;PRIVATE LABEL;SHIFT4 PAYMENTS;DEBIT;GIFT;UNITED STATES;US;USA;840
408011;PRIVATE LABEL;SHIFT4 PAYMENTS;DEBIT;GIFT;UNITED STATES;US;USA;840
734311;PRIVATE LABEL;BANCO PAN;DEBIT;;BRAZIL;BR;BRA;76
100511;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
100531;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
101081;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
101501;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
102581;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
103001;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
103091;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
113001;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
113011;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
113021;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
113031;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
113041;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
113051;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
113061;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
113081;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
113091;LOCAL BRAND;BDO UNIBANK, INC.;DEBIT;PROPRIETARY ATM;PHILIPPINES;PH;PHL;608
120041;PRIVATE LABEL;TBI BANK;DEBIT;;BULGARIA;BG;BGR;100
120471;PRIVATE LABEL;BANCO DE CREDITO ARGENTINO;DEBIT;;ARGENTINA;AR;ARG;32
200101;PRIVATE LABEL;INDUSTRIAL AND COMMERCIAL BANK OF CHINA;DEBIT;;CHINA;CN;CHN;156
200831;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
200841;PAGOBANCOMAT;;DEBIT;;ITALY;IT;ITA;380
5 changes: 2 additions & 3 deletions src/test/resources/data/binbase/case1/V7_binbase_1.9.0.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
bin,countryCode,cardType,version
976200,TJK,debit,1
977700,OST,debit,1
976200;NSPK;"CJSC ""Dushanbe City Bank""";DEBIT;MIR Classic;Tajikistan;TJ;TJK;762
977700;NSPK;MRB Bank;DEBIT;MIR Classic;Republic of South Ossetia;OS;OST;896