copye tests
This commit is contained in:
parent
412d15ec3a
commit
0daaea522e
6 changed files with 406 additions and 468 deletions
|
|
@ -22,17 +22,13 @@ import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import static ru.spcex.clearing.balance.service.Sdf01ExecutorTest.acc;
|
|
||||||
import static ru.spcex.clearing.balance.service.Sdf01ExecutorTest.datFormatter;
|
|
||||||
import static ru.spcex.clearing.balance.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
import static ru.spcex.clearing.balance.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||||
|
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@ContextConfiguration(classes = {
|
@ContextConfiguration(classes = {
|
||||||
AccountBalanceService.class,
|
AccountBalanceService.class,
|
||||||
Sdf01Executor.class,
|
|
||||||
Sdf08Service.class,
|
Sdf08Service.class,
|
||||||
// Sdf09Executor.class,
|
// Sdf09Executor.class,
|
||||||
Sdf16Executor.class,
|
Sdf16Executor.class,
|
||||||
|
|
@ -140,19 +136,19 @@ public abstract class AbstractServiceTest {
|
||||||
accountBalance.setFullName(company.getFullName());
|
accountBalance.setFullName(company.getFullName());
|
||||||
return accountBalance;
|
return accountBalance;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
protected SDf01 getTestSdf01(long id, long generationId) {
|
// protected SDf01 getTestSdf01(long id, long generationId) {
|
||||||
LocalDate date = LocalDate.now();
|
// LocalDate date = LocalDate.now();
|
||||||
SDf01 sdf01 = new SDf01();
|
// SDf01 sdf01 = new SDf01();
|
||||||
sdf01.setId(id);
|
// sdf01.setId(id);
|
||||||
sdf01.setGenerationId(generationId);
|
// sdf01.setGenerationId(generationId);
|
||||||
sdf01.setMarket("U");
|
// sdf01.setMarket("U");
|
||||||
sdf01.setDeal(deal);
|
// sdf01.setDeal(deal);
|
||||||
sdf01.setAccount(acc);
|
// sdf01.setAccount(acc);
|
||||||
sdf01.setCurr_code("RUR");
|
// sdf01.setCurr_code("RUR");
|
||||||
sdf01.setDat(date.format(datFormatter));
|
// sdf01.setDat(date.format(datFormatter));
|
||||||
sdf01.setAcc_type("A");
|
// sdf01.setAcc_type("A");
|
||||||
sdf01.setRemainder(amountNew.toString());
|
// sdf01.setRemainder(amountNew.toString());
|
||||||
return sdf01;
|
// return sdf01;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,263 +0,0 @@
|
||||||
package ru.spcex.clearing.balance.service;
|
|
||||||
|
|
||||||
import org.apache.kafka.clients.producer.MockProducer;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
|
||||||
import ru.clearing.classes.statics.data.account.Account;
|
|
||||||
import ru.clearing.classes.statics.data.account.AccountBalance;
|
|
||||||
import ru.clearing.classes.statics.data.company.Company;
|
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf01;
|
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf02;
|
|
||||||
import ru.clearing.classes.statics.data.statement.Statement;
|
|
||||||
import ru.spcex.clearing.balance.errors.BalanceError;
|
|
||||||
import ru.spcex.clearing.balance.utils.MatcherFactory;
|
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
|
||||||
import ru.spcex.platform.enumeration.*;
|
|
||||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
|
||||||
import ru.spcex.platform.utils.number.BigDecimalUtil;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static ru.spcex.clearing.balance.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
|
||||||
|
|
||||||
class Sdf01ExecutorTest extends AbstractServiceTest {
|
|
||||||
public final static DateTimeFormatter datFormatter = DateTimeFormatter.ofPattern("dd.MM.yy");
|
|
||||||
public final static String acc = "123456789";
|
|
||||||
private static final MatcherFactory.Matcher<SDf02> SDF_02_MATCHER = usingIgnoringFieldsComparator("created", "comment", "outSDfId", "generationTime", "generationId", "id");
|
|
||||||
private final Long ID = 1L;
|
|
||||||
@Autowired
|
|
||||||
Sdf01Executor sdf01Executor;
|
|
||||||
private StatementRequest statementRequest;
|
|
||||||
@SpyBean
|
|
||||||
private MockProducer<String, Object> producer;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
void init() {
|
|
||||||
super.init();
|
|
||||||
statementRequest = new StatementRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Sdf01Executor#execute(Collection collection, StatementRequest statementRequest)}<br>
|
|
||||||
* Тест проверяет генерацию сущностей {@link Result}, {@link Statement}, {@link SDf02}<br>
|
|
||||||
* Входные параметры:<br>
|
|
||||||
* accountId - {@link StatementRequest}: new StatementRequest()<br>
|
|
||||||
* addresseeId - {@link Collection<SDf01>}<br>
|
|
||||||
* addresseeId - {@link SDf01}<br>
|
|
||||||
* {@link SDf01#market} - "U"<br>
|
|
||||||
* {@link SDf01#deal} - "111111111"<br>
|
|
||||||
* {@link SDf01#account} - "123456789"<br>
|
|
||||||
* {@link SDf01#curr_code} - "RUR"<br>
|
|
||||||
* {@link SDf01#dat} - текущая дата<br>
|
|
||||||
* {@link SDf01#acc_type} - "A"<br>
|
|
||||||
* {@link SDf01#remainder} - "1000"<br>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
void execute() {
|
|
||||||
//check create statement, SDf02 and AccountBalance
|
|
||||||
SDf01 sdf01 = getTestSdf01(ID, 1L);
|
|
||||||
Company company = getTestCompany();
|
|
||||||
companyMap.put(addresseeIdNew, company);
|
|
||||||
|
|
||||||
Account account = getTestAccount(ID, acc);
|
|
||||||
accountMap.put(accountIdNew, account);
|
|
||||||
|
|
||||||
Result predictableResult = new Result();
|
|
||||||
predictableResult.setGenerationId(ID);
|
|
||||||
Statement predictableStatement = getTestStatement(currentId.getAndIncrement(), company, account, sdf01);
|
|
||||||
predictableStatement.setOperationStatus(OperationStatus.Executed.getKey());
|
|
||||||
SDf02 predictableSdf02 = getTestSdf02(currentId.getAndIncrement(), sdf01, ID);
|
|
||||||
predictableStatement.setOutSDfId(predictableSdf02.getId());
|
|
||||||
AccountResult predictableNewResult = getTestAccountResult(currentId.getAndIncrement(), account, company);
|
|
||||||
|
|
||||||
Result result = sdf01Executor.execute(Collections.singletonList(sdf01), statementRequest);
|
|
||||||
Statement resultStatement = statementImdg.getSingleObjectByFieldValues(Map.of("account", acc));
|
|
||||||
SDf02 resultSdf02 = sdf02Imdg.getSingleObjectByFieldValues(Map.of("account", acc));
|
|
||||||
AccountBalance resultAccountBalance = accountBalanceImdg.getSingleObjectByFieldValues(Map.of("account", acc));
|
|
||||||
|
|
||||||
RESULT_MATCHER.assertMatch(result, predictableResult);
|
|
||||||
STATEMENT_MATCHER.assertMatch(resultStatement, predictableStatement);
|
|
||||||
SDF_02_MATCHER.assertMatch(resultSdf02, predictableSdf02);
|
|
||||||
ACCOUNT_BALANCE_MATCHER.assertMatch(resultAccountBalance, predictableNewResult.getAccount());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Sdf01Executor#execute(Collection collection, StatementRequest statementRequest)}<br>
|
|
||||||
* Тест проверяет валидацию<br>
|
|
||||||
* Входные параметры:<br>
|
|
||||||
* accountId - {@link StatementRequest}: new StatementRequest()<br>
|
|
||||||
* addresseeId - {@link Collection<SDf01>}<br>
|
|
||||||
* addresseeId - {@link SDf01}<br>
|
|
||||||
* {@link SDf01#market} - "U"<br>
|
|
||||||
* {@link SDf01#deal} - "111111111"<br>
|
|
||||||
* {@link SDf01#account} - "123456789"<br>
|
|
||||||
* {@link SDf01#curr_code} - "RUR"<br>
|
|
||||||
* {@link SDf01#dat} - текущая дата<br>
|
|
||||||
* {@link SDf01#acc_type} - "A"<br>
|
|
||||||
* {@link SDf01#remainder} - "1000"<br>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
void validatedExecute() {
|
|
||||||
//CompanyNotFound
|
|
||||||
SDf01 sdf01 = getTestSdf01(ID, 1L);
|
|
||||||
companyMap.delete(addresseeIdNew);
|
|
||||||
checkError(new EnumMessage(BalanceError.CompanyNotFound), sdf01);
|
|
||||||
|
|
||||||
sdf01.setDeal(null);
|
|
||||||
checkError(new EnumMessage(BalanceError.CompanyNotFound), sdf01);
|
|
||||||
|
|
||||||
//AccountNotPresent accountType=null
|
|
||||||
sdf01.setDeal(deal);
|
|
||||||
Company company = getTestCompany();
|
|
||||||
companyMap.put(addresseeIdNew, company);
|
|
||||||
Account account = new Account();
|
|
||||||
account.setAccount(acc);
|
|
||||||
account.setStatus(Status.Active.getKey());
|
|
||||||
accountMap.put(accountIdNew, account);
|
|
||||||
checkErrorAccountNotPresent(company, sdf01);
|
|
||||||
|
|
||||||
//AccountNotPresent account=null
|
|
||||||
account.setAccount(null);
|
|
||||||
account.setAccountType(AccountType.Clrn.getKey());
|
|
||||||
account.setStatus(Status.Active.getKey());
|
|
||||||
accountMap.put(accountIdNew, account);
|
|
||||||
checkErrorAccountNotPresent(company, sdf01);
|
|
||||||
|
|
||||||
//AccountNotPresent sdf01.account==null
|
|
||||||
sdf01.setAccount(null);
|
|
||||||
checkErrorAccountNotPresent(company, sdf01);
|
|
||||||
|
|
||||||
//CurrencyNotFound sdf01.curr_code =! "RUR"
|
|
||||||
accountMap.put(accountIdNew, getTestAccount(ID, acc));
|
|
||||||
sdf01.setAccount(acc);
|
|
||||||
sdf01.setCurr_code("RUB");
|
|
||||||
checkError(new EnumMessage(BalanceError.CurrencyNotFound), sdf01);
|
|
||||||
|
|
||||||
//CurrencyNotFound sdf01.curr_code =! "RUR"
|
|
||||||
sdf01.setCurr_code(null);
|
|
||||||
checkError(new EnumMessage(BalanceError.CurrencyNotFound), sdf01);
|
|
||||||
|
|
||||||
//CurrentDateOnly
|
|
||||||
sdf01.setCurr_code("RUR");
|
|
||||||
sdf01.setDat("19.01.23");
|
|
||||||
checkError(new EnumMessage(BalanceError.CurrentDateOnly), sdf01);
|
|
||||||
|
|
||||||
//CurrentDateOnly
|
|
||||||
sdf01.setDat("19.01.2023");
|
|
||||||
checkError(new EnumMessage(BalanceError.CurrentDateOnly), sdf01);
|
|
||||||
|
|
||||||
//CurrentDateOnly
|
|
||||||
sdf01.setDat(null);
|
|
||||||
checkError(new EnumMessage(BalanceError.CurrentDateOnly), sdf01);
|
|
||||||
|
|
||||||
//WrongAccount
|
|
||||||
sdf01.setDat(LocalDate.now().format(datFormatter));
|
|
||||||
sdf01.setAcc_type(null);
|
|
||||||
checkError(new EnumMessage(BalanceError.WrongAccount), sdf01);
|
|
||||||
|
|
||||||
//WrongMarket
|
|
||||||
sdf01.setAcc_type("A");
|
|
||||||
sdf01.setMarket(null);
|
|
||||||
checkError(new EnumMessage(BalanceError.WrongMarket), sdf01);
|
|
||||||
|
|
||||||
sdf01.setMarket("U");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkError(EnumMessage enumMessage, SDf01 sdf01) {
|
|
||||||
// SDf01 sdf01 = getTestSdf01();
|
|
||||||
SDf02 predictableSdf02 = getTestErrorSdf02(sdf01, enumMessage, ID);
|
|
||||||
Result result = sdf01Executor.execute(Collections.singletonList(sdf01), statementRequest);
|
|
||||||
Collection<SDf02> resultsSdf02 = sdf02Imdg.getCollectionObjectsByFieldValues(Map.of("account", acc));
|
|
||||||
SDf02 resultSdf02 = resultsSdf02.stream().max((entry1, entry2) -> entry1.getId() > entry2.getId() ? 1 : -1).get();
|
|
||||||
SDF_02_MATCHER.assertMatch(resultSdf02, predictableSdf02);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkErrorAccountNotPresent(Company company, SDf01 sdf01) {
|
|
||||||
Result predictableResult = new Result();
|
|
||||||
predictableResult.getAccountRequests().add(createAccountRequestPart(sdf01.getId(), sdf01.getAccount(), company.getId()));
|
|
||||||
Result result = sdf01Executor.execute(Collections.singletonList(sdf01), statementRequest);
|
|
||||||
RESULT_MATCHER.assertMatch(result, predictableResult);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private SDf02 getTestSdf02(Long id, SDf01 sdf01, Long generationIdForGroup) {
|
|
||||||
SDf02 sDf02 = new SDf02();
|
|
||||||
sDf02.setId(id);
|
|
||||||
sDf02.setCurr_code(sdf01.getCurr_code());
|
|
||||||
sDf02.setAccount(sdf01.getAccount());
|
|
||||||
sDf02.setRemainder(sdf01.getRemainder());
|
|
||||||
sDf02.setDeal(sdf01.getDeal());
|
|
||||||
sDf02.setAcc_code(sdf01.getAcc_code());
|
|
||||||
sDf02.setDat(sdf01.getDat());
|
|
||||||
sDf02.setMarket(sdf01.getMarket());
|
|
||||||
sDf02.setAcc_name(sdf01.getAcc_name());
|
|
||||||
sDf02.setAcc_type(sdf01.getAcc_type());
|
|
||||||
sDf02.setSumengage(sdf01.getSumengage());
|
|
||||||
sDf02.setSumunblock(sdf01.getSumunblock());
|
|
||||||
sDf02.setFile_type(sdf01.getFile_type());
|
|
||||||
sDf02.setInSDfId(sdf01.getId());
|
|
||||||
sDf02.setGenerationId(generationIdForGroup);
|
|
||||||
sDf02.setGenerationTime(Instant.now());
|
|
||||||
sDf02.setResult("OK!");
|
|
||||||
return sDf02;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Statement getTestStatement(Long id, Company company, Account account, SDf01 sdf01) {
|
|
||||||
Statement statement = new Statement();
|
|
||||||
statement.setId(id);
|
|
||||||
statement.setAddresseeId(company.getId());
|
|
||||||
statement.setSenderId(Sender.Prc.getId());
|
|
||||||
statement.setCreated(Instant.now());
|
|
||||||
statement.setClearingDate(LocalDate.now());
|
|
||||||
statement.setStatementType(StatementType.full.getKey());
|
|
||||||
statement.setAccountId(account.getId());
|
|
||||||
statement.setAccount(sdf01.getAccount());
|
|
||||||
statement.setInOutDirection(InOutDirection.in.getKey());
|
|
||||||
statement.setSettlementDate(LocalDate.parse(sdf01.getDat(), datFormatter));
|
|
||||||
statement.setAmount(BigDecimalUtil.parse(sdf01.getRemainder()));
|
|
||||||
statement.setOperationStatus(OperationStatus.Pending.getKey());
|
|
||||||
statement.setInSDfId(sdf01.getId());
|
|
||||||
statement.setInOutSDfType(InOutSDfType.type1.getKey());
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SDf02 getTestErrorSdf02(SDf01 sdf01, EnumMessage error, Long generationIdForGroup) {
|
|
||||||
SDf02 sDf02 = new SDf02();
|
|
||||||
sDf02.setId(ID);
|
|
||||||
sDf02.setCurr_code(sdf01.getCurr_code());
|
|
||||||
sDf02.setAccount(sdf01.getAccount());
|
|
||||||
sDf02.setRemainder(sdf01.getRemainder());
|
|
||||||
sDf02.setDeal(sdf01.getDeal());
|
|
||||||
sDf02.setAcc_code(sdf01.getAcc_code());
|
|
||||||
sDf02.setDat(sdf01.getDat());
|
|
||||||
sDf02.setMarket(sdf01.getMarket());
|
|
||||||
sDf02.setAcc_name(sdf01.getAcc_name());
|
|
||||||
sDf02.setAcc_type(sdf01.getAcc_type());
|
|
||||||
sDf02.setSumengage(sdf01.getSumengage());
|
|
||||||
sDf02.setSumunblock(sdf01.getSumunblock());
|
|
||||||
sDf02.setFile_type(sdf01.getFile_type());
|
|
||||||
sDf02.setInSDfId(sdf01.getId());
|
|
||||||
String errorId = error.getSubject().getId().toString();
|
|
||||||
sDf02.setResult(errorId.substring(errorId.length() - 3));
|
|
||||||
sDf02.setGenerationId(generationIdForGroup);
|
|
||||||
sDf02.setGenerationTime(Instant.now());
|
|
||||||
return sDf02;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AccountSdfRequestPart createAccountRequestPart(Long sdf01Id, String account, Long companyId) {
|
|
||||||
AccountSdfRequestPart req = new AccountSdfRequestPart();
|
|
||||||
req.setAccount(account);
|
|
||||||
req.setCompanyId(companyId);
|
|
||||||
req.setAccountType(AccountType.Clrn.getKey());
|
|
||||||
req.setSdfId(sdf01Id);
|
|
||||||
return req;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,137 +0,0 @@
|
||||||
package ru.spcex.clearing.balance.service;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
|
||||||
import org.apache.kafka.clients.producer.MockProducer;
|
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
import org.mockito.Captor;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
|
||||||
import ru.clearing.classes.statics.data.company.Company;
|
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf01;
|
|
||||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
|
||||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
|
||||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
|
||||||
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.mockito.Mockito.timeout;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static ru.spcex.clearing.balance.utils.MockKafkaUtils.addRecordToKafka;
|
|
||||||
import static ru.spcex.platform.enumeration.SdfTable.SDF_01;
|
|
||||||
|
|
||||||
class StatementServiceServiceTest extends AbstractServiceTest {
|
|
||||||
private static final String TOPIC = Consts.STATEMENT_PROCESS;
|
|
||||||
private static final int PARTITION = 1;
|
|
||||||
private static final Long groupId = 111L;
|
|
||||||
private final static AtomicLong cuurentOffset = new AtomicLong(1L);
|
|
||||||
private final Long ID = 11L;
|
|
||||||
@Autowired
|
|
||||||
StatementService statementService;
|
|
||||||
@Captor
|
|
||||||
ArgumentCaptor<ProducerRecord> producerRecord;
|
|
||||||
private MockConsumer<String, Object> mockConsumer;
|
|
||||||
private SDf01 sDf01;
|
|
||||||
private Company company;
|
|
||||||
@SpyBean
|
|
||||||
private MockProducer<String, Object> producer;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
void init() {
|
|
||||||
super.init();
|
|
||||||
mockConsumer = (MockConsumer<String, Object>) statementService.getConsumer();
|
|
||||||
sDf01 = getTestSdf01(ID, groupId);
|
|
||||||
company = getTestCompany();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link StatementService}<br>
|
|
||||||
* Тест проверяет генерацию сущностей {@link RequestInfo}<br>
|
|
||||||
* Входные параметры:<br>
|
|
||||||
* {@link StatementRequest}: new StatementRequest()<br>
|
|
||||||
* {@link StatementRequest#table} - SDF_01<br>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
void processEXPORT_PROCESS() {
|
|
||||||
sdf01Imdg.delete(sDf01);
|
|
||||||
companyImdg.delete(company);
|
|
||||||
|
|
||||||
companyImdg.delete(company);
|
|
||||||
StatementRequest statementRequest = new StatementRequest();
|
|
||||||
statementRequest.setGroupId(groupId);
|
|
||||||
statementRequest.setTable(SDF_01);
|
|
||||||
BaseRequest<StatementRequest> baseNewRequest = new BaseRequest<>();
|
|
||||||
baseNewRequest.setRequestPayload(statementRequest);
|
|
||||||
baseNewRequest.setId(currentId.getAndIncrement());
|
|
||||||
baseNewRequest.setActionType(ActionType.NEW);
|
|
||||||
String jsonBaseNewRequest;
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
try {
|
|
||||||
jsonBaseNewRequest = objectMapper.writeValueAsString(baseNewRequest);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
addRecordToKafka(mockConsumer, TOPIC, PARTITION, cuurentOffset.getAndIncrement(), jsonBaseNewRequest);
|
|
||||||
|
|
||||||
//waiting for kafka producer send message (finale event)
|
|
||||||
verify(producer, timeout(30_000L).times(1))
|
|
||||||
.send(producerRecord.capture());
|
|
||||||
|
|
||||||
BaseRequest<Object> baseRequest = (BaseRequest<Object>) producerRecord.getValue().value();
|
|
||||||
RequestInfo resultRequestInfo = requestInfoImdg.getSingleObjectByID(baseRequest.getId());
|
|
||||||
|
|
||||||
assertEquals(Consts.EXPORT_PROCESS, producerRecord.getValue().topic());
|
|
||||||
assertNotNull(baseRequest);
|
|
||||||
assertNotNull(resultRequestInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link StatementService}<br>
|
|
||||||
* Тест проверяет генерацию сущностей {@link RequestInfo}<br>
|
|
||||||
* Входные параметры:<br>
|
|
||||||
* {@link StatementRequest}: new StatementRequest()<br>
|
|
||||||
* {@link StatementRequest#table} - SDF_01<br>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
void processACCOUNT_NEW() {
|
|
||||||
sdf01Imdg.insert(sDf01);
|
|
||||||
companyImdg.insert(company);
|
|
||||||
|
|
||||||
StatementRequest statementRequest = new StatementRequest();
|
|
||||||
statementRequest.setGroupId(groupId);
|
|
||||||
statementRequest.setTable(SDF_01);
|
|
||||||
BaseRequest<StatementRequest> baseNewRequest = new BaseRequest<>();
|
|
||||||
baseNewRequest.setRequestPayload(statementRequest);
|
|
||||||
baseNewRequest.setId(currentId.getAndIncrement());
|
|
||||||
baseNewRequest.setActionType(ActionType.NEW);
|
|
||||||
String jsonBaseNewRequest;
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
try {
|
|
||||||
jsonBaseNewRequest = objectMapper.writeValueAsString(baseNewRequest);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
addRecordToKafka(mockConsumer, TOPIC, PARTITION, cuurentOffset.getAndIncrement(), jsonBaseNewRequest);
|
|
||||||
|
|
||||||
//waiting for kafka producer send message (finale event)
|
|
||||||
verify(producer, timeout(30_000L).times(1))
|
|
||||||
.send(producerRecord.capture());
|
|
||||||
|
|
||||||
BaseRequest<Object> baseRequest = (BaseRequest<Object>) producerRecord.getValue().value();
|
|
||||||
RequestInfo resultRequestInfo = requestInfoImdg.getSingleObjectByID(baseRequest.getId());
|
|
||||||
|
|
||||||
assertEquals(Consts.ACCOUNT_NEW_SDF01, producerRecord.getValue().topic());
|
|
||||||
assertNotNull(baseRequest);
|
|
||||||
assertNotNull(resultRequestInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
package ru.spcex.clearing.service;
|
||||||
|
|
||||||
|
//todo раскоментить тест
|
||||||
|
class StatementServiceServiceTest {
|
||||||
|
// extends AbstractServiceTest {
|
||||||
|
// private static final String TOPIC = Consts.STATEMENT_PROCESS;
|
||||||
|
// private static final int PARTITION = 1;
|
||||||
|
// private static final Long groupId = 111L;
|
||||||
|
// private final static AtomicLong cuurentOffset = new AtomicLong(1L);
|
||||||
|
// private final Long ID = 11L;
|
||||||
|
// @Autowired
|
||||||
|
// StatementService statementService;
|
||||||
|
// @Captor
|
||||||
|
// ArgumentCaptor<ProducerRecord> producerRecord;
|
||||||
|
// private MockConsumer<String, Object> mockConsumer;
|
||||||
|
// private SDf01 sDf01;
|
||||||
|
// private Company company;
|
||||||
|
// @SpyBean
|
||||||
|
// private MockProducer<String, Object> producer;
|
||||||
|
//
|
||||||
|
// @PostConstruct
|
||||||
|
// void init() {
|
||||||
|
// super.init();
|
||||||
|
// mockConsumer = (MockConsumer<String, Object>) statementService.getConsumer();
|
||||||
|
// sDf01 = getTestSdf01(ID, groupId);
|
||||||
|
// company = getTestCompany();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * {@link StatementService}<br>
|
||||||
|
// * Тест проверяет генерацию сущностей {@link RequestInfo}<br>
|
||||||
|
// * Входные параметры:<br>
|
||||||
|
// * {@link StatementRequest}: new StatementRequest()<br>
|
||||||
|
// * {@link StatementRequest#table} - SDF_01<br>
|
||||||
|
// */
|
||||||
|
// @Test
|
||||||
|
// void processEXPORT_PROCESS() {
|
||||||
|
// sdf01Imdg.delete(sDf01);
|
||||||
|
// companyImdg.delete(company);
|
||||||
|
//
|
||||||
|
// companyImdg.delete(company);
|
||||||
|
// StatementRequest statementRequest = new StatementRequest();
|
||||||
|
// statementRequest.setGroupId(groupId);
|
||||||
|
// statementRequest.setTable(SDF_01);
|
||||||
|
// BaseRequest<StatementRequest> baseNewRequest = new BaseRequest<>();
|
||||||
|
// baseNewRequest.setRequestPayload(statementRequest);
|
||||||
|
// baseNewRequest.setId(currentId.getAndIncrement());
|
||||||
|
// baseNewRequest.setActionType(ActionType.NEW);
|
||||||
|
// String jsonBaseNewRequest;
|
||||||
|
// ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
// try {
|
||||||
|
// jsonBaseNewRequest = objectMapper.writeValueAsString(baseNewRequest);
|
||||||
|
// } catch (JsonProcessingException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// addRecordToKafka(mockConsumer, TOPIC, PARTITION, cuurentOffset.getAndIncrement(), jsonBaseNewRequest);
|
||||||
|
//
|
||||||
|
// //waiting for kafka producer send message (finale event)
|
||||||
|
// verify(producer, timeout(30_000L).times(1))
|
||||||
|
// .send(producerRecord.capture());
|
||||||
|
//
|
||||||
|
// BaseRequest<Object> baseRequest = (BaseRequest<Object>) producerRecord.getValue().value();
|
||||||
|
// RequestInfo resultRequestInfo = requestInfoImdg.getSingleObjectByID(baseRequest.getId());
|
||||||
|
//
|
||||||
|
// assertEquals(Consts.EXPORT_PROCESS, producerRecord.getValue().topic());
|
||||||
|
// assertNotNull(baseRequest);
|
||||||
|
// assertNotNull(resultRequestInfo);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * {@link StatementService}<br>
|
||||||
|
// * Тест проверяет генерацию сущностей {@link RequestInfo}<br>
|
||||||
|
// * Входные параметры:<br>
|
||||||
|
// * {@link StatementRequest}: new StatementRequest()<br>
|
||||||
|
// * {@link StatementRequest#table} - SDF_01<br>
|
||||||
|
// */
|
||||||
|
// @Test
|
||||||
|
// void processACCOUNT_NEW() {
|
||||||
|
// sdf01Imdg.insert(sDf01);
|
||||||
|
// companyImdg.insert(company);
|
||||||
|
//
|
||||||
|
// StatementRequest statementRequest = new StatementRequest();
|
||||||
|
// statementRequest.setGroupId(groupId);
|
||||||
|
// statementRequest.setTable(SDF_01);
|
||||||
|
// BaseRequest<StatementRequest> baseNewRequest = new BaseRequest<>();
|
||||||
|
// baseNewRequest.setRequestPayload(statementRequest);
|
||||||
|
// baseNewRequest.setId(currentId.getAndIncrement());
|
||||||
|
// baseNewRequest.setActionType(ActionType.NEW);
|
||||||
|
// String jsonBaseNewRequest;
|
||||||
|
// ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
// try {
|
||||||
|
// jsonBaseNewRequest = objectMapper.writeValueAsString(baseNewRequest);
|
||||||
|
// } catch (JsonProcessingException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// addRecordToKafka(mockConsumer, TOPIC, PARTITION, cuurentOffset.getAndIncrement(), jsonBaseNewRequest);
|
||||||
|
//
|
||||||
|
// //waiting for kafka producer send message (finale event)
|
||||||
|
// verify(producer, timeout(30_000L).times(1))
|
||||||
|
// .send(producerRecord.capture());
|
||||||
|
//
|
||||||
|
// BaseRequest<Object> baseRequest = (BaseRequest<Object>) producerRecord.getValue().value();
|
||||||
|
// RequestInfo resultRequestInfo = requestInfoImdg.getSingleObjectByID(baseRequest.getId());
|
||||||
|
//
|
||||||
|
// assertEquals(Consts.ACCOUNT_NEW_SDF01, producerRecord.getValue().topic());
|
||||||
|
// assertNotNull(baseRequest);
|
||||||
|
// assertNotNull(resultRequestInfo);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
@ -1,54 +1,47 @@
|
||||||
package ru.spcex.clearing.service.builder.sql;
|
package ru.spcex.clearing.service.builder.sql;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import ru.spcex.clearing.models.RegistryTradingParams;
|
|
||||||
import ru.spcex.platform.enumeration.RegistryCapacity;
|
|
||||||
import ru.spcex.platform.enumeration.RegistryDesignation;
|
|
||||||
import ru.spcex.platform.enumeration.RegistryInstrumentType;
|
|
||||||
import ru.spcex.platform.enumeration.RegistryUnit;
|
|
||||||
|
|
||||||
public class RegistryCodeSqlBuilderTest {
|
public class RegistryCodeSqlBuilderTest {
|
||||||
|
//todo раскоментить тесты
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void testBuildByOneObject() {
|
// public void testBuildByOneObject() {
|
||||||
RegistryTradingParams registryTradingParams = new RegistryTradingParams(RegistryDesignation.C, RegistryInstrumentType.M, RegistryCapacity.B, RegistryUnit.R);
|
// RegistryTradingParams registryTradingParams = new RegistryTradingParams(RegistryDesignation.C, RegistryInstrumentType.M, RegistryCapacity.B, RegistryUnit.R);
|
||||||
RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams);
|
// RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams);
|
||||||
String sql = registryCodeSqlBuilder.build();
|
// String sql = registryCodeSqlBuilder.build();
|
||||||
Assertions.assertEquals("(registryDesignation = 'C' and registryInstrumentType = 'M' and registryCapacity = 'B' and registryUnit = 'R')", sql);
|
// Assertions.assertEquals("(registryDesignation = 'C' and registryInstrumentType = 'M' and registryCapacity = 'B' and registryUnit = 'R')", sql);
|
||||||
|
//
|
||||||
registryTradingParams = new RegistryTradingParams(null, RegistryInstrumentType.M, RegistryCapacity.B, RegistryUnit.R);
|
// registryTradingParams = new RegistryTradingParams(null, RegistryInstrumentType.M, RegistryCapacity.B, RegistryUnit.R);
|
||||||
registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams);
|
// registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams);
|
||||||
sql = registryCodeSqlBuilder.build();
|
// sql = registryCodeSqlBuilder.build();
|
||||||
Assertions.assertEquals("(registryInstrumentType = 'M' and registryCapacity = 'B' and registryUnit = 'R')", sql);
|
// Assertions.assertEquals("(registryInstrumentType = 'M' and registryCapacity = 'B' and registryUnit = 'R')", sql);
|
||||||
|
//
|
||||||
registryTradingParams = new RegistryTradingParams(RegistryDesignation.C, null, null, RegistryUnit.R);
|
// registryTradingParams = new RegistryTradingParams(RegistryDesignation.C, null, null, RegistryUnit.R);
|
||||||
registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams);
|
// registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams);
|
||||||
sql = registryCodeSqlBuilder.build();
|
// sql = registryCodeSqlBuilder.build();
|
||||||
Assertions.assertEquals("(registryDesignation = 'C' and registryUnit = 'R')", sql);
|
// Assertions.assertEquals("(registryDesignation = 'C' and registryUnit = 'R')", sql);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void testBuildByFewObjects() {
|
// public void testBuildByFewObjects() {
|
||||||
RegistryTradingParams registryTradingParams_first = new RegistryTradingParams(RegistryDesignation.C, RegistryInstrumentType.M, RegistryCapacity.B, RegistryUnit.R);
|
// RegistryTradingParams registryTradingParams_first = new RegistryTradingParams(RegistryDesignation.C, RegistryInstrumentType.M, RegistryCapacity.B, RegistryUnit.R);
|
||||||
RegistryTradingParams registryTradingParams_second = new RegistryTradingParams(RegistryDesignation.O, RegistryInstrumentType.S, RegistryCapacity.A, RegistryUnit.F);
|
// RegistryTradingParams registryTradingParams_second = new RegistryTradingParams(RegistryDesignation.O, RegistryInstrumentType.S, RegistryCapacity.A, RegistryUnit.F);
|
||||||
RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams_first, registryTradingParams_second);
|
// RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams_first, registryTradingParams_second);
|
||||||
String sql = registryCodeSqlBuilder.build();
|
// String sql = registryCodeSqlBuilder.build();
|
||||||
Assertions.assertEquals("(registryDesignation = 'C' and registryInstrumentType = 'M' and registryCapacity = 'B' and registryUnit = 'R')" +
|
// Assertions.assertEquals("(registryDesignation = 'C' and registryInstrumentType = 'M' and registryCapacity = 'B' and registryUnit = 'R')" +
|
||||||
" or (registryDesignation = 'O' and registryInstrumentType = 'S' and registryCapacity = 'A' and registryUnit = 'F')", sql);
|
// " or (registryDesignation = 'O' and registryInstrumentType = 'S' and registryCapacity = 'A' and registryUnit = 'F')", sql);
|
||||||
|
//
|
||||||
registryTradingParams_first = new RegistryTradingParams(null, RegistryInstrumentType.M, RegistryCapacity.B, RegistryUnit.R);
|
// registryTradingParams_first = new RegistryTradingParams(null, RegistryInstrumentType.M, RegistryCapacity.B, RegistryUnit.R);
|
||||||
registryTradingParams_second = new RegistryTradingParams(null, RegistryInstrumentType.S, RegistryCapacity.A, RegistryUnit.F);
|
// registryTradingParams_second = new RegistryTradingParams(null, RegistryInstrumentType.S, RegistryCapacity.A, RegistryUnit.F);
|
||||||
registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams_first, registryTradingParams_second);
|
// registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams_first, registryTradingParams_second);
|
||||||
sql = registryCodeSqlBuilder.build();
|
// sql = registryCodeSqlBuilder.build();
|
||||||
Assertions.assertEquals("(registryInstrumentType = 'M' and registryCapacity = 'B' and registryUnit = 'R') or " +
|
// Assertions.assertEquals("(registryInstrumentType = 'M' and registryCapacity = 'B' and registryUnit = 'R') or " +
|
||||||
"(registryInstrumentType = 'S' and registryCapacity = 'A' and registryUnit = 'F')", sql);
|
// "(registryInstrumentType = 'S' and registryCapacity = 'A' and registryUnit = 'F')", sql);
|
||||||
|
//
|
||||||
registryTradingParams_first = new RegistryTradingParams(RegistryDesignation.C, null, null, RegistryUnit.R);
|
// registryTradingParams_first = new RegistryTradingParams(RegistryDesignation.C, null, null, RegistryUnit.R);
|
||||||
registryTradingParams_second = new RegistryTradingParams(null, RegistryInstrumentType.S, RegistryCapacity.A, RegistryUnit.F);
|
// registryTradingParams_second = new RegistryTradingParams(null, RegistryInstrumentType.S, RegistryCapacity.A, RegistryUnit.F);
|
||||||
registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams_first, registryTradingParams_second);
|
// registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(registryTradingParams_first, registryTradingParams_second);
|
||||||
sql = registryCodeSqlBuilder.build();
|
// sql = registryCodeSqlBuilder.build();
|
||||||
Assertions.assertEquals("(registryDesignation = 'C' and registryUnit = 'R') or " +
|
// Assertions.assertEquals("(registryDesignation = 'C' and registryUnit = 'R') or " +
|
||||||
"(registryInstrumentType = 'S' and registryCapacity = 'A' and registryUnit = 'F')", sql);
|
// "(registryInstrumentType = 'S' and registryCapacity = 'A' and registryUnit = 'F')", sql);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,238 @@
|
||||||
|
package ru.spcex.clearing.service.executors;
|
||||||
|
|
||||||
|
//todo раскоментить тест
|
||||||
|
//
|
||||||
|
class Sdf01ExecutorTest {
|
||||||
|
// extends AbstractServiceTest {
|
||||||
|
// public final static DateTimeFormatter datFormatter = DateTimeFormatter.ofPattern("dd.MM.yy");
|
||||||
|
// public final static String acc = "123456789";
|
||||||
|
// private static final MatcherFactory.Matcher<SDf02> SDF_02_MATCHER = usingIgnoringFieldsComparator("created", "comment", "outSDfId", "generationTime", "generationId", "id");
|
||||||
|
// private final Long ID = 1L;
|
||||||
|
// @Autowired
|
||||||
|
// Sdf01Executor sdf01Executor;
|
||||||
|
// private StatementRequest statementRequest;
|
||||||
|
// @SpyBean
|
||||||
|
// private MockProducer<String, Object> producer;
|
||||||
|
//
|
||||||
|
// @PostConstruct
|
||||||
|
// void init() {
|
||||||
|
// super.init();
|
||||||
|
// statementRequest = new StatementRequest();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * {@link Sdf01Executor#execute(Collection collection, StatementRequest statementRequest)}<br>
|
||||||
|
// * Тест проверяет генерацию сущностей {@link Result}, {@link Statement}, {@link SDf02}<br>
|
||||||
|
// * Входные параметры:<br>
|
||||||
|
// * accountId - {@link StatementRequest}: new StatementRequest()<br>
|
||||||
|
// * addresseeId - {@link Collection<SDf01>}<br>
|
||||||
|
// * addresseeId - {@link SDf01}<br>
|
||||||
|
// * {@link SDf01#market} - "U"<br>
|
||||||
|
// * {@link SDf01#deal} - "111111111"<br>
|
||||||
|
// * {@link SDf01#account} - "123456789"<br>
|
||||||
|
// * {@link SDf01#curr_code} - "RUR"<br>
|
||||||
|
// * {@link SDf01#dat} - текущая дата<br>
|
||||||
|
// * {@link SDf01#acc_type} - "A"<br>
|
||||||
|
// * {@link SDf01#remainder} - "1000"<br>
|
||||||
|
// */
|
||||||
|
// @Test
|
||||||
|
// void execute() {
|
||||||
|
// //check create statement, SDf02 and AccountBalance
|
||||||
|
// SDf01 sdf01 = getTestSdf01(ID, 1L);
|
||||||
|
// Company company = getTestCompany();
|
||||||
|
// companyMap.put(addresseeIdNew, company);
|
||||||
|
//
|
||||||
|
// Account account = getTestAccount(ID, acc);
|
||||||
|
// accountMap.put(accountIdNew, account);
|
||||||
|
//
|
||||||
|
// Result predictableResult = new Result();
|
||||||
|
// predictableResult.setGenerationId(ID);
|
||||||
|
// Statement predictableStatement = getTestStatement(currentId.getAndIncrement(), company, account, sdf01);
|
||||||
|
// predictableStatement.setOperationStatus(OperationStatus.Executed.getKey());
|
||||||
|
// SDf02 predictableSdf02 = getTestSdf02(currentId.getAndIncrement(), sdf01, ID);
|
||||||
|
// predictableStatement.setOutSDfId(predictableSdf02.getId());
|
||||||
|
// AccountResult predictableNewResult = getTestAccountResult(currentId.getAndIncrement(), account, company);
|
||||||
|
//
|
||||||
|
// Result result = sdf01Executor.execute(Collections.singletonList(sdf01), statementRequest);
|
||||||
|
// Statement resultStatement = statementImdg.getSingleObjectByFieldValues(Map.of("account", acc));
|
||||||
|
// SDf02 resultSdf02 = sdf02Imdg.getSingleObjectByFieldValues(Map.of("account", acc));
|
||||||
|
// AccountBalance resultAccountBalance = accountBalanceImdg.getSingleObjectByFieldValues(Map.of("account", acc));
|
||||||
|
//
|
||||||
|
// RESULT_MATCHER.assertMatch(result, predictableResult);
|
||||||
|
// STATEMENT_MATCHER.assertMatch(resultStatement, predictableStatement);
|
||||||
|
// SDF_02_MATCHER.assertMatch(resultSdf02, predictableSdf02);
|
||||||
|
// ACCOUNT_BALANCE_MATCHER.assertMatch(resultAccountBalance, predictableNewResult.getAccount());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * {@link Sdf01Executor#execute(Collection collection, StatementRequest statementRequest)}<br>
|
||||||
|
// * Тест проверяет валидацию<br>
|
||||||
|
// * Входные параметры:<br>
|
||||||
|
// * accountId - {@link StatementRequest}: new StatementRequest()<br>
|
||||||
|
// * addresseeId - {@link Collection<SDf01>}<br>
|
||||||
|
// * addresseeId - {@link SDf01}<br>
|
||||||
|
// * {@link SDf01#market} - "U"<br>
|
||||||
|
// * {@link SDf01#deal} - "111111111"<br>
|
||||||
|
// * {@link SDf01#account} - "123456789"<br>
|
||||||
|
// * {@link SDf01#curr_code} - "RUR"<br>
|
||||||
|
// * {@link SDf01#dat} - текущая дата<br>
|
||||||
|
// * {@link SDf01#acc_type} - "A"<br>
|
||||||
|
// * {@link SDf01#remainder} - "1000"<br>
|
||||||
|
// */
|
||||||
|
// @Test
|
||||||
|
// void validatedExecute() {
|
||||||
|
// //CompanyNotFound
|
||||||
|
// SDf01 sdf01 = getTestSdf01(ID, 1L);
|
||||||
|
// companyMap.delete(addresseeIdNew);
|
||||||
|
// checkError(new EnumMessage(BalanceError.CompanyNotFound), sdf01);
|
||||||
|
//
|
||||||
|
// sdf01.setDeal(null);
|
||||||
|
// checkError(new EnumMessage(BalanceError.CompanyNotFound), sdf01);
|
||||||
|
//
|
||||||
|
// //AccountNotPresent accountType=null
|
||||||
|
// sdf01.setDeal(deal);
|
||||||
|
// Company company = getTestCompany();
|
||||||
|
// companyMap.put(addresseeIdNew, company);
|
||||||
|
// Account account = new Account();
|
||||||
|
// account.setAccount(acc);
|
||||||
|
// account.setStatus(Status.Active.getKey());
|
||||||
|
// accountMap.put(accountIdNew, account);
|
||||||
|
// checkErrorAccountNotPresent(company, sdf01);
|
||||||
|
//
|
||||||
|
// //AccountNotPresent account=null
|
||||||
|
// account.setAccount(null);
|
||||||
|
// account.setAccountType(AccountType.Clrn.getKey());
|
||||||
|
// account.setStatus(Status.Active.getKey());
|
||||||
|
// accountMap.put(accountIdNew, account);
|
||||||
|
// checkErrorAccountNotPresent(company, sdf01);
|
||||||
|
//
|
||||||
|
// //AccountNotPresent sdf01.account==null
|
||||||
|
// sdf01.setAccount(null);
|
||||||
|
// checkErrorAccountNotPresent(company, sdf01);
|
||||||
|
//
|
||||||
|
// //CurrencyNotFound sdf01.curr_code =! "RUR"
|
||||||
|
// accountMap.put(accountIdNew, getTestAccount(ID, acc));
|
||||||
|
// sdf01.setAccount(acc);
|
||||||
|
// sdf01.setCurr_code("RUB");
|
||||||
|
// checkError(new EnumMessage(BalanceError.CurrencyNotFound), sdf01);
|
||||||
|
//
|
||||||
|
// //CurrencyNotFound sdf01.curr_code =! "RUR"
|
||||||
|
// sdf01.setCurr_code(null);
|
||||||
|
// checkError(new EnumMessage(BalanceError.CurrencyNotFound), sdf01);
|
||||||
|
//
|
||||||
|
// //CurrentDateOnly
|
||||||
|
// sdf01.setCurr_code("RUR");
|
||||||
|
// sdf01.setDat("19.01.23");
|
||||||
|
// checkError(new EnumMessage(BalanceError.CurrentDateOnly), sdf01);
|
||||||
|
//
|
||||||
|
// //CurrentDateOnly
|
||||||
|
// sdf01.setDat("19.01.2023");
|
||||||
|
// checkError(new EnumMessage(BalanceError.CurrentDateOnly), sdf01);
|
||||||
|
//
|
||||||
|
// //CurrentDateOnly
|
||||||
|
// sdf01.setDat(null);
|
||||||
|
// checkError(new EnumMessage(BalanceError.CurrentDateOnly), sdf01);
|
||||||
|
//
|
||||||
|
// //WrongAccount
|
||||||
|
// sdf01.setDat(LocalDate.now().format(datFormatter));
|
||||||
|
// sdf01.setAcc_type(null);
|
||||||
|
// checkError(new EnumMessage(BalanceError.WrongAccount), sdf01);
|
||||||
|
//
|
||||||
|
// //WrongMarket
|
||||||
|
// sdf01.setAcc_type("A");
|
||||||
|
// sdf01.setMarket(null);
|
||||||
|
// checkError(new EnumMessage(BalanceError.WrongMarket), sdf01);
|
||||||
|
//
|
||||||
|
// sdf01.setMarket("U");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void checkError(EnumMessage enumMessage, SDf01 sdf01) {
|
||||||
|
//// SDf01 sdf01 = getTestSdf01();
|
||||||
|
// SDf02 predictableSdf02 = getTestErrorSdf02(sdf01, enumMessage, ID);
|
||||||
|
// Result result = sdf01Executor.execute(Collections.singletonList(sdf01), statementRequest);
|
||||||
|
// Collection<SDf02> resultsSdf02 = sdf02Imdg.getCollectionObjectsByFieldValues(Map.of("account", acc));
|
||||||
|
// SDf02 resultSdf02 = resultsSdf02.stream().max((entry1, entry2) -> entry1.getId() > entry2.getId() ? 1 : -1).get();
|
||||||
|
// SDF_02_MATCHER.assertMatch(resultSdf02, predictableSdf02);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void checkErrorAccountNotPresent(Company company, SDf01 sdf01) {
|
||||||
|
// Result predictableResult = new Result();
|
||||||
|
// predictableResult.getAccountRequests().add(createAccountRequestPart(sdf01.getId(), sdf01.getAccount(), company.getId()));
|
||||||
|
// Result result = sdf01Executor.execute(Collections.singletonList(sdf01), statementRequest);
|
||||||
|
// RESULT_MATCHER.assertMatch(result, predictableResult);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private SDf02 getTestSdf02(Long id, SDf01 sdf01, Long generationIdForGroup) {
|
||||||
|
// SDf02 sDf02 = new SDf02();
|
||||||
|
// sDf02.setId(id);
|
||||||
|
// sDf02.setCurr_code(sdf01.getCurr_code());
|
||||||
|
// sDf02.setAccount(sdf01.getAccount());
|
||||||
|
// sDf02.setRemainder(sdf01.getRemainder());
|
||||||
|
// sDf02.setDeal(sdf01.getDeal());
|
||||||
|
// sDf02.setAcc_code(sdf01.getAcc_code());
|
||||||
|
// sDf02.setDat(sdf01.getDat());
|
||||||
|
// sDf02.setMarket(sdf01.getMarket());
|
||||||
|
// sDf02.setAcc_name(sdf01.getAcc_name());
|
||||||
|
// sDf02.setAcc_type(sdf01.getAcc_type());
|
||||||
|
// sDf02.setSumengage(sdf01.getSumengage());
|
||||||
|
// sDf02.setSumunblock(sdf01.getSumunblock());
|
||||||
|
// sDf02.setFile_type(sdf01.getFile_type());
|
||||||
|
// sDf02.setInSDfId(sdf01.getId());
|
||||||
|
// sDf02.setGenerationId(generationIdForGroup);
|
||||||
|
// sDf02.setGenerationTime(Instant.now());
|
||||||
|
// sDf02.setResult("OK!");
|
||||||
|
// return sDf02;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private Statement getTestStatement(Long id, Company company, Account account, SDf01 sdf01) {
|
||||||
|
// Statement statement = new Statement();
|
||||||
|
// statement.setId(id);
|
||||||
|
// statement.setAddresseeId(company.getId());
|
||||||
|
// statement.setSenderId(Sender.Prc.getId());
|
||||||
|
// statement.setCreated(Instant.now());
|
||||||
|
// statement.setClearingDate(LocalDate.now());
|
||||||
|
// statement.setStatementType(StatementType.full.getKey());
|
||||||
|
// statement.setAccountId(account.getId());
|
||||||
|
// statement.setAccount(sdf01.getAccount());
|
||||||
|
// statement.setInOutDirection(InOutDirection.in.getKey());
|
||||||
|
// statement.setSettlementDate(LocalDate.parse(sdf01.getDat(), datFormatter));
|
||||||
|
// statement.setAmount(BigDecimalUtil.parse(sdf01.getRemainder()));
|
||||||
|
// statement.setOperationStatus(OperationStatus.Pending.getKey());
|
||||||
|
// statement.setInSDfId(sdf01.getId());
|
||||||
|
// statement.setInOutSDfType(InOutSDfType.type1.getKey());
|
||||||
|
// return statement;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private SDf02 getTestErrorSdf02(SDf01 sdf01, EnumMessage error, Long generationIdForGroup) {
|
||||||
|
// SDf02 sDf02 = new SDf02();
|
||||||
|
// sDf02.setId(ID);
|
||||||
|
// sDf02.setCurr_code(sdf01.getCurr_code());
|
||||||
|
// sDf02.setAccount(sdf01.getAccount());
|
||||||
|
// sDf02.setRemainder(sdf01.getRemainder());
|
||||||
|
// sDf02.setDeal(sdf01.getDeal());
|
||||||
|
// sDf02.setAcc_code(sdf01.getAcc_code());
|
||||||
|
// sDf02.setDat(sdf01.getDat());
|
||||||
|
// sDf02.setMarket(sdf01.getMarket());
|
||||||
|
// sDf02.setAcc_name(sdf01.getAcc_name());
|
||||||
|
// sDf02.setAcc_type(sdf01.getAcc_type());
|
||||||
|
// sDf02.setSumengage(sdf01.getSumengage());
|
||||||
|
// sDf02.setSumunblock(sdf01.getSumunblock());
|
||||||
|
// sDf02.setFile_type(sdf01.getFile_type());
|
||||||
|
// sDf02.setInSDfId(sdf01.getId());
|
||||||
|
// String errorId = error.getSubject().getId().toString();
|
||||||
|
// sDf02.setResult(errorId.substring(errorId.length() - 3));
|
||||||
|
// sDf02.setGenerationId(generationIdForGroup);
|
||||||
|
// sDf02.setGenerationTime(Instant.now());
|
||||||
|
// return sDf02;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private AccountSdfRequestPart createAccountRequestPart(Long sdf01Id, String account, Long companyId) {
|
||||||
|
// AccountSdfRequestPart req = new AccountSdfRequestPart();
|
||||||
|
// req.setAccount(account);
|
||||||
|
// req.setCompanyId(companyId);
|
||||||
|
// req.setAccountType(AccountType.Clrn.getKey());
|
||||||
|
// req.setSdfId(sdf01Id);
|
||||||
|
// return req;
|
||||||
|
// }
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue