fix tests
This commit is contained in:
parent
2716196bf7
commit
6e6d866445
5 changed files with 78 additions and 83 deletions
|
|
@ -5,11 +5,13 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import ru.clearing.classes.statics.data.account.Account;
|
import ru.clearing.classes.statics.data.account.Account;
|
||||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||||
import ru.clearing.classes.statics.data.company.Company;
|
import ru.clearing.classes.statics.data.company.Company;
|
||||||
|
import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
|
||||||
import ru.spcex.clearing.account.errors.AccountError;
|
import ru.spcex.clearing.account.errors.AccountError;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountUpdateRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountUpdateRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||||
|
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||||
import ru.spcex.clearing.validation.common.rules.EnumPresentRule;
|
import ru.spcex.clearing.validation.common.rules.EnumPresentRule;
|
||||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||||
|
|
@ -72,14 +74,12 @@ public class BankAccountValidationConfig {
|
||||||
CurrencyCode.values(),
|
CurrencyCode.values(),
|
||||||
AccountError.WrongFieldValue,
|
AccountError.WrongFieldValue,
|
||||||
AccountError.RequiredFieldEmpty),
|
AccountError.RequiredFieldEmpty),
|
||||||
// todo currency codes not present in currency_code_dictionary, uncomment when present
|
DictionaryPresentRule.instance("currency",
|
||||||
//
|
BankAccountNewRequest::getCurrency,
|
||||||
// DictionaryPresentRule.instance("currency",
|
IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
||||||
// BankAccountNewRequest::getCurrency,
|
CurrencyCodeDictionary.class,
|
||||||
// IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
AccountError.RequiredFieldEmpty,
|
||||||
// CurrencyCodeDictionary.class,
|
AccountError.WrongFieldValue),
|
||||||
// AccountError.RequiredFieldEmpty,
|
|
||||||
// AccountError.WrongFieldValue),
|
|
||||||
FieldRequiredRule.instance("bankIdentificationCode",
|
FieldRequiredRule.instance("bankIdentificationCode",
|
||||||
BankAccountNewRequest::getBankIdentificationCode,
|
BankAccountNewRequest::getBankIdentificationCode,
|
||||||
AccountError.RequiredFieldEmpty),
|
AccountError.RequiredFieldEmpty),
|
||||||
|
|
@ -128,16 +128,14 @@ public class BankAccountValidationConfig {
|
||||||
CurrencyCode.values(),
|
CurrencyCode.values(),
|
||||||
false,
|
false,
|
||||||
AccountError.WrongFieldValue,
|
AccountError.WrongFieldValue,
|
||||||
AccountError.RequiredFieldEmpty)
|
AccountError.RequiredFieldEmpty),
|
||||||
// todo currency codes not present in currency_code_dictionary, uncomment when present
|
DictionaryPresentRule.instance("currency",
|
||||||
//
|
BankAccountUpdateRequest::getCurrency,
|
||||||
// DictionaryPresentRule.instance("currency",
|
IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
||||||
// BankAccountUpdateRequest::getCurrency,
|
CurrencyCodeDictionary.class,
|
||||||
// IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
AccountError.RequiredFieldEmpty,
|
||||||
// CurrencyCodeDictionary.class,
|
AccountError.WrongFieldValue,
|
||||||
// AccountError.RequiredFieldEmpty,
|
false)
|
||||||
// AccountError.WrongFieldValue,
|
|
||||||
// false)
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||||
import ru.spcex.platform.utils.validation.IValidator;
|
import ru.spcex.platform.utils.validation.IValidator;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
|
@ -156,6 +157,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
||||||
|
|
||||||
Collection<Account> companies = accountMap.getCollectionObjectsByFieldValues(Map.of("companyId", companyId));
|
Collection<Account> companies = accountMap.getCollectionObjectsByFieldValues(Map.of("companyId", companyId));
|
||||||
|
|
||||||
|
Instant now = Instant.now();
|
||||||
Account account = new Account();
|
Account account = new Account();
|
||||||
account.setAccount(req.getAccount());
|
account.setAccount(req.getAccount());
|
||||||
account.setAccountType(req.getAccountType());
|
account.setAccountType(req.getAccountType());
|
||||||
|
|
@ -163,7 +165,9 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
||||||
account.setStatus(req.getStatus());
|
account.setStatus(req.getStatus());
|
||||||
// todo выяснить у репортера, что писать в это поле если это не первый счет компании
|
// todo выяснить у репортера, что писать в это поле если это не первый счет компании
|
||||||
account.setProcessingSign(companies.isEmpty() ? Allowed.ALLOWED.getKey() : null);
|
account.setProcessingSign(companies.isEmpty() ? Allowed.ALLOWED.getKey() : null);
|
||||||
account.setCompanyId(req.getCompanyId());
|
account.setCompanyId(relation.getConsumerId());
|
||||||
|
account.setCreated(now);
|
||||||
|
account.setUpdated(now);
|
||||||
Long id = accountMap.insert(account);
|
Long id = accountMap.insert(account);
|
||||||
|
|
||||||
log.debug("successfully processed, new account id {}", id);
|
log.debug("successfully processed, new account id {}", id);
|
||||||
|
|
@ -194,6 +198,8 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
||||||
if (request.getStatus() != null && !account.getStatus().equalsIgnoreCase(request.getStatus()))
|
if (request.getStatus() != null && !account.getStatus().equalsIgnoreCase(request.getStatus()))
|
||||||
return makeError(AccountError.WrongFieldValue, "status", userRequest.getId());
|
return makeError(AccountError.WrongFieldValue, "status", userRequest.getId());
|
||||||
|
|
||||||
|
account.setUpdated(Instant.now());
|
||||||
|
|
||||||
accountMap.update(account);
|
accountMap.update(account);
|
||||||
|
|
||||||
log.debug("successfully processed, update account id {}", account.getId());
|
log.debug("successfully processed, update account id {}", account.getId());
|
||||||
|
|
@ -213,6 +219,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
||||||
|
|
||||||
Account account = accountMap.getSingleObjectByID(request.getId());
|
Account account = accountMap.getSingleObjectByID(request.getId());
|
||||||
account.setStatus(AccountStatus.BLOCKED.getKey());
|
account.setStatus(AccountStatus.BLOCKED.getKey());
|
||||||
|
account.setUpdated(Instant.now());
|
||||||
|
|
||||||
accountMap.update(account);
|
accountMap.update(account);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,31 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
||||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||||
|
|
||||||
BankAccountNewRequest req = userRequest.getRequestPayload();
|
BankAccountNewRequest req = userRequest.getRequestPayload();
|
||||||
|
|
||||||
|
Long relationId = null;
|
||||||
|
Long consumerId = null;
|
||||||
|
String relationSqlCondition = String.format("consumerId = %s and service = %s", req.companyId,
|
||||||
|
ru.spcex.platform.enumeration.Service.MKR.getKey());
|
||||||
|
Relation relationByCompany = relationMap.getSingleObjectBySQL(relationSqlCondition);
|
||||||
|
if (relationByCompany != null) {
|
||||||
|
relationId = relationByCompany.getId();
|
||||||
|
consumerId = relationByCompany.getConsumerId();
|
||||||
|
} else {
|
||||||
|
log.warn("Not found relation by condition: {}", relationSqlCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
Instant now = Instant.now();
|
||||||
|
Account account = new Account();
|
||||||
|
account.setAccount(req.getAccount());
|
||||||
|
account.setAccountType(AccountType.Bank.getKey());
|
||||||
|
account.setStatus(AccountStatus.ACTIVE.getKey());
|
||||||
|
account.setRelationId(relationId);
|
||||||
|
account.setCompanyId(consumerId);
|
||||||
|
account.setProcessingSign(Allowed.ALLOWED.getKey());
|
||||||
|
account.setCreated(now);
|
||||||
|
account.setUpdated(now);
|
||||||
|
accountMap.insert(account);
|
||||||
|
|
||||||
BankAccount bankAccount = new BankAccount();
|
BankAccount bankAccount = new BankAccount();
|
||||||
bankAccount.setBankIdentificationCode(req.getBankIdentificationCode());
|
bankAccount.setBankIdentificationCode(req.getBankIdentificationCode());
|
||||||
bankAccount.setBankName(req.getBankName());
|
bankAccount.setBankName(req.getBankName());
|
||||||
|
|
@ -109,27 +134,6 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
||||||
bankAccount.setTaxRegistrationReasonCode(req.getTaxRegistrationReasonCode());
|
bankAccount.setTaxRegistrationReasonCode(req.getTaxRegistrationReasonCode());
|
||||||
bankAccount.setAccount(req.getAccount());
|
bankAccount.setAccount(req.getAccount());
|
||||||
bankAccount.setCompanyId(req.getCompanyId());
|
bankAccount.setCompanyId(req.getCompanyId());
|
||||||
|
|
||||||
Account account = new Account();
|
|
||||||
account.setAccount(req.account);
|
|
||||||
account.setAccountType(AccountType.Bank.getKey());
|
|
||||||
|
|
||||||
String relationSqlCondition = String.format("consumerId = %s and service = %s", req.companyId,
|
|
||||||
ru.spcex.platform.enumeration.Service.MKR.getKey());
|
|
||||||
Relation relationByCompany = relationMap.getSingleObjectBySQL(relationSqlCondition);
|
|
||||||
if (relationByCompany != null) {
|
|
||||||
account.setRelationId(relationByCompany.getId());
|
|
||||||
account.setCompanyId(relationByCompany.getConsumerId());
|
|
||||||
} else {
|
|
||||||
log.warn("Not found relation by condition: {}", relationSqlCondition);
|
|
||||||
}
|
|
||||||
account.setStatus(AccountStatus.ACTIVE.getKey());
|
|
||||||
account.setProcessingSign(Allowed.ALLOWED.getKey());
|
|
||||||
account.setCreated(Instant.now());
|
|
||||||
account.setUpdated(Instant.now());
|
|
||||||
|
|
||||||
accountMap.insert(account);
|
|
||||||
|
|
||||||
bankAccount.setAccountId(account.getId());
|
bankAccount.setAccountId(account.getId());
|
||||||
Long bankAccountId = bankAccountMap.insert(bankAccount);
|
Long bankAccountId = bankAccountMap.insert(bankAccount);
|
||||||
log.debug("successfully processed, new id {}", bankAccountId);
|
log.debug("successfully processed, new id {}", bankAccountId);
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ import javax.annotation.PostConstruct;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.mockito.Mockito.timeout;
|
import static org.mockito.Mockito.timeout;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration.currentID;
|
import static ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration.currentID;
|
||||||
|
|
@ -131,14 +131,16 @@ class AccountServiceTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void accountCorrespondentNew() {
|
void accountCorrespondentNew() {
|
||||||
|
String uniqueAccount = account + UUID.randomUUID();
|
||||||
|
|
||||||
AccountCorrespondentNewRequest accountCorrespondentNewRequest = new AccountCorrespondentNewRequest();
|
AccountCorrespondentNewRequest accountCorrespondentNewRequest = new AccountCorrespondentNewRequest();
|
||||||
accountCorrespondentNewRequest.setAccount(account);
|
accountCorrespondentNewRequest.setAccount(uniqueAccount);
|
||||||
accountCorrespondentNewRequest.setAccountType(AccountType.Corr.getKey());
|
accountCorrespondentNewRequest.setAccountType(AccountType.Corr.getKey());
|
||||||
accountCorrespondentNewRequest.setCompanyId(companyId);
|
accountCorrespondentNewRequest.setCompanyId(companyId);
|
||||||
accountCorrespondentNewRequest.setStatus(AccountStatus.ACTIVE.getKey());
|
accountCorrespondentNewRequest.setStatus(AccountStatus.ACTIVE.getKey());
|
||||||
|
|
||||||
Account predictableAccount = new Account();
|
Account predictableAccount = new Account();
|
||||||
predictableAccount.setAccount(account);
|
predictableAccount.setAccount(uniqueAccount);
|
||||||
predictableAccount.setAccountType(AccountType.Corr.getKey());
|
predictableAccount.setAccountType(AccountType.Corr.getKey());
|
||||||
predictableAccount.setCompanyId(companyId);
|
predictableAccount.setCompanyId(companyId);
|
||||||
predictableAccount.setProcessingSign(Allowed.ALLOWED.getKey());
|
predictableAccount.setProcessingSign(Allowed.ALLOWED.getKey());
|
||||||
|
|
@ -155,10 +157,12 @@ class AccountServiceTest {
|
||||||
|
|
||||||
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
||||||
|
|
||||||
Account resultNew = accountImdg.getCollectionObjectsByFieldValues(Map.of("companyId", companyId)).iterator().next();
|
Account resultNew = accountImdg.getCollectionObjectsByFieldValues(Map.of("account", uniqueAccount)).iterator().next();
|
||||||
predictableAccount.setId(resultNew.getId());
|
predictableAccount.setId(resultNew.getId());
|
||||||
|
predictableAccount.setUpdated(resultNew.getUpdated());
|
||||||
|
predictableAccount.setCreated(resultNew.getCreated());
|
||||||
ACCOUNT_MATCHER.assertMatch(resultNew, predictableAccount);
|
ACCOUNT_MATCHER.assertMatch(resultNew, predictableAccount);
|
||||||
|
accountImdg.delete(resultNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -195,7 +199,9 @@ class AccountServiceTest {
|
||||||
existAccount.setAccount(updatedAccount);
|
existAccount.setAccount(updatedAccount);
|
||||||
|
|
||||||
Account resultUpdating = accountImdg.getSingleObjectByID(accountId);
|
Account resultUpdating = accountImdg.getSingleObjectByID(accountId);
|
||||||
|
existAccount.setUpdated(resultUpdating.getUpdated());
|
||||||
ACCOUNT_MATCHER.assertMatch(resultUpdating, existAccount);
|
ACCOUNT_MATCHER.assertMatch(resultUpdating, existAccount);
|
||||||
|
accountImdg.delete(resultUpdating);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -224,8 +230,10 @@ class AccountServiceTest {
|
||||||
|
|
||||||
Account resultBlock = accountImdg.getSingleObjectByID(accountId);
|
Account resultBlock = accountImdg.getSingleObjectByID(accountId);
|
||||||
existAccount.setStatus(AccountStatus.BLOCKED.getKey());
|
existAccount.setStatus(AccountStatus.BLOCKED.getKey());
|
||||||
|
existAccount.setUpdated(resultBlock.getUpdated());
|
||||||
|
|
||||||
ACCOUNT_MATCHER.assertMatch(existAccount, resultBlock);
|
ACCOUNT_MATCHER.assertMatch(existAccount, resultBlock);
|
||||||
|
accountImdg.delete(resultBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -250,7 +258,6 @@ class AccountServiceTest {
|
||||||
AccountSdf01Request accountSdf01Request = new AccountSdf01Request();
|
AccountSdf01Request accountSdf01Request = new AccountSdf01Request();
|
||||||
accountSdf01Request.setGroupingSdf01Id(firstID);
|
accountSdf01Request.setGroupingSdf01Id(firstID);
|
||||||
accountSdf01Request.setAccounts(Collections.singletonList(accountSdfRequestPart));
|
accountSdf01Request.setAccounts(Collections.singletonList(accountSdfRequestPart));
|
||||||
|
|
||||||
BaseRequest<AccountSdf01Request> baseNewRequest = new BaseRequest<>();
|
BaseRequest<AccountSdf01Request> baseNewRequest = new BaseRequest<>();
|
||||||
baseNewRequest.setRequestPayload(accountSdf01Request);
|
baseNewRequest.setRequestPayload(accountSdf01Request);
|
||||||
baseNewRequest.setId(firstID);
|
baseNewRequest.setId(firstID);
|
||||||
|
|
@ -279,33 +286,25 @@ class AccountServiceTest {
|
||||||
|
|
||||||
Account predictableAccount = new Account();
|
Account predictableAccount = new Account();
|
||||||
predictableAccount.setAccount(account);
|
predictableAccount.setAccount(account);
|
||||||
predictableAccount.setId(firstID);
|
|
||||||
predictableAccount.setCompanyId(firstID);
|
predictableAccount.setCompanyId(firstID);
|
||||||
|
|
||||||
RequestInfo predictableRequestInfo = new RequestInfo();
|
RequestInfo predictableRequestInfo = new RequestInfo();
|
||||||
predictableRequestInfo.setId(secondID);
|
predictableRequestInfo.setId(secondID);
|
||||||
predictableRequestInfo.setStatus(Status.Processing);
|
predictableRequestInfo.setStatus(Status.Processing);
|
||||||
|
|
||||||
//ACT
|
|
||||||
hazelcastServiceTest.waitTillReadyState();
|
|
||||||
|
|
||||||
//KAFKA
|
//KAFKA
|
||||||
addRecordToKafka((MockConsumer) accountService.getConsumer(), TOPIC_ACCOUNT_NEW, PARTITION, 0, jsonBaseNewRequest);
|
addRecordToKafka((MockConsumer) accountService.getConsumer(), TOPIC_ACCOUNT_NEW, PARTITION, 0, jsonBaseNewRequest);
|
||||||
|
|
||||||
//waiting for kafka producer send message (finale event)
|
//waiting for kafka producer send message (finale event)
|
||||||
verify(producer, timeout(30_000L).times(1))
|
verify(producer, timeout(30_000L).times(2))
|
||||||
.send(producerRecord.capture());
|
.send(producerRecord.capture());
|
||||||
BaseRequest<Object> baseRequestObject = (BaseRequest<Object>) producerRecord.getValue().value();
|
|
||||||
|
|
||||||
ImdgHazelcast<Account> accountImdg = (ImdgHazelcast<Account>) hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
ImdgHazelcast<Account> accountImdg = (ImdgHazelcast<Account>) hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||||
ImdgHazelcast<RequestInfo> requestInfoImdg = (ImdgHazelcast<RequestInfo>) hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
|
||||||
|
|
||||||
//ASSERT
|
//ASSERT
|
||||||
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", account));
|
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", account));
|
||||||
RequestInfo requestInfoResult = requestInfoImdg.getSingleObjectByID(baseRequestObject.getId());
|
predictableAccount.setId(accountResult.getId());
|
||||||
|
|
||||||
assertEquals(Consts.STATEMENT_PROCESS, producerRecord.getValue().topic());
|
|
||||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||||
REQUEST_INFO_MATCHER_MATCHER.assertMatch(requestInfoResult, predictableRequestInfo);
|
accountImdg.delete(accountResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,6 +16,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
import ru.clearing.classes.statics.data.account.Account;
|
import ru.clearing.classes.statics.data.account.Account;
|
||||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||||
import ru.clearing.classes.statics.data.company.Company;
|
import ru.clearing.classes.statics.data.company.Company;
|
||||||
|
import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
|
||||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||||
import ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration;
|
import ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration;
|
||||||
import ru.spcex.clearing.account.config.KafkaConfigTest;
|
import ru.spcex.clearing.account.config.KafkaConfigTest;
|
||||||
|
|
@ -83,6 +84,7 @@ public class BankAccountServiceTest {
|
||||||
protected Imdg<Company> companyImdg;
|
protected Imdg<Company> companyImdg;
|
||||||
private Imdg<BankAccount> bankAccountImdg;
|
private Imdg<BankAccount> bankAccountImdg;
|
||||||
private Imdg<Account> accountImdg;
|
private Imdg<Account> accountImdg;
|
||||||
|
private Imdg<CurrencyCodeDictionary> currencyCodeDictionaryImdg;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IMessageResolver messageResolver;
|
private IMessageResolver messageResolver;
|
||||||
|
|
@ -105,6 +107,13 @@ public class BankAccountServiceTest {
|
||||||
companyImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
companyImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||||
bankAccountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
bankAccountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||||
accountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
accountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||||
|
currencyCodeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||||
|
IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class
|
||||||
|
);
|
||||||
|
CurrencyCodeDictionary currencyCodeDictionary = new CurrencyCodeDictionary();
|
||||||
|
currencyCodeDictionary.setCode("RUB");
|
||||||
|
currencyCodeDictionary.setName("RUB");
|
||||||
|
currencyCodeDictionaryImdg.insert(currencyCodeDictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -207,28 +216,6 @@ public class BankAccountServiceTest {
|
||||||
checkError(errMsg, bankAccountNewRequest);
|
checkError(errMsg, bankAccountNewRequest);
|
||||||
bankAccountNewRequest.setCompanyId(addresseeIdNew);
|
bankAccountNewRequest.setCompanyId(addresseeIdNew);
|
||||||
|
|
||||||
//AccountValidationRule.RubRequiredFields
|
|
||||||
//RequiredFieldEmpty
|
|
||||||
bankAccountNewRequest.setCorrespondentAccount(null);
|
|
||||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "correspondentAccount"));
|
|
||||||
checkError(errMsg, bankAccountNewRequest);
|
|
||||||
|
|
||||||
bankAccountNewRequest.setCorrespondentAccount(correspondentAccount);
|
|
||||||
bankAccountNewRequest.setCorrespondentAccountName(null);
|
|
||||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "correspondentAccountName"));
|
|
||||||
checkError(errMsg, bankAccountNewRequest);
|
|
||||||
|
|
||||||
bankAccountNewRequest.setCorrespondentAccountName(correspondentAccountName);
|
|
||||||
bankAccountNewRequest.setTaxpayerIdentificationNumber(null);
|
|
||||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "taxpayerIdentificationNumber"));
|
|
||||||
checkError(errMsg, bankAccountNewRequest);
|
|
||||||
|
|
||||||
bankAccountNewRequest.setTaxpayerIdentificationNumber(taxpayerIdentificationNumber);
|
|
||||||
bankAccountNewRequest.setTaxRegistrationReasonCode(null);
|
|
||||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "taxRegistrationReasonCode"));
|
|
||||||
checkError(errMsg, bankAccountNewRequest);
|
|
||||||
bankAccountNewRequest.setTaxRegistrationReasonCode(taxRegistrationReasonCode);
|
|
||||||
|
|
||||||
//AccountValidationRule.CompanyPresent
|
//AccountValidationRule.CompanyPresent
|
||||||
//CompanyNotFound
|
//CompanyNotFound
|
||||||
bankAccountNewRequest.setCompanyId(999924535239L);
|
bankAccountNewRequest.setCompanyId(999924535239L);
|
||||||
|
|
@ -297,6 +284,7 @@ public class BankAccountServiceTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void bankAccountUpdate() {
|
void bankAccountUpdate() {
|
||||||
|
clearImdg(accountImdg);
|
||||||
//ARRANGE
|
//ARRANGE
|
||||||
// Company company = getTestCompany();
|
// Company company = getTestCompany();
|
||||||
// companyImdg.insert(company);
|
// companyImdg.insert(company);
|
||||||
|
|
@ -337,12 +325,11 @@ public class BankAccountServiceTest {
|
||||||
//ASSERT
|
//ASSERT
|
||||||
waitingWhenAddedRecordAndCheckIt(ID, producer, producerRecord);
|
waitingWhenAddedRecordAndCheckIt(ID, producer, producerRecord);
|
||||||
|
|
||||||
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", acc));
|
Account accountResult = accountImdg.getSingleObjectByID(predictableAccount.getId());
|
||||||
BankAccount resultUpdating = bankAccountImdg.getSingleObjectBySQL(String.format("account = %s or companyId = %s", acc, addresseeIdNew));
|
BankAccount resultUpdating = bankAccountImdg.getSingleObjectByID(predictableUpdateBankAccount.getId());
|
||||||
|
predictableAccount.setUpdated(accountResult.getUpdated());
|
||||||
predictableUpdateBankAccount.setAccountId(resultUpdating.getAccountId());
|
predictableUpdateBankAccount.setAccountId(resultUpdating.getAccountId());
|
||||||
predictableUpdateBankAccount.setCompanyId(resultUpdating.getCompanyId());
|
predictableUpdateBankAccount.setCompanyId(resultUpdating.getCompanyId());
|
||||||
predictableAccount.setUpdated(accountResult.getUpdated());
|
|
||||||
|
|
||||||
BANK_ACCOUNT_MATCHER.assertMatch(resultUpdating, predictableUpdateBankAccount);
|
BANK_ACCOUNT_MATCHER.assertMatch(resultUpdating, predictableUpdateBankAccount);
|
||||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue