account-service http://jira.mfd.msk:8088/browse/CLS-631 правки валидации TradingClearingRegistryList
This commit is contained in:
parent
9bd0ad49ec
commit
0e5f2ed054
2 changed files with 16 additions and 8 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
|
|
@ -14,6 +15,7 @@ import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
|||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.CurrencyCode;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
|
|
@ -52,7 +54,7 @@ public class TradingClearingRegistryListValidationConfig {
|
|||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.TradingClearingRegistryNotFound,
|
||||
false),
|
||||
new ExistAllCurrencyAccountId<>("accountId",
|
||||
new ExistAllAccountId<>("accountId",
|
||||
TradingClearingRegistryListNewRequest::getAccountId,
|
||||
false,
|
||||
null),
|
||||
|
|
@ -120,13 +122,13 @@ public class TradingClearingRegistryListValidationConfig {
|
|||
}
|
||||
|
||||
|
||||
public static class ExistAllCurrencyAccountId<R> implements IValidationRule<ImdgValidationContext<R>> {
|
||||
public static class ExistAllAccountId<R> implements IValidationRule<ImdgValidationContext<R>> {
|
||||
String fieldName;
|
||||
Function<R, Long> accountIdGetter;
|
||||
boolean required;
|
||||
Function<R, Long> idGetter;
|
||||
|
||||
public ExistAllCurrencyAccountId(String fieldName, Function<R, Long> accountIdGetter, boolean required, Function<R, Long> idGetter) {
|
||||
public ExistAllAccountId(String fieldName, Function<R, Long> accountIdGetter, boolean required, Function<R, Long> idGetter) {
|
||||
this.fieldName = fieldName;
|
||||
this.accountIdGetter = accountIdGetter;
|
||||
this.required = required;
|
||||
|
|
@ -149,7 +151,11 @@ public class TradingClearingRegistryListValidationConfig {
|
|||
Account byIdObject = accountImdg.getSingleObjectByID(accountId);
|
||||
if (byIdObject == null)
|
||||
return of(AccountError.AccountNotFound, accountId, fieldName);
|
||||
if (!AccountType.Curr.equalsByKey(byIdObject.getAccountType())) {
|
||||
if (!IEnumKey.contains(byIdObject.getAccountType(), AccountType.Clrn, AccountType.Info)) {
|
||||
return of(AccountError.AccountIsNotACurrency, accountId,
|
||||
fieldName, "expected: CLRN/INFO but is " + byIdObject.getAccountType()); // Счет %S не
|
||||
}
|
||||
if (CurrencyCode.isRub(byIdObject.getCurrency()) || StringUtils.isEmpty(byIdObject.getCurrency())) {
|
||||
return of(AccountError.AccountIsNotACurrency, accountId, fieldName); // Счет %S не валютный
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,8 @@ class TradingClearingRegistryListServiceTest {
|
|||
c2Account.setAccount("AAAX-44654-CURR");
|
||||
c2Account.setStatus("ACTV");
|
||||
c2Account.setCompanyId(COMPANY_ID); // для валидации принадлежности счёта
|
||||
c2Account.setAccountType(AccountType.Curr.getKey());
|
||||
c2Account.setAccountType(AccountType.Info.getKey());
|
||||
c2Account.setCurrency("USD");
|
||||
accounts.insert(c2Account);
|
||||
|
||||
Account c3Account = new Account();
|
||||
|
|
@ -175,7 +176,8 @@ class TradingClearingRegistryListServiceTest {
|
|||
c3Account.setAccount("AAAX-12654-CURR");
|
||||
c3Account.setStatus("ACTV");
|
||||
c3Account.setCompanyId(COMPANY_ID); // для валидации принадлежности счёта
|
||||
c3Account.setAccountType(AccountType.Curr.getKey());
|
||||
c3Account.setAccountType(AccountType.Info.getKey());
|
||||
c3Account.setCurrency("USD");
|
||||
accounts.insert(c3Account);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
|
|
@ -201,7 +203,7 @@ class TradingClearingRegistryListServiceTest {
|
|||
final String ccCode = null;
|
||||
TradingClearingRegistryListNewRequest tcrlNewRequest = new TradingClearingRegistryListNewRequest();
|
||||
tcrlNewRequest.setTradingClearingRegistryId(TCR_ID);
|
||||
tcrlNewRequest.setCurrencyAccountList(Arrays.asList(134L));
|
||||
tcrlNewRequest.setAccountId(134L);
|
||||
tcrlNewRequest.setStatus("ACTV");
|
||||
|
||||
ClientCode predictableClientCode = new ClientCode();
|
||||
|
|
@ -212,7 +214,7 @@ class TradingClearingRegistryListServiceTest {
|
|||
TradingClearingRegistryList predictableTradingClearingRegistryList = new TradingClearingRegistryList();
|
||||
predictableTradingClearingRegistryList.setAccountId(134L);
|
||||
predictableTradingClearingRegistryList.setStatus("ACTV");
|
||||
predictableTradingClearingRegistryList.setCurrency("RUB");
|
||||
predictableTradingClearingRegistryList.setCurrency("USD");
|
||||
|
||||
//ACT
|
||||
String jsonString = TestUtils.getJsonStringForNew(tcrlNewRequest, ID);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue