Merge remote-tracking branch 'origin/dev' into CLS-262
# Conflicts: # clearing-parent/pom.xml
This commit is contained in:
commit
05285cb12a
90 changed files with 3826 additions and 501 deletions
|
|
@ -65,6 +65,14 @@
|
|||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>security-util</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package ru.spcex.clearing.account.config;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.platform.enumeration.UserRole;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
|
||||
@Configuration
|
||||
public class BeanConfiguration {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public UserRoleVerification userRoleVerification(ImdgProvider imdgProvider, IMessageResolver messageResolver) {
|
||||
return new UserRoleVerification(imdgProvider, messageResolver, UserRole.Admin, AccountError.UserVerifyDenial);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package ru.spcex.clearing.account.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.enumeration.SimpleMessageResolver;
|
||||
|
||||
@Configuration
|
||||
public class ErrorResolverConfig {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver() {
|
||||
return new SimpleMessageResolver();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
package ru.spcex.clearing.account.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
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.company.CompanySymbols;
|
||||
import ru.spcex.clearing.account.validation.AccountValidationRule;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class ValidationConfig {
|
||||
Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Map<String, Imdg<? extends SpcexObjectBase>> imdgs;
|
||||
|
||||
public ValidationConfig(ImdgProvider imdgProvider) {
|
||||
log.debug("Init validator config");
|
||||
this.imdgs = new HashMap<>();
|
||||
BiConsumer<String, Class<? extends SpcexObjectBase>> addImdg = (s, aClass) -> imdgs.put(s, imdgProvider.getImdg(s, aClass));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account, Account.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company, Company.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountBalance, AccountBalance.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* чтобы во всех валидаторах был один экземпляр Imdg
|
||||
*/
|
||||
private Imdg<?> getImdg(String key) {
|
||||
return imdgs.get(key);
|
||||
}
|
||||
|
||||
@Bean("bankAccountNewRequestValidator")
|
||||
public Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator() {
|
||||
log.debug("Create validator bankAccountNewRequestValidator");
|
||||
return bankAccountNewRequest -> {
|
||||
ImdgValidationContext<BankAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(bankAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, getImdg(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountBalance);
|
||||
|
||||
return new ValidatorImpl<>(context,
|
||||
AccountValidationRule.RequiredFields,
|
||||
AccountValidationRule.RubRequiredFields,
|
||||
AccountValidationRule.AccountIsNew,
|
||||
AccountValidationRule.CompanyPresent
|
||||
);
|
||||
};
|
||||
//todo после слияния ветки CLR_51_57 переписать на использование DictionaryPresentRule, FieldRequiredRule
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
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.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class AccountValidationConfig {
|
||||
|
||||
@Bean("correspondentAccountNewRequestValidator")
|
||||
public Function<CorrespondentAccountNewRequest, IValidator> correspondentAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return correspondentAccountNewRequest -> {
|
||||
ImdgValidationContext<CorrespondentAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(correspondentAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
CorrespondentAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive),
|
||||
FieldRequiredRule.instance("account",
|
||||
CorrespondentAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", accountValue);
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", AccountStatus.ACTIVE.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate, accountStatusPredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return null;
|
||||
return AccountError.AccountAlreadyExist;
|
||||
}),
|
||||
FieldRequiredRule.instance("status",
|
||||
CorrespondentAccountNewRequest::getStatus,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
false,
|
||||
statusValue -> {
|
||||
if (statusValue == null || AccountStatus.ACTIVE.equalsByKey(statusValue)) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
}),
|
||||
DictionaryPresentRule.instance("accountType",
|
||||
CorrespondentAccountNewRequest::getAccountType,
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary,
|
||||
AccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue,
|
||||
accountType -> {
|
||||
if (AccountType.Corr.equalsByKey(accountType.getCode())) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("correspondentAccountUpdateRequestValidator")
|
||||
public Function<CorrespondentAccountUpdateRequest, IValidator> correspondentAccountUpdateRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return correspondentAccountUpdateRequest -> {
|
||||
ImdgValidationContext<CorrespondentAccountUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(correspondentAccountUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
CorrespondentAccountUpdateRequest::getId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
account -> {
|
||||
String statusFromRequest = correspondentAccountUpdateRequest.getStatus();
|
||||
if (statusFromRequest != null && !statusFromRequest.equalsIgnoreCase(account.getStatus()))
|
||||
return AccountError.WrongFieldValue;
|
||||
return null;
|
||||
}),
|
||||
IdPresentRule.instance("companyId",
|
||||
CorrespondentAccountUpdateRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
false,
|
||||
company -> {
|
||||
IErrorEnumId error = WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive;
|
||||
error = Objects.equals(company.getId(), correspondentAccountUpdateRequest.getCompanyId()) ? error : AccountError.WrongFieldValue;
|
||||
return error;
|
||||
}),
|
||||
EnumPresentRule.instance("status",
|
||||
CorrespondentAccountUpdateRequest::getStatus,
|
||||
AccountStatus.values(),
|
||||
false,
|
||||
AccountError.WrongFieldValue,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("accountType",
|
||||
CorrespondentAccountUpdateRequest::getAccountType,
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary,
|
||||
AccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue,
|
||||
accountType -> {
|
||||
if (AccountType.Corr.equalsByKey(accountType.getCode())) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("correspondentAccountBlockRequestValidator")
|
||||
public Function<CommonDeleteRequest, IValidator> correspondentAccountBlockRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return correspondentAccountBlockRequest -> {
|
||||
ImdgValidationContext<CommonDeleteRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(correspondentAccountBlockRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
CommonDeleteRequest::getId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
account -> {
|
||||
if (AccountStatus.ACTIVE.equalsByKey(account.getStatus())) return null;
|
||||
return AccountError.AccountNotActive;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||
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.imdg.IMDGDistributedNames;
|
||||
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.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class BankAccountValidationConfig {
|
||||
|
||||
@Bean("bankAccountNewRequestValidator")
|
||||
public Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return bankAccountNewRequest -> {
|
||||
ImdgValidationContext<BankAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(bankAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CurrencyCodeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
BankAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive),
|
||||
FieldRequiredRule.instance("account",
|
||||
BankAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", accountValue);
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", AccountStatus.ACTIVE.getKey());
|
||||
ImdgPredicate accountTypePredicate = pb.equals("accountType", AccountType.Bank.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate,
|
||||
accountStatusPredicate,
|
||||
accountTypePredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return null;
|
||||
return AccountError.AccountAlreadyExist;
|
||||
}),
|
||||
DictionaryPresentRule.instance("currency",
|
||||
BankAccountNewRequest::getCurrency,
|
||||
IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
||||
CurrencyCodeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue),
|
||||
FieldRequiredRule.instance("bankIdentificationCode",
|
||||
BankAccountNewRequest::getBankIdentificationCode,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
FieldRequiredRule.instance("bankName",
|
||||
BankAccountNewRequest::getBankName,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
FieldRequiredRule.instance("destination",
|
||||
BankAccountNewRequest::getDestination,
|
||||
AccountError.RequiredFieldEmpty)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("bankAccountUpdateRequestValidator")
|
||||
public Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return bankAccountUpdateRequest -> {
|
||||
ImdgValidationContext<BankAccountUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(bankAccountUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CurrencyCodeDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
BankAccountUpdateRequest::getId,
|
||||
IMDGDistributedNames.Map_BankAccount,
|
||||
BankAccount.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
bankAccount -> {
|
||||
Long accountId = bankAccount.getAccountId();
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
Account account = accountImdg.getSingleObjectByID(accountId);
|
||||
if (account == null) return AccountError.AccountNotFound;
|
||||
if (!AccountStatus.ACTIVE.equalsByKey(account.getStatus())) return AccountError.AccountNotActive;
|
||||
return null;
|
||||
}),
|
||||
DictionaryPresentRule.instance("currency",
|
||||
BankAccountUpdateRequest::getCurrency,
|
||||
IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
||||
CurrencyCodeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("bankAccountBlockRequestValidator")
|
||||
public Function<CommonDeleteRequest, IValidator> bankAccountBlockRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return bankAccountBlockRequest -> {
|
||||
ImdgValidationContext<CommonDeleteRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(bankAccountBlockRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
CommonDeleteRequest::getId,
|
||||
IMDGDistributedNames.Map_BankAccount,
|
||||
BankAccount.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
bankAccount -> {
|
||||
Long accountId = bankAccount.getAccountId();
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
Account account = accountImdg.getSingleObjectByID(accountId);
|
||||
if (account == null) return AccountError.AccountNotFound;
|
||||
if (!AccountStatus.ACTIVE.equalsByKey(account.getStatus())) return AccountError.AccountNotActive;
|
||||
return null;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.ClearingAccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountUpdateRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class ClearingAccountValidationConfig {
|
||||
|
||||
@Bean("clearingAccountNewRequestValidator")
|
||||
public Function<ClearingAccountNewRequest, IValidator> clearingAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return clearingAccountNewRequest -> {
|
||||
ImdgValidationContext<ClearingAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(clearingAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
ClearingAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null),
|
||||
FieldRequiredRule.instance("account",
|
||||
ClearingAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", accountValue);
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", AccountStatus.ACTIVE.getKey());
|
||||
ImdgPredicate accountTypePredicate = pb.equals("accountType", AccountType.Clrn.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate,
|
||||
accountStatusPredicate,
|
||||
accountTypePredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return null;
|
||||
return AccountError.AccountAlreadyExist;
|
||||
}),
|
||||
DictionaryPresentRule.instance("clearingAccountType",
|
||||
ClearingAccountNewRequest::getClearingAccountType,
|
||||
IMDGDistributedNames.Map_ClearingAccountTypeDictionary,
|
||||
ClearingAccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Bean("clearingAccountUpdateRequestValidator")
|
||||
public Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return clearingAccountUpdateRequest -> {
|
||||
ImdgValidationContext<ClearingAccountUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(clearingAccountUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
FieldRequiredRule.instance("account",
|
||||
ClearingAccountUpdateRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", accountValue);
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", AccountStatus.ACTIVE.getKey());
|
||||
ImdgPredicate accountTypePredicate = pb.equals("accountType", AccountType.Clrn.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate,
|
||||
accountStatusPredicate,
|
||||
accountTypePredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return AccountError.AccountNotFound;
|
||||
return null;
|
||||
}),
|
||||
FieldRequiredRule.instance("status",
|
||||
ClearingAccountUpdateRequest::getStatus,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
statusValue -> {
|
||||
if (statusValue == 0 || statusValue == 1 || statusValue == 2) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
}),
|
||||
FieldRequiredRule.instance("deal",
|
||||
ClearingAccountUpdateRequest::getDeal,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
dealValue -> {
|
||||
Imdg<Company> companyImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
Company company = companyImdg.getSingleObjectByFieldValues(Map.of("tradingCode", dealValue));
|
||||
if (company == null) return AccountError.WrongFieldValue;
|
||||
return null;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.DepoAccountNewRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class DepoAccountValidationConfig {
|
||||
|
||||
@Bean("depoAccountNewRequestValidator")
|
||||
public Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return depoAccountNewRequest -> {
|
||||
ImdgValidationContext<DepoAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(depoAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_DepoAccount);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
DepoAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null),
|
||||
FieldRequiredRule.instance("account",
|
||||
DepoAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", accountValue);
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", AccountStatus.ACTIVE.getKey());
|
||||
ImdgPredicate accountTypePredicate = pb.equals("accountType", AccountType.Clrn.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate,
|
||||
accountStatusPredicate,
|
||||
accountTypePredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return null;
|
||||
return AccountError.AccountAlreadyExist;
|
||||
}),
|
||||
FieldRequiredRule.instance("depoAccountType",
|
||||
DepoAccountNewRequest::getDepoAccountType,
|
||||
AccountError.RequiredFieldEmpty)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.InformationAccountNewRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class InformationAccountValidationConfig {
|
||||
|
||||
@Bean("informationAccountNewRequestValidator")
|
||||
public Function<InformationAccountNewRequest, IValidator> informationAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return informationAccountNewRequest -> {
|
||||
ImdgValidationContext<InformationAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(informationAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_InformationAccount);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
InformationAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
company -> {
|
||||
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()))
|
||||
return AccountError.CompanyNotActive;
|
||||
Long companyId = company.getId();
|
||||
Imdg<InformationAccount> informationAccountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
Collection<InformationAccount> infoAccounts = informationAccountImdg.getCollectionObjectsByFieldValues(
|
||||
Map.of("companyId", companyId)
|
||||
);
|
||||
if (infoAccounts.isEmpty()) return null;
|
||||
return AccountError.InfoAccountAlreadyExist;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ClearingAccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Configuration
|
||||
public class ValidationConfig {
|
||||
|
||||
@Bean("imdgForValidation")
|
||||
public Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation(ImdgProvider imdgProvider) {
|
||||
final Map<String, Imdg<? extends SpcexObjectBase>> imdg = new HashMap<>();
|
||||
BiConsumer<String, Class<? extends SpcexObjectBase>> addImdg = (s, aClass) -> imdg.put(s, imdgProvider.getImdg(s, aClass));
|
||||
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company, Company.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccountTypeDictionary, ClearingAccountTypeDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account, Account.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
|
||||
return imdg;
|
||||
}
|
||||
|
||||
@Bean("validationHelper")
|
||||
public ValidationHelper validationHelper(IMessageResolver messageResolver) {
|
||||
return new ValidationHelper(messageResolver);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -3,12 +3,18 @@ package ru.spcex.clearing.account.errors;
|
|||
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
||||
|
||||
public enum AccountError implements IErrorEnumId {
|
||||
UserVerifyDenial(5001L),
|
||||
RequiredFieldEmpty(5002L),
|
||||
WrongFieldValue(5004L),
|
||||
AccountAlreadyExist(5010L),
|
||||
AccountNotFound(5011L),
|
||||
AccountNotActive(5012L),
|
||||
CompanyNotFound(5013L),
|
||||
CompanyNotActive(5014L),
|
||||
|
||||
InfoAccountAlreadyExist(5015L),
|
||||
ClearingCategoryNotFound(5019L)
|
||||
;
|
||||
|
||||
private final Long id;
|
||||
|
||||
AccountError(Long id) {
|
||||
|
|
|
|||
|
|
@ -1,51 +1,192 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.ClearingCategory;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class AccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Imdg<Account> accountMap;
|
||||
private final Imdg<ClearingMemberCategory> clearingMemberCategoryMap;
|
||||
private final Imdg<Relation> relationMap;
|
||||
private final KafkaSender kafkaSender;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator;
|
||||
private final Function<CorrespondentAccountUpdateRequest, IValidator> accountUpdateRequestValidator;
|
||||
private final Function<CommonDeleteRequest, IValidator> accountBlockRequestValidator;
|
||||
|
||||
@Autowired
|
||||
public AccountService(Consumer<String, Object> kafkaQueue, ImdgProvider imdgProvider, KafkaSender kafkaSender) {
|
||||
super(kafkaQueue);
|
||||
this.accountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
public AccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
KafkaSender kafkaSender,
|
||||
IMessageResolver messageResolver,
|
||||
UserRoleVerification userRoleVerification,
|
||||
ValidationHelper validationHelper,
|
||||
@Qualifier("correspondentAccountNewRequestValidator")
|
||||
Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator,
|
||||
@Qualifier("correspondentAccountUpdateRequestValidator")
|
||||
Function<CorrespondentAccountUpdateRequest, IValidator> accountUpdateRequestValidator,
|
||||
@Qualifier("correspondentAccountBlockRequestValidator")
|
||||
Function<CommonDeleteRequest, IValidator> accountBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.accountMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
this.clearingMemberCategoryMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
this.relationMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.messageResolver = messageResolver;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.validationHelper = validationHelper;
|
||||
this.accountNewRequestValidator = accountNewRequestValidator;
|
||||
this.accountUpdateRequestValidator = accountUpdateRequestValidator;
|
||||
this.accountBlockRequestValidator = accountBlockRequestValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(AccountSdf01Request.class)
|
||||
.setConsumer(this::accountNew)
|
||||
.forDestination(Consts.ACCOUNT_NEW, callbacks::put);
|
||||
.setConsumer(this::accountNewSdf01)
|
||||
.forDestination(Consts.ACCOUNT_NEW_SDF01, callbacks::put);
|
||||
callback(CorrespondentAccountNewRequest.class)
|
||||
.setConsumer(this::accountCorrespondentNew)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, callbacks::put);
|
||||
callback(CorrespondentAccountUpdateRequest.class)
|
||||
.setConsumer(this::correspondentAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, callbacks::put);
|
||||
callback(CommonDeleteRequest.class)
|
||||
.setConsumer(this::correspondentAccountBlock)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
private void accountNew(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
AccountSdf01Request req = userRequest.getRequestPayload();
|
||||
|
||||
public RequestInfoUpdate accountCorrespondentNew(BaseRequest<CorrespondentAccountNewRequest> userRequest) {
|
||||
log.debug("CorrespondentAccountNewRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
CorrespondentAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(req.getAccountType());
|
||||
account.setStatus(req.getStatus());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
|
||||
requestInfoUpdate = fillAccountFromRelation(account, userRequest.getId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
Long newId = accountMap.insert(account);
|
||||
log.debug("successfully processed, new account id {}", newId);
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate correspondentAccountUpdate(BaseRequest<CorrespondentAccountUpdateRequest> userRequest) {
|
||||
log.debug("CorrespondentAccountUpdateRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountUpdateRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
CorrespondentAccountUpdateRequest request = userRequest.getRequestPayload();
|
||||
|
||||
Account account = accountMap.getSingleObjectByID(request.getId());
|
||||
|
||||
if (request.getStatus() != null) account.setStatus(request.getStatus());
|
||||
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountMap.update(account);
|
||||
|
||||
log.debug("successfully processed, update account id {}", account.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate correspondentAccountBlock(BaseRequest<CommonDeleteRequest> userRequest) {
|
||||
log.debug("AccountBlockRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountBlockRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
CommonDeleteRequest request = userRequest.getRequestPayload();
|
||||
|
||||
Account account = accountMap.getSingleObjectByID(request.getId());
|
||||
account.setStatus(AccountStatus.BLOCKED.getKey());
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountMap.update(account);
|
||||
|
||||
log.debug("successfully processed, block account id {}", account.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RequestInfoUpdate accountNewSdf01(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
log.debug("AccountSdf01Request received");
|
||||
|
||||
AccountSdf01Request req = userRequest.getRequestPayload();
|
||||
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
||||
for (AccountSdfRequestPart accountReq : req.getAccounts()) {
|
||||
Account account = new Account();
|
||||
|
|
@ -58,13 +199,15 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
}
|
||||
sendStatementRequestBack(req.getGroupingSdf01Id(), accountToStatement);
|
||||
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void accountUpdateWithBrake(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
public void accountUpdateWithBrake(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
|
||||
}
|
||||
|
||||
private AccountSdfToStatementRequestPart responsePart(Long sdf01Id) {
|
||||
public AccountSdfToStatementRequestPart responsePart(Long sdf01Id) {
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(sdf01Id);
|
||||
responsePart.setErrorCode(null);
|
||||
|
|
@ -72,10 +215,59 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
return responsePart;
|
||||
}
|
||||
|
||||
private void sendStatementRequestBack(Long groupingSdf01Id, List<AccountSdfToStatementRequestPart> results) {
|
||||
public void sendStatementRequestBack(Long groupingSdf01Id, List<AccountSdfToStatementRequestPart> results) {
|
||||
StatementRequest request = new StatementRequest();
|
||||
request.setGroupId(groupingSdf01Id);
|
||||
request.setAccountCreationResults(results);
|
||||
kafkaSender.sendRequestToQueue(Consts.STATEMENT_PROCESS, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Заполняет поля relationId и companyId из соответствующей записи Relation
|
||||
*
|
||||
* @param requestId Идентификатор запроса для вывода лога
|
||||
*/
|
||||
public RequestInfoUpdate fillAccountFromRelation(Account account, Long requestId) {
|
||||
Long companyId = account.getCompanyId();
|
||||
ImdgPredicateBuilder clearingMemberCategoryPredicateBuilder = clearingMemberCategoryMap.predicateBuilder();
|
||||
ImdgPredicate companyIdEquals = clearingMemberCategoryPredicateBuilder.equals("companyId", companyId);
|
||||
Collection<ClearingMemberCategory> clearingMemberCategories = clearingMemberCategoryMap.getCollectionObjectsByPredicate(companyIdEquals);
|
||||
|
||||
if (clearingMemberCategories.isEmpty())
|
||||
return makeError(AccountError.ClearingCategoryNotFound, "clearingMemberCategory[companyId]", requestId);
|
||||
if (clearingMemberCategories.size() > 1)
|
||||
log.warn("ClearingMemberCategory for companyId {} contains multiply elements, use first", companyId);
|
||||
ClearingMemberCategory clearingMemberCategory = clearingMemberCategories.iterator().next();
|
||||
|
||||
ImdgPredicateBuilder relationPredicateBuilder = relationMap.predicateBuilder();
|
||||
ImdgPredicate consumerIdPredicate = relationPredicateBuilder.equals("consumerId", companyId);
|
||||
ImdgPredicate servicePredicate;
|
||||
String clearingCategoryValue = clearingMemberCategory.getClearingMemberCategory();
|
||||
if (IEnumKey.contains(clearingCategoryValue, ClearingCategory.B, ClearingCategory.I, ClearingCategory.V)) {
|
||||
servicePredicate = relationPredicateBuilder.equals("service", ru.spcex.platform.enumeration.Service.MKR.getKey());
|
||||
} else if (IEnumKey.contains(clearingCategoryValue, ClearingCategory.F, ClearingCategory.C)) {
|
||||
servicePredicate = relationPredicateBuilder.equals("service", ru.spcex.platform.enumeration.Service.FOND.getKey());
|
||||
} else {
|
||||
return makeError(AccountError.ClearingCategoryNotFound, "relation[consumerId = companyId].service", requestId);
|
||||
}
|
||||
ImdgPredicate finalRelationPredicate = relationPredicateBuilder.and(consumerIdPredicate, servicePredicate);
|
||||
Collection<Relation> relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
||||
|
||||
if (relations.isEmpty()) return makeError(AccountError.WrongFieldValue, "companyId", requestId);
|
||||
if (relations.size() > 1)
|
||||
log.warn("Relation for consumerId {} contains multiply elements, use first", companyId);
|
||||
Relation relation = relations.iterator().next();
|
||||
account.setRelationId(relation.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private RequestInfoUpdate makeError(AccountError accountError, String fieldName, Long reqId) {
|
||||
String errMsg = messageResolver.resolve(new EnumMessage(accountError, fieldName));
|
||||
return new RequestInfoUpdate()
|
||||
.setId(reqId)
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
|
@ -19,18 +18,16 @@ import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountUpdate
|
|||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.Allowed;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
|
|
@ -38,30 +35,40 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Imdg<BankAccount> bankAccountMap;
|
||||
private final Imdg<Account> accountMap;
|
||||
private final Imdg<Relation> relationMap;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final ImdgProvider imdgProvider;
|
||||
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final ValidationHelper validationHelper;
|
||||
|
||||
private final AccountService accountService;
|
||||
|
||||
// private final Imdg<User> userImdg;
|
||||
// private final Imdg<UserRoleSession> userRoleSessionImdg;
|
||||
private final Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator;
|
||||
private final Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator;
|
||||
private final Function<CommonDeleteRequest, IValidator> bankAccountBlockRequestValidator;
|
||||
|
||||
@Autowired
|
||||
public BankAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
IMessageResolver messageResolver,
|
||||
|
||||
UserRoleVerification userRoleVerification,
|
||||
ValidationHelper validationHelper,
|
||||
AccountService accountService,
|
||||
@Qualifier("bankAccountNewRequestValidator")
|
||||
Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator) {
|
||||
Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator,
|
||||
@Qualifier("bankAccountUpdateRequestValidator")
|
||||
Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator,
|
||||
@Qualifier("bankAccountBlockRequestValidator")
|
||||
Function<CommonDeleteRequest, IValidator> bankAccountBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.bankAccountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
this.accountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.relationMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
|
||||
this.messageResolver = messageResolver;
|
||||
|
||||
// this.userImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_User, User.class);
|
||||
// this.userRoleSessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_UserRoleSession, UserRoleSession.class);
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.validationHelper = validationHelper;
|
||||
this.accountService = accountService;
|
||||
this.bankAccountNewRequestValidator = bankAccountNewRequestValidator;
|
||||
this.bankAccountUpdateRequestValidator = bankAccountUpdateRequestValidator;
|
||||
this.bankAccountBlockRequestValidator = bankAccountBlockRequestValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -73,82 +80,81 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
.setFunction(this::bankAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_BANK_ACCOUNT_UPDATE, callbacks::put);
|
||||
callback(CommonDeleteRequest.class)
|
||||
.setFunction(this::bankAccountDelete)
|
||||
.forDestination(Consts.DESTINATION_BANK_ACCOUNT_DELETE, callbacks::put);
|
||||
.setFunction(this::bankAccountBlock)
|
||||
.forDestination(Consts.DESTINATION_BANK_ACCOUNT_BLOCK, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
// protected Optional<EnumMessage> checkUserRole(Long userId) {
|
||||
// User user = userImdg.getSingleObjectByID(userId);
|
||||
// if (user == null) {
|
||||
// return Optional.of(new EnumMessage(AccountError.userNotFound(5007)));
|
||||
// }
|
||||
// UserRoleSession role=userRoleSessionImdg.getSingleObjectBySql("userId="+userId+" and userRoleSessions.userRole='ADMN'");
|
||||
// if (role == null) {
|
||||
// return Optional.of(new EnumMessage(AccountError.userNotFound(5001))); // Нет прав на проведение данной операции».
|
||||
// }
|
||||
// return Optional.empty();
|
||||
// }
|
||||
|
||||
private RequestInfoUpdate bankAccountNew(BaseRequest<BankAccountNewRequest> userRequest) {
|
||||
public RequestInfoUpdate bankAccountNew(BaseRequest<BankAccountNewRequest> userRequest) {
|
||||
log.debug("BankAccountNewRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, bankAccountNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
BankAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
// // проверка прав
|
||||
// checkUserRole(req.getUserId());
|
||||
// валидация
|
||||
IValidator validator = bankAccountNewRequestValidator.apply(req);
|
||||
Optional<EnumMessage> error = validator.tillFirstError();
|
||||
if (error.isPresent()) {
|
||||
log.warn("BankAccountNewRequest[{}] validation error: {}", userRequest.getId(), error.get());
|
||||
String errorMsg = messageResolver.resolve(error.get());
|
||||
return new RequestInfoUpdate()
|
||||
.setId(userRequest.getId())
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errorMsg);
|
||||
}
|
||||
|
||||
log.debug("BankAccountNewRequest received");
|
||||
BankAccount bankAccount = new BankAccount();
|
||||
bankAccount.setBankIdentificationCode(req.getBankIdentificationCode());
|
||||
bankAccount.setBankName(req.getBankName());
|
||||
bankAccount.setCorrespondentAccount(req.getCorrespondentAccount());
|
||||
bankAccount.setCorrespondentAccountName(req.getCorrespondentAccountName());
|
||||
bankAccount.setCurrency(req.getCurrency());
|
||||
bankAccount.setDestination(req.getDestination());
|
||||
bankAccount.setTaxpayerIdentificationNumber(req.getTaxpayerIdentificationNumber());
|
||||
bankAccount.setTaxRegistrationReasonCode(req.getTaxRegistrationReasonCode());
|
||||
bankAccount.setAccount(req.getAccount());
|
||||
bankAccount.setCompanyId(req.getCompanyId());
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(req.account);
|
||||
account.setAccount(req.getAccount());
|
||||
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());
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
accountMap.insert(account);
|
||||
Long bankAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
accountId = accountMap.insert(account);
|
||||
|
||||
bankAccount.setAccountId(account.getId());
|
||||
bankAccountMap.insert(bankAccount);
|
||||
log.debug("successfully processed, new id {}", bankAccount.getId());
|
||||
BankAccount bankAccount = new BankAccount();
|
||||
bankAccount.setBankIdentificationCode(req.getBankIdentificationCode());
|
||||
bankAccount.setBankName(req.getBankName());
|
||||
bankAccount.setCorrespondentAccount(req.getCorrespondentAccount());
|
||||
bankAccount.setCorrespondentAccountName(req.getCorrespondentAccountName());
|
||||
bankAccount.setCurrency(req.getCurrency());
|
||||
bankAccount.setDestination(req.getDestination());
|
||||
bankAccount.setTaxpayerIdentificationNumber(req.getTaxpayerIdentificationNumber());
|
||||
bankAccount.setTaxRegistrationReasonCode(req.getTaxRegistrationReasonCode());
|
||||
bankAccount.setAccount(req.getAccount());
|
||||
bankAccount.setCompanyId(req.getCompanyId());
|
||||
bankAccount.setAccountId(accountId);
|
||||
bankAccountId = bankAccountMap.insert(bankAccount);
|
||||
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new bank account id {}, account id {}", bankAccountId, accountId);
|
||||
} else {
|
||||
log.debug("failed insert, new bank account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
bankAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private RequestInfoUpdate bankAccountUpdate(BaseRequest<BankAccountUpdateRequest> userRequest) {
|
||||
BankAccountUpdateRequest req = userRequest.getRequestPayload();
|
||||
log.debug("BankAccountUpdateRequest received id = {}", req.getId());
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, bankAccountUpdateRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
BankAccount bankAccount = bankAccountMap.getSingleObjectByID(req.getId());
|
||||
bankAccount.setBankIdentificationCode(req.getBankIdentificationCode());
|
||||
bankAccount.setBankName(req.getBankName());
|
||||
|
|
@ -164,24 +170,68 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
account.setAccount(req.account);
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountMap.update(account);
|
||||
bankAccountMap.update(bankAccount);
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
accountMap.update(account);
|
||||
bankAccountMap.update(bankAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new bank account id {}, account id {}",
|
||||
bankAccount.getId(),
|
||||
account.getId());
|
||||
} else {
|
||||
log.debug("failed update, bank account id {}, new account id {}",
|
||||
bankAccount.getId(),
|
||||
account.getId());
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
log.debug("successfully update, existing bankAccount with id {}", bankAccount.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
private RequestInfoUpdate bankAccountDelete(BaseRequest<CommonDeleteRequest> userRequest) {
|
||||
private RequestInfoUpdate bankAccountBlock(BaseRequest<CommonDeleteRequest> userRequest) {
|
||||
CommonDeleteRequest req = userRequest.getRequestPayload();
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, bankAccountBlockRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
log.debug("CommonDeleteRequest received id = {}", req.getId());
|
||||
BankAccount bankAccount = bankAccountMap.getSingleObjectByID(req.getId());
|
||||
|
||||
Account account = accountMap.getSingleObjectByID(bankAccount.getAccountId());
|
||||
account.setStatus(AccountStatus.BLOCKED.getKey());
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountMap.update(account);
|
||||
bankAccountMap.delete(bankAccount);
|
||||
log.debug("successfully delete, existing bankAccount with id {}", bankAccount.getId());
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
accountMap.update(account);
|
||||
bankAccountMap.delete(bankAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new bank account id {}, account id {}",
|
||||
bankAccount.getId(),
|
||||
account.getId());
|
||||
} else {
|
||||
// todo выяснить, что возвращать из метода в этой ситуации
|
||||
log.debug("failed block, bank account id {}, new account id {}",
|
||||
bankAccount.getId(),
|
||||
account.getId());
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
log.debug("successfully block, existing bankAccount with id {}", bankAccount.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,168 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class ClearingAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final AccountService accountService;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final Function<ClearingAccountNewRequest, IValidator> clearingAccountNewRequestValidator;
|
||||
private final Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator;
|
||||
|
||||
@Autowired
|
||||
public ClearingAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaResponseQueue,
|
||||
AccountService accountService,
|
||||
ValidationHelper validationHelper,
|
||||
ImdgProvider imdgProvider,
|
||||
IMessageResolver messageResolver,
|
||||
@Qualifier("clearingAccountNewRequestValidator")
|
||||
Function<ClearingAccountNewRequest, IValidator> clearingAccountNewRequestValidator,
|
||||
@Qualifier("clearingAccountUpdateRequestValidator")
|
||||
Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.accountService = accountService;
|
||||
this.validationHelper = validationHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.clearingAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
this.messageResolver = messageResolver;
|
||||
this.clearingAccountNewRequestValidator = clearingAccountNewRequestValidator;
|
||||
this.clearingAccountUpdateRequestValidator = clearingAccountUpdateRequestValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
init();
|
||||
callback(ClearingAccountNewRequest.class)
|
||||
.setFunction(this::clearingAccountNew)
|
||||
.forDestination(Consts.DESTINATION_CLEARING_ACCOUNT_NEW, callbacks::put);
|
||||
callback(ClearingAccountUpdateRequest.class)
|
||||
.setFunction(this::clearingAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_CLEARING_ACCOUNT_UPDATE, callbacks::put);
|
||||
}
|
||||
|
||||
public RequestInfoUpdate clearingAccountNew(BaseRequest<ClearingAccountNewRequest> userRequest) {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(
|
||||
userRequest, clearingAccountNewRequestValidator
|
||||
);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ClearingAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Clrn.getKey());
|
||||
account.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
Long clearingAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
ClearingAccount clearingAccount = new ClearingAccount();
|
||||
clearingAccount.setCompanyId(req.getCompanyId());
|
||||
clearingAccount.setAccountId(accountId);
|
||||
clearingAccount.setClearingAccountType(req.getClearingAccountType());
|
||||
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new clearing account id {}, account id {}", clearingAccountId, accountId);
|
||||
} else {
|
||||
// todo выяснить, что возвращать из метода в этой ситуации
|
||||
log.debug("failed insert, new clearing account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
clearingAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate clearingAccountUpdate(BaseRequest<ClearingAccountUpdateRequest> userRequest) {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(
|
||||
userRequest, clearingAccountUpdateRequestValidator
|
||||
);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ClearingAccountUpdateRequest req = userRequest.getRequestPayload();
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", req.getAccount());
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", AccountStatus.ACTIVE.getKey());
|
||||
ImdgPredicate accountTypePredicate = pb.equals("accountType", AccountType.Clrn.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate,
|
||||
accountStatusPredicate,
|
||||
accountTypePredicate);
|
||||
|
||||
Account account = accountImdg.getCollectionObjectsByPredicate(finalPredicate).iterator().next();
|
||||
Long accountId = account.getId();
|
||||
|
||||
ClearingAccount clearingAccount = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", accountId));
|
||||
if (clearingAccount == null) {
|
||||
String errMsg = messageResolver.resolve(new EnumMessage(AccountError.AccountNotFound, account.getAccount()));
|
||||
return new RequestInfoUpdate()
|
||||
.setId(userRequest.getId())
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errMsg);
|
||||
}
|
||||
|
||||
Integer statusValue = req.getStatus();
|
||||
if (statusValue == 0) account.setStatus(AccountStatus.BLOCKED.getKey());
|
||||
else if (statusValue == 1) account.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
else if (statusValue == 2) account.setStatus(AccountStatus.CLOSE.getKey());
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountImdg.update(account);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.DepoAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class DepoAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final ValidationHelper validationHelper;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final AccountService accountService;
|
||||
private final Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator;
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<DepoAccount> depoAccountImdg;
|
||||
|
||||
public DepoAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ValidationHelper validationHelper,
|
||||
ImdgProvider imdgProvider,
|
||||
AccountService accountService,
|
||||
@Qualifier("depoAccountNewRequestValidator")
|
||||
Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.validationHelper = validationHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountService = accountService;
|
||||
this.depoAccountNewRequestValidator = depoAccountNewRequestValidator;
|
||||
this.accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.depoAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
callback(DepoAccountNewRequest.class)
|
||||
.setConsumer(this::depoAccountNew)
|
||||
.forDestination(Consts.DESTINATION_DEPO_ACCOUNT_NEW, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
public RequestInfoUpdate depoAccountNew(BaseRequest<DepoAccountNewRequest> userRequest) {
|
||||
log.debug("DepoAccountNewRequest received");
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(
|
||||
userRequest, depoAccountNewRequestValidator
|
||||
);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
DepoAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Depo.getKey());
|
||||
account.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
Long depoAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
DepoAccount depoAccount = new DepoAccount();
|
||||
depoAccount.setCompanyId(req.getCompanyId());
|
||||
depoAccount.setAccountId(accountId);
|
||||
depoAccount.setDepoAccountType(req.getDepoAccountType());
|
||||
depoAccountId = depoAccountImdg.insert(depoAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new depo account id {}, account id {}", depoAccountId, accountId);
|
||||
} else {
|
||||
// todo выяснить, что возвращать из метода в этой ситуации
|
||||
log.debug("failed insert, new depo account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
depoAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.InformationAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class InformationAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final IMessageResolver messageResolver;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final AccountService accountService;
|
||||
private final Function<InformationAccountNewRequest, IValidator> infoAccountNewRequestValidator;
|
||||
private final Imdg<InformationAccount> informationAccountImdg;
|
||||
private final Imdg<Account> accountImdg;
|
||||
|
||||
@Autowired
|
||||
public InformationAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaResponseQueue,
|
||||
IMessageResolver messageResolver,
|
||||
ImdgProvider imdgProvider,
|
||||
ValidationHelper validationHelper,
|
||||
AccountService accountService,
|
||||
@Qualifier("informationAccountNewRequestValidator")
|
||||
Function<InformationAccountNewRequest, IValidator> infoAccountNewRequestValidator) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.messageResolver = messageResolver;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.validationHelper = validationHelper;
|
||||
this.accountService = accountService;
|
||||
this.infoAccountNewRequestValidator = infoAccountNewRequestValidator;
|
||||
this.informationAccountImdg = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
this.accountImdg = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
callback(InformationAccountNewRequest.class)
|
||||
.setConsumer(this::informationAccountNew)
|
||||
.forDestination(Consts.DESTINATION_INFORMATION_ACCOUNT_NEW, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
public RequestInfoUpdate informationAccountNew(BaseRequest<InformationAccountNewRequest> userRequest) {
|
||||
log.debug("InformationAccountNewRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, infoAccountNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
Long newId = informationAccountImdg.nextIDSequenceFor();
|
||||
String accountValue = generateInfoAccount(newId);
|
||||
|
||||
ImdgPredicateBuilder accountPredicateBuilder = accountImdg.predicateBuilder();
|
||||
ImdgPredicate companyIdPredicate = accountPredicateBuilder.equals("companyId", 1);
|
||||
ImdgPredicate accountTypePredicate = accountPredicateBuilder.equals("accountType", AccountType.Anlt.getKey());
|
||||
ImdgPredicate andPredicate = accountPredicateBuilder.and(companyIdPredicate, accountTypePredicate);
|
||||
Collection<Account> accountsAnlt = accountImdg.getCollectionObjectsByPredicate(andPredicate);
|
||||
if (accountsAnlt.isEmpty()) {
|
||||
String errMsg = messageResolver.resolve(new EnumMessage(AccountError.WrongFieldValue, "clearingAccountId"));
|
||||
return new RequestInfoUpdate()
|
||||
.setId(userRequest.getId())
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errMsg);
|
||||
} else if (accountsAnlt.size() > 1) {
|
||||
log.warn("Account for companyId 1 and accountType=ANLT contains multiply elements, use first");
|
||||
}
|
||||
Account anltAccount = accountsAnlt.iterator().next();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(accountValue);
|
||||
account.setAccountType(AccountType.Info.getKey());
|
||||
account.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
account.setCompanyId(userRequest.getRequestPayload().getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
imdgTransaction.beginTransaction();
|
||||
boolean txOk = false;
|
||||
Long informationAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
try {
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
InformationAccount informationAccount = new InformationAccount();
|
||||
informationAccount.setId(newId);
|
||||
informationAccount.setAccountId(accountId);
|
||||
informationAccount.setClearingAccountId(anltAccount.getId());
|
||||
informationAccount.setCompanyId(userRequest.getRequestPayload().getCompanyId());
|
||||
informationAccountId = informationAccountImdg.insert(informationAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
} else {
|
||||
// todo выяснить, что возвращать из метода в этой ситуации
|
||||
log.debug("failed insert, new information account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String generateInfoAccount(Long id) {
|
||||
return "%d%d%08d%d".formatted(39911, 810, id, 7000);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,34 +15,51 @@ import org.springframework.boot.test.mock.mockito.SpyBean;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration;
|
||||
import ru.spcex.clearing.account.config.KafkaConfigTest;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.account.utils.MatcherFactory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
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.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
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.verify;
|
||||
import static ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration.currentID;
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.account.utils.TestUtils.addRecordToKafka;
|
||||
import static ru.spcex.clearing.account.utils.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountService.class,
|
||||
HazelcastServiceTestConfiguration.class,
|
||||
KafkaConfigTest.class})
|
||||
|
|
@ -50,8 +67,10 @@ class AccountServiceTest {
|
|||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<RequestInfo> REQUEST_INFO_MATCHER_MATCHER = usingIgnoringFieldsComparator("created");
|
||||
private static final int PARTITION = 0;
|
||||
private static final String TOPIC_ACCOUNT_NEW = Consts.ACCOUNT_NEW;
|
||||
private static final String TOPIC_ACCOUNT_NEW = Consts.ACCOUNT_NEW_SDF01;
|
||||
private static final String account = "123456789123";
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
@Autowired
|
||||
AccountService accountService;
|
||||
@Autowired
|
||||
|
|
@ -63,8 +82,157 @@ class AccountServiceTest {
|
|||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
accountTypeDictionary.setCode(AccountType.Corr.getKey());
|
||||
accountTypeDictionary.setName(AccountType.Corr.getKey());
|
||||
accountTypeDictionaryImdg.insert(accountTypeDictionary);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountCorrespondentNew() {
|
||||
String uniqueAccount = account + UUID.randomUUID();
|
||||
|
||||
CorrespondentAccountNewRequest correspondentAccountNewRequest = new CorrespondentAccountNewRequest();
|
||||
correspondentAccountNewRequest.setAccount(uniqueAccount);
|
||||
correspondentAccountNewRequest.setAccountType(AccountType.Corr.getKey());
|
||||
correspondentAccountNewRequest.setCompanyId(companyId);
|
||||
correspondentAccountNewRequest.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(uniqueAccount);
|
||||
predictableAccount.setAccountType(AccountType.Corr.getKey());
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
predictableAccount.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
|
||||
String jsonString = getJsonStringForNew(correspondentAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
||||
|
||||
Account resultNew = accountImdg.getCollectionObjectsByFieldValues(Map.of("account", uniqueAccount)).iterator().next();
|
||||
predictableAccount.setId(resultNew.getId());
|
||||
predictableAccount.setUpdated(resultNew.getUpdated());
|
||||
predictableAccount.setCreated(resultNew.getCreated());
|
||||
ACCOUNT_MATCHER.assertMatch(resultNew, predictableAccount);
|
||||
accountImdg.delete(resultNew);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountCorrespondentUpdate() {
|
||||
Account existAccount = new Account();
|
||||
existAccount.setAccount(account);
|
||||
existAccount.setAccountType(AccountType.Corr.getKey());
|
||||
existAccount.setStatus(AccountStatus.CLOSE.getKey());
|
||||
existAccount.setCompanyId(companyId);
|
||||
Long accountId = accountImdg.insert(existAccount);
|
||||
|
||||
CorrespondentAccountUpdateRequest correspondentAccountUpdateRequest = new CorrespondentAccountUpdateRequest();
|
||||
correspondentAccountUpdateRequest.setAccount(account);
|
||||
correspondentAccountUpdateRequest.setAccountType(AccountType.Corr.getKey());
|
||||
correspondentAccountUpdateRequest.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
correspondentAccountUpdateRequest.setCompanyId(companyId);
|
||||
correspondentAccountUpdateRequest.setId(accountId);
|
||||
|
||||
|
||||
String jsonString = getJsonStringForUPDATE(correspondentAccountUpdateRequest, 0);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
||||
|
||||
Account resultUpdating = accountImdg.getSingleObjectByID(accountId);
|
||||
existAccount.setUpdated(resultUpdating.getUpdated());
|
||||
ACCOUNT_MATCHER.assertMatch(resultUpdating, existAccount);
|
||||
accountImdg.delete(resultUpdating);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountCorrespondentBlock() {
|
||||
Account existAccount = new Account();
|
||||
existAccount.setAccount(account);
|
||||
existAccount.setAccountType(AccountType.Corr.getKey());
|
||||
existAccount.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
existAccount.setCompanyId(companyId);
|
||||
Long accountId = accountImdg.insert(existAccount);
|
||||
|
||||
CommonDeleteRequest commonDeleteRequest = new CommonDeleteRequest();
|
||||
commonDeleteRequest.setId(accountId);
|
||||
|
||||
String jsonString = getJsonStringForDELETE(commonDeleteRequest, 0);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
||||
|
||||
Account resultBlock = accountImdg.getSingleObjectByID(accountId);
|
||||
existAccount.setStatus(AccountStatus.BLOCKED.getKey());
|
||||
existAccount.setUpdated(resultBlock.getUpdated());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(existAccount, resultBlock);
|
||||
accountImdg.delete(resultBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link AccountService#accountNew(BaseRequest)}<br>
|
||||
* {@link AccountService#accountNewSdf01(BaseRequest)}<br>
|
||||
* Тест проверяет создание сущности {@link BaseRequest} в Hazelcast при передаче из Apache Kafka.<br>
|
||||
* Входной запрос {@link AccountSdf01Request}:<br>
|
||||
* {@link AccountSdfRequestPart#setSdfId} - текущий Id<br>
|
||||
|
|
@ -74,7 +242,7 @@ class AccountServiceTest {
|
|||
* {@link AccountSdf01Request#setAccounts} - Collections.singletonList(AccountSdfRequestPart)<br>
|
||||
*/
|
||||
@Test
|
||||
void accountNew() throws InterruptedException {
|
||||
void accountSdf01New() throws InterruptedException {
|
||||
//ARRANGE
|
||||
Long firstID = currentID.getAndIncrement();
|
||||
Long secondID = currentID.getAndIncrement();
|
||||
|
|
@ -85,7 +253,6 @@ class AccountServiceTest {
|
|||
AccountSdf01Request accountSdf01Request = new AccountSdf01Request();
|
||||
accountSdf01Request.setGroupingSdf01Id(firstID);
|
||||
accountSdf01Request.setAccounts(Collections.singletonList(accountSdfRequestPart));
|
||||
|
||||
BaseRequest<AccountSdf01Request> baseNewRequest = new BaseRequest<>();
|
||||
baseNewRequest.setRequestPayload(accountSdf01Request);
|
||||
baseNewRequest.setId(firstID);
|
||||
|
|
@ -114,33 +281,25 @@ class AccountServiceTest {
|
|||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(account);
|
||||
predictableAccount.setId(firstID);
|
||||
predictableAccount.setCompanyId(firstID);
|
||||
|
||||
RequestInfo predictableRequestInfo = new RequestInfo();
|
||||
predictableRequestInfo.setId(secondID);
|
||||
predictableRequestInfo.setStatus(Status.Processing);
|
||||
|
||||
//ACT
|
||||
hazelcastServiceTest.waitTillReadyState();
|
||||
|
||||
//KAFKA
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(), TOPIC_ACCOUNT_NEW, PARTITION, 0, jsonBaseNewRequest);
|
||||
|
||||
//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());
|
||||
BaseRequest<Object> baseRequestObject = (BaseRequest<Object>) producerRecord.getValue().value();
|
||||
|
||||
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
|
||||
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", account));
|
||||
RequestInfo requestInfoResult = requestInfoImdg.getSingleObjectByID(baseRequestObject.getId());
|
||||
|
||||
assertEquals(Consts.STATEMENT_PROCESS, producerRecord.getValue().topic());
|
||||
predictableAccount.setId(accountResult.getId());
|
||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||
REQUEST_INFO_MATCHER_MATCHER.assertMatch(requestInfoResult, predictableRequestInfo);
|
||||
accountImdg.delete(accountResult);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,11 +15,17 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.spcex.clearing.account.config.ErrorResolverConfig;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration;
|
||||
import ru.spcex.clearing.account.config.KafkaConfigTest;
|
||||
import ru.spcex.clearing.account.config.ValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.BankAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.account.utils.MatcherFactory.Matcher;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
|
|
@ -29,11 +35,11 @@ import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewReq
|
|||
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.service.RequestInfoUpdate;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.Allowed;
|
||||
import ru.spcex.platform.enumeration.Status;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
|
@ -47,9 +53,12 @@ import static ru.spcex.clearing.platform.messaging.service.Status.Error;
|
|||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
ErrorResolverConfig.class,
|
||||
AccountService.class,
|
||||
BankAccountService.class,
|
||||
ValidationConfig.class,
|
||||
BankAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
BeanConfiguration.class,
|
||||
HazelcastServiceTestConfiguration.class,
|
||||
KafkaConfigTest.class})
|
||||
public class BankAccountServiceTest {
|
||||
|
|
@ -59,7 +68,7 @@ public class BankAccountServiceTest {
|
|||
private static final int PARTITION = 0;
|
||||
private static final String TOPIC_ACCOUNT_NEW = Consts.DESTINATION_BANK_ACCOUNT_NEW;
|
||||
private static final String TOPIC_ACCOUNT_UPDATE = Consts.DESTINATION_BANK_ACCOUNT_UPDATE;
|
||||
private static final String TOPIC_ACCOUNT_DELETE = Consts.DESTINATION_BANK_ACCOUNT_DELETE;
|
||||
private static final String TOPIC_ACCOUNT_DELETE = Consts.DESTINATION_BANK_ACCOUNT_BLOCK;
|
||||
private static final Long ID = 0L;
|
||||
private static final AtomicInteger countRun = new AtomicInteger(1);
|
||||
private static final Long accountId = 12L;
|
||||
|
|
@ -77,6 +86,12 @@ public class BankAccountServiceTest {
|
|||
protected Imdg<Company> companyImdg;
|
||||
private Imdg<BankAccount> bankAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<CurrencyCodeDictionary> currencyCodeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
@Autowired
|
||||
private IMessageResolver messageResolver;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
|
|
@ -96,6 +111,19 @@ public class BankAccountServiceTest {
|
|||
companyImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
bankAccountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
accountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
currencyCodeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
CurrencyCodeDictionary currencyCodeDictionary = new CurrencyCodeDictionary();
|
||||
currencyCodeDictionary.setCode("RUB");
|
||||
currencyCodeDictionary.setName("RUB");
|
||||
currencyCodeDictionaryImdg.insert(currencyCodeDictionary);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,10 +144,27 @@ public class BankAccountServiceTest {
|
|||
public void bankAccountNew() {
|
||||
//ARRANGE
|
||||
BankAccount predictableBankAccount = getBankAccount();
|
||||
|
||||
Company company = getTestCompany();
|
||||
companyImdg.insert(company);
|
||||
Long companyId = companyImdg.insert(company);
|
||||
Long relationId = 777L;
|
||||
Account predictableAccount = getTestAccount(accountId, acc);
|
||||
predictableAccount.setProcessingSign(null);
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
predictableAccount.setRelationId(relationId);
|
||||
clearImdg(accountImdg);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
BankAccountNewRequest bankAccountNewRequest = getBankAccountNewRequest(predictableBankAccount);
|
||||
String jsonString = getJsonStringForNew(bankAccountNewRequest, ID);
|
||||
|
||||
|
|
@ -160,60 +205,55 @@ public class BankAccountServiceTest {
|
|||
companyImdg.insert(company);
|
||||
BankAccountNewRequest bankAccountNewRequest = getBankAccountNewRequest(predictableBankAccount);
|
||||
|
||||
String errMsg;
|
||||
//AccountValidationRule.RequiredFields
|
||||
//WrongFieldValue
|
||||
bankAccountNewRequest.setCurrency(null);
|
||||
checkError("(5004) args [currency]", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "currency"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCurrency("TT0");
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.WrongFieldValue, "currency"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCurrency(currency);
|
||||
bankAccountNewRequest.setBankIdentificationCode(null);
|
||||
checkError("(5004) args [bankIdentificationCode]", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "bankIdentificationCode"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setBankIdentificationCode(bankIdentificationCode);
|
||||
bankAccountNewRequest.setBankName(null);
|
||||
checkError("(5004) args [bankName]", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "bankName"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setBankName(bankName);
|
||||
bankAccountNewRequest.setAccount(null);
|
||||
checkError("(5004) args [account]", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "account"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setAccount(acc);
|
||||
bankAccountNewRequest.setDestination(null);
|
||||
checkError("(5004) args [destination]", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "destination"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setDestination(destination);
|
||||
bankAccountNewRequest.setCompanyId(null);
|
||||
checkError("(5004) args [companyId]", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "companyId"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
bankAccountNewRequest.setCompanyId(addresseeIdNew);
|
||||
|
||||
//AccountValidationRule.RubRequiredFields
|
||||
//WrongFieldValue
|
||||
bankAccountNewRequest.setCorrespondentAccount(null);
|
||||
checkError("(5004) args [correspondentAccount]", bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCorrespondentAccount(correspondentAccount);
|
||||
bankAccountNewRequest.setCorrespondentAccountName(null);
|
||||
checkError("(5004) args [correspondentAccountName]", bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCorrespondentAccountName(correspondentAccountName);
|
||||
bankAccountNewRequest.setTaxpayerIdentificationNumber(null);
|
||||
checkError("(5004) args [taxpayerIdentificationNumber]", bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setTaxpayerIdentificationNumber(taxpayerIdentificationNumber);
|
||||
bankAccountNewRequest.setTaxRegistrationReasonCode(null);
|
||||
checkError("(5004) args [taxRegistrationReasonCode]", bankAccountNewRequest);
|
||||
bankAccountNewRequest.setTaxRegistrationReasonCode(taxRegistrationReasonCode);
|
||||
|
||||
//AccountValidationRule.CompanyPresent
|
||||
//CompanyNotFound
|
||||
bankAccountNewRequest.setCompanyId(999924535239L);
|
||||
checkError("(5013) args []", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.CompanyNotFound, "companyId"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
//CompanyNotActive
|
||||
company.setWorkflowStatus(Status.Blocked.getKey());
|
||||
companyImdg.insert(company);
|
||||
bankAccountNewRequest.setCompanyId(company.getId());
|
||||
checkError("(5014) args []", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.CompanyNotActive, "companyId"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
//AccountValidationRule.AccountIsNew
|
||||
//AccountAlreadyExist
|
||||
|
|
@ -221,7 +261,8 @@ public class BankAccountServiceTest {
|
|||
companyImdg.insert(company);
|
||||
Account existAccount = getTestAccount(accountId, acc);
|
||||
accountImdg.insert(existAccount);
|
||||
checkError("(5010) args []", bankAccountNewRequest);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.AccountAlreadyExist, "account"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
accountImdg.delete(existAccount);
|
||||
}
|
||||
|
||||
|
|
@ -269,6 +310,7 @@ public class BankAccountServiceTest {
|
|||
*/
|
||||
@Test
|
||||
void bankAccountUpdate() {
|
||||
clearImdg(accountImdg);
|
||||
//ARRANGE
|
||||
// Company company = getTestCompany();
|
||||
// companyImdg.insert(company);
|
||||
|
|
@ -282,7 +324,7 @@ public class BankAccountServiceTest {
|
|||
predictableUpdateBankAccount.setBankIdentificationCode("88888");
|
||||
predictableUpdateBankAccount.setCorrespondentAccount("894984646541316");
|
||||
predictableUpdateBankAccount.setCorrespondentAccountName("BIK OF NEW BUNK");
|
||||
predictableUpdateBankAccount.setCurrency("EU");
|
||||
predictableUpdateBankAccount.setCurrency("RUB");
|
||||
predictableUpdateBankAccount.setDestination("OOO NEW BUNK");
|
||||
predictableUpdateBankAccount.setTaxpayerIdentificationNumber("65468461321");
|
||||
predictableUpdateBankAccount.setTaxRegistrationReasonCode("532137");
|
||||
|
|
@ -309,12 +351,11 @@ public class BankAccountServiceTest {
|
|||
//ASSERT
|
||||
waitingWhenAddedRecordAndCheckIt(ID, producer, producerRecord);
|
||||
|
||||
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", acc));
|
||||
BankAccount resultUpdating = bankAccountImdg.getSingleObjectBySQL(String.format("account = %s or companyId = %s", acc, addresseeIdNew));
|
||||
Account accountResult = accountImdg.getSingleObjectByID(predictableAccount.getId());
|
||||
BankAccount resultUpdating = bankAccountImdg.getSingleObjectByID(predictableUpdateBankAccount.getId());
|
||||
predictableAccount.setUpdated(accountResult.getUpdated());
|
||||
predictableUpdateBankAccount.setAccountId(resultUpdating.getAccountId());
|
||||
predictableUpdateBankAccount.setCompanyId(resultUpdating.getCompanyId());
|
||||
predictableAccount.setUpdated(accountResult.getUpdated());
|
||||
|
||||
BANK_ACCOUNT_MATCHER.assertMatch(resultUpdating, predictableUpdateBankAccount);
|
||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||
}
|
||||
|
|
@ -332,6 +373,7 @@ public class BankAccountServiceTest {
|
|||
bankAccountImdg.insert(bankAccountExists);
|
||||
Account account = new Account();
|
||||
account.setId(accountId);
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
accountImdg.insert(account);
|
||||
|
||||
CommonDeleteRequest commonDeleteRequest = new CommonDeleteRequest();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,218 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
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.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ClearingAccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration;
|
||||
import ru.spcex.clearing.account.config.KafkaConfigTest;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ClearingAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.account.utils.MatcherFactory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountUpdateRequest;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.account.utils.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
ClearingAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountService.class,
|
||||
ClearingAccountService.class,
|
||||
HazelcastServiceTestConfiguration.class,
|
||||
KafkaConfigTest.class})
|
||||
class ClearingAccountServiceTest {
|
||||
public static final MatcherFactory.Matcher<ClearingAccount> CLEARING_ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator("created", "updated");
|
||||
private static final int PARTITION = 0;
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
private static final String CLEARING_ACCOUNT_TYPE_DICT = "A";
|
||||
private static final String ACCOUNT_VALUE = "account-value";
|
||||
private static final String TRADING_CODE = "trading-code";
|
||||
|
||||
@Autowired
|
||||
ClearingAccountService clearingAccountService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
|
||||
private Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<ClearingAccountTypeDictionary> clearingAccountTypeDictionaryImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
clearingAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
clearingAccountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingAccountTypeDictionary, ClearingAccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
company.setTradingCode(TRADING_CODE);
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
accountTypeDictionary.setCode(AccountType.Clrn.getKey());
|
||||
accountTypeDictionary.setName(AccountType.Clrn.getKey());
|
||||
accountTypeDictionaryImdg.insert(accountTypeDictionary);
|
||||
|
||||
ClearingAccountTypeDictionary clearingAccountTypeDictionary = new ClearingAccountTypeDictionary();
|
||||
clearingAccountTypeDictionary.setName(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
clearingAccountTypeDictionary.setCode(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
clearingAccountTypeDictionaryImdg.insert(clearingAccountTypeDictionary);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void clearingAccountNew() {
|
||||
ClearingAccountNewRequest clearingAccountNewRequest = new ClearingAccountNewRequest();
|
||||
clearingAccountNewRequest.setAccount(ACCOUNT_VALUE);
|
||||
clearingAccountNewRequest.setCompanyId(companyId);
|
||||
clearingAccountNewRequest.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
|
||||
String jsonString = getJsonStringForNew(clearingAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) clearingAccountService.getConsumer(),
|
||||
Consts.DESTINATION_CLEARING_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
predictableAccount.setAccountType(AccountType.Clrn.getKey());
|
||||
predictableAccount.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
|
||||
ClearingAccount predictableClearingAccount = new ClearingAccount();
|
||||
predictableClearingAccount.setCompanyId(companyId);
|
||||
predictableClearingAccount.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
|
||||
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Clrn.getKey()));
|
||||
ClearingAccount resultClearingAccountNew = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
|
||||
predictableAccount.setId(resultAccountNew.getId());
|
||||
predictableClearingAccount.setAccountId(resultAccountNew.getId());
|
||||
predictableClearingAccount.setId(resultClearingAccountNew.getId());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(resultAccountNew, predictableAccount);
|
||||
CLEARING_ACCOUNT_MATCHER.assertMatch(resultClearingAccountNew, predictableClearingAccount);
|
||||
|
||||
clearingAccountImdg.delete(resultClearingAccountNew);
|
||||
accountImdg.delete(resultAccountNew);
|
||||
}
|
||||
|
||||
@Test
|
||||
void clearingAccountUpdate() {
|
||||
Account existAccount = new Account();
|
||||
existAccount.setAccount(ACCOUNT_VALUE);
|
||||
existAccount.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
existAccount.setAccountType(AccountType.Clrn.getKey());
|
||||
Long accountId = accountImdg.insert(existAccount);
|
||||
|
||||
ClearingAccount existClearingAccount = new ClearingAccount();
|
||||
existClearingAccount.setAccountId(accountId);
|
||||
existClearingAccount.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
existClearingAccount.setCompanyId(companyId);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
predictableAccount.setStatus(AccountStatus.BLOCKED.getKey());
|
||||
predictableAccount.setAccountType(AccountType.Clrn.getKey());
|
||||
|
||||
clearingAccountImdg.insert(existClearingAccount);
|
||||
|
||||
ClearingAccountUpdateRequest clearingAccountUpdateRequest = new ClearingAccountUpdateRequest();
|
||||
clearingAccountUpdateRequest.setAccount(ACCOUNT_VALUE);
|
||||
clearingAccountUpdateRequest.setStatus(0);
|
||||
clearingAccountUpdateRequest.setDeal(TRADING_CODE);
|
||||
|
||||
String jsonString = getJsonStringForUPDATE(clearingAccountUpdateRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) clearingAccountService.getConsumer(), Consts.DESTINATION_CLEARING_ACCOUNT_UPDATE, PARTITION, 0, jsonString);
|
||||
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
||||
|
||||
Account accountResult = accountImdg.getSingleObjectByID(accountId);
|
||||
predictableAccount.setId(accountResult.getId());
|
||||
predictableAccount.setUpdated(accountResult.getUpdated());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
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.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.DepoAccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration;
|
||||
import ru.spcex.clearing.account.config.KafkaConfigTest;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.DepoAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.account.utils.MatcherFactory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.DepoAccountNewRequest;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.account.utils.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
DepoAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountService.class,
|
||||
DepoAccountService.class,
|
||||
HazelcastServiceTestConfiguration.class,
|
||||
KafkaConfigTest.class})
|
||||
class DepoAccountServiceTest {
|
||||
public static final MatcherFactory.Matcher<DepoAccount> CLEARING_ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator("created", "updated");
|
||||
private static final int PARTITION = 0;
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
private static final String DEPO_ACCOUNT_TYPE_DICT = "A";
|
||||
private static final String ACCOUNT_VALUE = "account-value";
|
||||
private static final String TRADING_CODE = "trading-code";
|
||||
|
||||
@Autowired
|
||||
DepoAccountService depoAccountService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
|
||||
private Imdg<DepoAccount> depoAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<DepoAccountTypeDictionary> depoAccountTypeDictionaryImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
depoAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_DepoAccount, DepoAccount.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
depoAccountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_DepoAccountTypeDictionary, DepoAccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
company.setTradingCode(TRADING_CODE);
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
accountTypeDictionary.setCode(AccountType.Depo.getKey());
|
||||
accountTypeDictionary.setName(AccountType.Depo.getKey());
|
||||
accountTypeDictionaryImdg.insert(accountTypeDictionary);
|
||||
|
||||
DepoAccountTypeDictionary depoAccountTypeDictionary = new DepoAccountTypeDictionary();
|
||||
depoAccountTypeDictionary.setName(DEPO_ACCOUNT_TYPE_DICT);
|
||||
depoAccountTypeDictionary.setCode(DEPO_ACCOUNT_TYPE_DICT);
|
||||
depoAccountTypeDictionaryImdg.insert(depoAccountTypeDictionary);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void depoAccountNew() {
|
||||
DepoAccountNewRequest depoAccountNewRequest = new DepoAccountNewRequest();
|
||||
depoAccountNewRequest.setAccount(ACCOUNT_VALUE);
|
||||
depoAccountNewRequest.setCompanyId(companyId);
|
||||
depoAccountNewRequest.setDepoAccountType(DEPO_ACCOUNT_TYPE_DICT);
|
||||
|
||||
String jsonString = getJsonStringForNew(depoAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) depoAccountService.getConsumer(),
|
||||
Consts.DESTINATION_DEPO_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
predictableAccount.setAccountType(AccountType.Depo.getKey());
|
||||
predictableAccount.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
|
||||
DepoAccount predictableDepoAccount = new DepoAccount();
|
||||
predictableDepoAccount.setCompanyId(companyId);
|
||||
predictableDepoAccount.setDepoAccountType(DEPO_ACCOUNT_TYPE_DICT);
|
||||
|
||||
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Depo.getKey()));
|
||||
DepoAccount resultDepoAccountNew = depoAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
|
||||
predictableAccount.setId(resultAccountNew.getId());
|
||||
predictableDepoAccount.setAccountId(resultAccountNew.getId());
|
||||
predictableDepoAccount.setId(resultDepoAccountNew.getId());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(resultAccountNew, predictableAccount);
|
||||
CLEARING_ACCOUNT_MATCHER.assertMatch(resultDepoAccountNew, predictableDepoAccount);
|
||||
|
||||
depoAccountImdg.delete(resultDepoAccountNew);
|
||||
accountImdg.delete(resultAccountNew);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
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.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration;
|
||||
import ru.spcex.clearing.account.config.KafkaConfigTest;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.InformationAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.account.utils.MatcherFactory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.InformationAccountNewRequest;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.account.utils.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
InformationAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountService.class,
|
||||
InformationAccountService.class,
|
||||
HazelcastServiceTestConfiguration.class,
|
||||
KafkaConfigTest.class})
|
||||
class InformationAccountServiceTest {
|
||||
public static final MatcherFactory.Matcher<InformationAccount> INFORMATION_ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator("created", "updated");
|
||||
private static final int PARTITION = 0;
|
||||
private static final String account = "123456789123";
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
private Long anltAccountId;
|
||||
|
||||
@Autowired
|
||||
InformationAccountService informationAccountService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
|
||||
private Imdg<InformationAccount> informationAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
informationAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
accountTypeDictionary.setCode(AccountType.Info.getKey());
|
||||
accountTypeDictionary.setName(AccountType.Info.getKey());
|
||||
accountTypeDictionaryImdg.insert(accountTypeDictionary);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
Account accountAnlt = new Account();
|
||||
accountAnlt.setAccountType(AccountType.Anlt.getKey());
|
||||
accountAnlt.setCompanyId(1L);
|
||||
anltAccountId = accountImdg.insert(accountAnlt);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountInformationNew() {
|
||||
InformationAccountNewRequest InformationAccountNewRequest = new InformationAccountNewRequest();
|
||||
InformationAccountNewRequest.setCompanyId(companyId);
|
||||
|
||||
String jsonString = getJsonStringForNew(InformationAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) informationAccountService.getConsumer(),
|
||||
Consts.DESTINATION_INFORMATION_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingWhenAddedRecordAndCheckIt(0L, producer, producerRecord);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccountType(AccountType.Info.getKey());
|
||||
predictableAccount.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
|
||||
InformationAccount predictableInfoAccount = new InformationAccount();
|
||||
predictableInfoAccount.setCompanyId(companyId);
|
||||
predictableInfoAccount.setClearingAccountId(anltAccountId);
|
||||
|
||||
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Info.getKey()));
|
||||
InformationAccount resultInfoAccountNew = informationAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
|
||||
predictableAccount.setId(resultAccountNew.getId());
|
||||
predictableAccount.setAccount(informationAccountService.generateInfoAccount(resultInfoAccountNew.getId()));
|
||||
predictableInfoAccount.setAccountId(resultAccountNew.getId());
|
||||
predictableInfoAccount.setId(resultInfoAccountNew.getId());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(resultAccountNew, predictableAccount);
|
||||
INFORMATION_ACCOUNT_MATCHER.assertMatch(resultInfoAccountNew, predictableInfoAccount);
|
||||
|
||||
informationAccountImdg.delete(resultInfoAccountNew);
|
||||
accountImdg.delete(resultAccountNew);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ public class AccountController extends AbstractQueueController {
|
|||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody AccountNewAction accountNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_ACCOUNT_NEW, accountNewAction);
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, accountNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update account.")
|
||||
|
|
@ -68,7 +68,7 @@ public class AccountController extends AbstractQueueController {
|
|||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody AccountUpdateAction accountUpdateAction) throws ExecutionException, InterruptedException {
|
||||
accountUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete account.")
|
||||
|
|
@ -79,7 +79,7 @@ public class AccountController extends AbstractQueueController {
|
|||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_ACCOUNT_DELETE, deleteAction);
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class BankAccountController extends AbstractQueueController {
|
|||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_BANK_ACCOUNT_DELETE, deleteAction);
|
||||
return processRequest(Consts.DESTINATION_BANK_ACCOUNT_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get bank account.")
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/accounting/information-account")
|
||||
@RequestMapping("/accounting/information-accounts")
|
||||
public class InformationAccountController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class AccountControllerTest extends AbstractControllerTest {
|
|||
|
||||
//ACT and ASSERT
|
||||
checkAddingByRestApi(REST_URL, accountNewAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_ACCOUNT_NEW, accountNewAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, accountNewAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +69,7 @@ class AccountControllerTest extends AbstractControllerTest {
|
|||
//ACT and ASSERT
|
||||
checkUpdatingWithIdVolidationByRestApi(IMDGDistributedNames.Map_Account, account,
|
||||
REST_URL, accountUpdateAction, id);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,7 +88,7 @@ class AccountControllerTest extends AbstractControllerTest {
|
|||
//ACT and ASSERT
|
||||
checkDeletingWithIdVolidationByRestApi(IMDGDistributedNames.Map_Account, account,
|
||||
REST_URL, id);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_ACCOUNT_DELETE, deleteAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class BankAccountControllerTest extends AbstractControllerTest {
|
|||
deleteAction.setId(id);
|
||||
//ACT and ASSERT
|
||||
checkDeletingByRestApi(REST_URL, id);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_BANK_ACCOUNT_DELETE, deleteAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_BANK_ACCOUNT_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import ru.spcex.clearing.backendapi.controller.queue.account.InformationAccountC
|
|||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
class InformationAccountControllerTest extends AbstractControllerTest {
|
||||
public static final String REST_URL = "/accounting/information-account/";
|
||||
public static final String REST_URL = "/accounting/information-accounts/";
|
||||
|
||||
/**
|
||||
* {@link InformationAccountController#getAll()} <br>
|
||||
* Тест проверяет получение запроса по REST API.<br>
|
||||
* Входной запрос /accounting/information-account/ <br>
|
||||
* Входной запрос /accounting/information-accounts/ <br>
|
||||
* Ответ CommonGetAllResponse <br>
|
||||
*/
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-imdg-api-hazelcast-impl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>classes</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,30 +1,16 @@
|
|||
package ru.spcex.clearing.balance.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.enumeration.SpringPropertiesMessageResolver;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@Configuration
|
||||
public class MessagesConfig {
|
||||
@Bean("validation-error-messages")
|
||||
public ResourceBundleMessageSource messages() {
|
||||
ResourceBundleMessageSource source = new ResourceBundleMessageSource();
|
||||
source.setBasenames("messages/error");
|
||||
source.setUseCodeAsDefaultMessage(true);
|
||||
source.setDefaultEncoding("utf8");
|
||||
source.setDefaultLocale(Locale.ROOT);
|
||||
return source;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IMessageResolver errorResolver(@Qualifier("validation-error-messages") ResourceBundleMessageSource messageBundle) {
|
||||
SpringPropertiesMessageResolver resolver = new SpringPropertiesMessageResolver(messageBundle);
|
||||
resolver.setLocale("ru");
|
||||
return resolver;
|
||||
public IMessageResolver errorResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class StatementService extends QueueConsumer implements InitializingBean
|
|||
exportRequest.setNameOfTable(service.exportTableName());
|
||||
kafkaReqProducer.sendRequestToQueue(Consts.EXPORT_PROCESS, exportRequest);
|
||||
} else {
|
||||
kafkaReqProducer.sendRequestToQueue(Consts.ACCOUNT_NEW, createAccountsRequest(statementRequest.getGroupId(), res.getAccountRequests()));
|
||||
kafkaReqProducer.sendRequestToQueue(Consts.ACCOUNT_NEW_SDF01, createAccountsRequest(statementRequest.getGroupId(), res.getAccountRequests()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
5211=Company not found
|
||||
5213=Currency not found
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
5211=Компания не найдена
|
||||
5213=Валюта не найдена
|
||||
|
|
@ -130,7 +130,7 @@ class StatementServiceServiceTest extends AbstractServiceTest {
|
|||
BaseRequest<Object> baseRequest = (BaseRequest<Object>) producerRecord.getValue().value();
|
||||
RequestInfo resultRequestInfo = requestInfoImdg.getSingleObjectByID(baseRequest.getId());
|
||||
|
||||
assertEquals(Consts.ACCOUNT_NEW, producerRecord.getValue().topic());
|
||||
assertEquals(Consts.ACCOUNT_NEW_SDF01, producerRecord.getValue().topic());
|
||||
assertNotNull(baseRequest);
|
||||
assertNotNull(resultRequestInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@
|
|||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-imdg-api-hazelcast-impl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>classes</artifactId>
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ package ru.spcex.clearing.config;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.enumeration.SimpleMessageResolver;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
@Configuration
|
||||
public class MessageResolverConfig {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver() {
|
||||
return new SimpleMessageResolver();
|
||||
public IMessageResolver messageResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package ru.spcex.clearing.util.services;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.clearing.platform.dictionary.ErrorCodeDictionary;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Использует ErrorCodeDictionary для расшифровки текста кодов ошибок.
|
||||
*/
|
||||
public class IMDGMessageResolver implements IMessageResolver {
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final Imdg<ErrorCodeDictionary> errorCodeDictionaryIMDG;
|
||||
|
||||
public IMDGMessageResolver(ImdgProvider imdgProvider) {
|
||||
this.errorCodeDictionaryIMDG = imdgProvider.getImdg(IMDGDistributedNames.Map_ErrorCodeDictionary, ErrorCodeDictionary.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolve(EnumMessage errorMessage) {
|
||||
if (errorMessage == null) return "null";
|
||||
|
||||
ErrorCodeDictionary errorDictionary = errorCodeDictionaryIMDG.getSingleObjectByID(errorMessage.getSubject().getId());
|
||||
if (errorDictionary == null) {
|
||||
log.warn("ERROR_CODE_DICTIONARY not found fo id={}", errorMessage.getSubject().getId());
|
||||
return String.format("(%d) args %s", errorMessage.getSubject().getId(), Arrays.toString(errorMessage.getArgs()));
|
||||
}
|
||||
String textTemplate = errorDictionary.getName();
|
||||
return String.format(textTemplate, errorMessage.getArgs());
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import java.util.function.Function;
|
|||
|
||||
/**
|
||||
* Проверка поля со значением из множества (enum)
|
||||
* Рекомендуется использовать не эту валидацию, а DictionaryPresentRule
|
||||
* @param <R> Класс проверяемого объекта
|
||||
* @param <E> Enum
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import java.util.function.Function;
|
|||
* @param getter Метод получения значения
|
||||
* @param errorEmptyRequiredValue Ошибка, которая будет возвращена, если поле пустое
|
||||
* @param additionalChecks Дополнительные проверки, связанные с этим полем
|
||||
* @param required Флаг обязательности поля
|
||||
* @param <R> Класс проверяемого объекта
|
||||
* @param <V> Класс проверяемого значения
|
||||
*/
|
||||
|
|
@ -23,9 +24,29 @@ public record FieldRequiredRule<R, V>(
|
|||
String fieldName,
|
||||
Function<R, V> getter,
|
||||
IErrorEnumId errorEmptyRequiredValue,
|
||||
boolean required,
|
||||
Function<V, IErrorEnumId>[] additionalChecks
|
||||
) implements IValidationRule<ImdgValidationContext<R>> {
|
||||
|
||||
/**
|
||||
* @param fieldName Название поля
|
||||
* @param getter Метод получения значения
|
||||
* @param errorEmptyRequiredValue Ошибка, которая будет возвращена, если поле пустое
|
||||
* @param additionalChecks Дополнительные проверки, связанные с этим полем
|
||||
* @param required Флаг обязательности поля
|
||||
* @param <R> Класс проверяемого объекта
|
||||
* @param <V> Класс проверяемого значения
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <R, V> FieldRequiredRule<R, V> instance(String fieldName,
|
||||
Function<R, V> getter,
|
||||
IErrorEnumId errorEmptyRequiredValue,
|
||||
boolean required,
|
||||
Function<V, IErrorEnumId>... additionalChecks) {
|
||||
if (errorEmptyRequiredValue == null) throw new IllegalArgumentException("Empty errorEmptyRequiredValue");
|
||||
return new FieldRequiredRule<>(fieldName, getter, errorEmptyRequiredValue, required, additionalChecks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fieldName Название поля
|
||||
* @param getter Метод получения значения
|
||||
|
|
@ -40,18 +61,17 @@ public record FieldRequiredRule<R, V>(
|
|||
IErrorEnumId errorEmptyRequiredValue,
|
||||
Function<V, IErrorEnumId>... additionalChecks) {
|
||||
if (errorEmptyRequiredValue == null) throw new IllegalArgumentException("Empty errorEmptyRequiredValue");
|
||||
return new FieldRequiredRule<>(fieldName, getter, errorEmptyRequiredValue, additionalChecks);
|
||||
return new FieldRequiredRule<>(fieldName, getter, errorEmptyRequiredValue, true, additionalChecks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<R> context) {
|
||||
R validatedObject = context.getValidatedObject();
|
||||
V value = getter.apply(validatedObject);
|
||||
if (value == null) return of(errorEmptyRequiredValue, fieldName);
|
||||
if (required && value == null) return of(errorEmptyRequiredValue, fieldName);
|
||||
for (Function<V, IErrorEnumId> additionalCheck : additionalChecks) {
|
||||
IErrorEnumId validationError = additionalCheck.apply(value);
|
||||
if (validationError != null)
|
||||
return of(validationError, fieldName);
|
||||
if (validationError != null) return of(validationError, fieldName);
|
||||
}
|
||||
return empty();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ import ru.spcex.clearing.util.security.UserRoleVerification;
|
|||
import ru.spcex.platform.enumeration.UserRole;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.enumeration.SimpleMessageResolver;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
|
||||
@Configuration
|
||||
public class BeanConfiguration {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver() {
|
||||
return new SimpleMessageResolver();
|
||||
public IMessageResolver messageResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -81,12 +81,6 @@ public class ClearingMemberCategoryValidationConfig {
|
|||
return CompanyErrors.CompanyDisabled;
|
||||
return null;
|
||||
}),
|
||||
EnumPresentRule.instance("clearingMemberCategory",
|
||||
ClearingMemberCategoryUpdateRequest::getClearingMemberCategory,
|
||||
ClearingCategory.values(),
|
||||
false,
|
||||
CompanyErrors.WrongFieldValue,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("clearingMemberCategory",
|
||||
ClearingMemberCategoryUpdateRequest::getClearingMemberCategory,
|
||||
IMDGDistributedNames.Map_ClearingCategoryDictionary,
|
||||
|
|
|
|||
|
|
@ -49,11 +49,6 @@ public class CompanyValidationConfig {
|
|||
WorkflowStatusDictionary.class,
|
||||
CompanyErrors.RequiredFieldEmpty,
|
||||
CompanyErrors.WrongFieldValue),
|
||||
EnumPresentRule.instance("companySymbol",
|
||||
CompanyNewRequest::getCompanySymbol,
|
||||
CompanySymbol.values(),
|
||||
CompanyErrors.WrongFieldValue,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("companySymbol",
|
||||
CompanyNewRequest::getCompanySymbol,
|
||||
IMDGDistributedNames.Map_CompanySymbolDictionary,
|
||||
|
|
|
|||
|
|
@ -44,11 +44,6 @@ public class ContactValidationConfig {
|
|||
Company.class,
|
||||
CompanyErrors.RequiredFieldEmpty,
|
||||
CompanyErrors.CompanyNotFound),
|
||||
EnumPresentRule.instance("contactType",
|
||||
ContactNewRequest::getContactType,
|
||||
ContactTypes.values(),
|
||||
CompanyErrors.WrongFieldValue,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("contactType",
|
||||
ContactNewRequest::getContactType,
|
||||
IMDGDistributedNames.Map_ContactTypeDictionary,
|
||||
|
|
@ -86,12 +81,6 @@ public class ContactValidationConfig {
|
|||
}
|
||||
return null;
|
||||
}),
|
||||
EnumPresentRule.instance("contactType",
|
||||
ContactUpdateRequest::getContactType,
|
||||
ContactTypes.values(),
|
||||
false,
|
||||
CompanyErrors.WrongFieldValue,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("contactType",
|
||||
ContactUpdateRequest::getContactType,
|
||||
IMDGDistributedNames.Map_ContactTypeDictionary,
|
||||
|
|
|
|||
|
|
@ -45,11 +45,6 @@ public class ProfileDocumentValidationConfig {
|
|||
CompanyErrors.RequiredFieldEmpty,
|
||||
CompanyErrors.CompanyNotFound,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : CompanyErrors.CompanyDisabled),
|
||||
EnumPresentRule.instance("documentType",
|
||||
ProfileDocumentNewRequest::getDocumentType,
|
||||
DocumentTypes.values(),
|
||||
CompanyErrors.WrongFieldValue,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("documentType",
|
||||
ProfileDocumentNewRequest::getDocumentType,
|
||||
IMDGDistributedNames.Map_DocumentTypeDictionary,
|
||||
|
|
@ -109,12 +104,6 @@ public class ProfileDocumentValidationConfig {
|
|||
CompanyErrors.CompanyNotFound,
|
||||
false,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : CompanyErrors.CompanyDisabled),
|
||||
EnumPresentRule.instance("documentType",
|
||||
ProfileDocumentUpdateRequest::getDocumentType,
|
||||
DocumentTypes.values(),
|
||||
false,
|
||||
CompanyErrors.WrongFieldValue,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("documentType",
|
||||
ProfileDocumentUpdateRequest::getDocumentType,
|
||||
IMDGDistributedNames.Map_DocumentTypeDictionary,
|
||||
|
|
|
|||
|
|
@ -24,9 +24,8 @@ public class DbConnectionConfig {
|
|||
this.settings = settings.getDatabase();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource result;
|
||||
@Bean(destroyMethod = "close")
|
||||
public ComboPooledDataSource dataSource() {
|
||||
String login = settings.getLogin();
|
||||
String password = settings.getPassword();
|
||||
String logTimeoutPart = "";
|
||||
|
|
@ -49,14 +48,13 @@ public class DbConnectionConfig {
|
|||
cpds.setNumHelperThreads(numHelperThreads);
|
||||
cpds.setCheckoutTimeout(timeoutSec * 1000);
|
||||
logTimeoutPart = String.format(" (timeout=%ds)", timeoutSec);
|
||||
result = cpds;
|
||||
|
||||
String OPERATION_DATABASE_CONNECTION_CHECK = String.format("Database [%s] connection check", dbPath);
|
||||
try {
|
||||
Connection conn = result.getConnection();
|
||||
Connection conn = cpds.getConnection();
|
||||
conn.close();
|
||||
log.info("{}: success", OPERATION_DATABASE_CONNECTION_CHECK);
|
||||
return result;
|
||||
return cpds;
|
||||
} catch (Throwable e) {
|
||||
String msg = String.format("%s%s: failed: %s -> %s",
|
||||
OPERATION_DATABASE_CONNECTION_CHECK, logTimeoutPart, e.getClass().getSimpleName(), e.getMessage());
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ public class STradesMapStore extends TemplateMapStore<STrades> {
|
|||
return IMDGDistributedNames.Map_STrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getIndexingField() {
|
||||
return new String[]{"tradeNum"};// список индексируемых полей
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return "S_TRADES";
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import ru.clearing.platform.dictionary.CompanySymbolDictionary;
|
|||
import ru.spcex.clearing.imdg.base.*;
|
||||
import ru.spcex.clearing.imdg.config.DbTestConnectionConfig;
|
||||
import ru.spcex.clearing.imdg.config.TestConfiguration;
|
||||
import ru.spcex.clearing.imdg.structure.BusinessObjectAndBusinessEventForCheckMapStore;
|
||||
import ru.spcex.clearing.imdg.structure.DictionaryObjectForCheckMapStore;
|
||||
import ru.spcex.clearing.imdg.structure.CheckerBusinessMapStore;
|
||||
import ru.spcex.clearing.imdg.structure.CheckerDictionaryMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.BusinessEventRowMapper;
|
||||
import ru.spcex.clearing.imdg.utils.DbDataUtils;
|
||||
import ru.spcex.clearing.imdg.utils.SpcexObjectBaseRowMapper;
|
||||
|
|
@ -43,8 +43,8 @@ import java.sql.*;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ru.spcex.clearing.imdg.structure.RunnableMapNamesForTesting.businessObjectAndBusinessEventForCheckMapStores;
|
||||
import static ru.spcex.clearing.imdg.structure.RunnableMapNamesForTesting.dictionaryObjectForCheckMapStores;
|
||||
import static ru.spcex.clearing.imdg.structure.RunnableMapNamesForTesting.checkerBusinessMapStores;
|
||||
import static ru.spcex.clearing.imdg.structure.RunnableMapNamesForTesting.checkerDictionaryMapStores;
|
||||
import static ru.spcex.clearing.imdg.utils.DbDataUtils.generatingRandomString;
|
||||
|
||||
@ContextConfiguration(classes = {
|
||||
|
|
@ -77,7 +77,7 @@ public class AllMapStoreTest {
|
|||
@PostConstruct
|
||||
public void initTestObjects() {
|
||||
try {
|
||||
for (BusinessObjectAndBusinessEventForCheckMapStore<SpcexObjectBase> objectForCheck : businessObjectAndBusinessEventForCheckMapStores) {
|
||||
for (CheckerBusinessMapStore<SpcexObjectBase> objectForCheck : checkerBusinessMapStores) {
|
||||
SpcexObjectBase object = objectForCheck.getClazz().getDeclaredConstructor().newInstance();
|
||||
DbDataUtils.fillObjectDefaultValues(object, object.getClass());
|
||||
if (objectForCheck.getClazz().equals(CompanyHistory.class)) {
|
||||
|
|
@ -112,7 +112,7 @@ public class AllMapStoreTest {
|
|||
objectForCheck.setPredictableObj(object);
|
||||
}
|
||||
}
|
||||
for (DictionaryObjectForCheckMapStore<AbstractDictionary> objectForCheck : dictionaryObjectForCheckMapStores) {
|
||||
for (CheckerDictionaryMapStore<AbstractDictionary> objectForCheck : checkerDictionaryMapStores) {
|
||||
AbstractDictionary object = objectForCheck.getClazz().getDeclaredConstructor().newInstance();
|
||||
DbDataUtils.fillObjectDefaultValues(object, object.getClass());
|
||||
objectForCheck.setPredictableObj(object);
|
||||
|
|
@ -178,7 +178,7 @@ public class AllMapStoreTest {
|
|||
testConfig.shutDownHazelcast();
|
||||
testConfig.reinitHazlecastInstance();
|
||||
|
||||
for (BusinessObjectAndBusinessEventForCheckMapStore objectForCheck : businessObjectAndBusinessEventForCheckMapStores) {
|
||||
for (CheckerBusinessMapStore objectForCheck : checkerBusinessMapStores) {
|
||||
String mapName = objectForCheck.getMapName();
|
||||
SpcexObjectBase actual;
|
||||
if (getMapStore(mapName) instanceof TemplateEventMapStore) {
|
||||
|
|
@ -200,7 +200,7 @@ public class AllMapStoreTest {
|
|||
}
|
||||
objectForCheck.getMATCHER().assertMatch(actual, objectForCheck.getPredictableObj());
|
||||
}
|
||||
for (DictionaryObjectForCheckMapStore objectForCheck : dictionaryObjectForCheckMapStores) {
|
||||
for (CheckerDictionaryMapStore objectForCheck : checkerDictionaryMapStores) {
|
||||
String mapName = objectForCheck.getMapName();
|
||||
AbstractDictionary actual;
|
||||
IMap<Long, AbstractDictionary> map = testConfig.getHazelcastInstance().getMap(mapName);
|
||||
|
|
@ -215,7 +215,7 @@ public class AllMapStoreTest {
|
|||
Assumptions.assumeTrue(false, "todo удалить если будет не нужна, пока не работает из-за \"deleteIsSupported() return false\" в SimpleObjectMapStore.");
|
||||
saveBusinessObjectAndBusinessEventToMaps();
|
||||
|
||||
for (BusinessObjectAndBusinessEventForCheckMapStore objectForCheck : businessObjectAndBusinessEventForCheckMapStores) {
|
||||
for (CheckerBusinessMapStore objectForCheck : checkerBusinessMapStores) {
|
||||
IMap<Long, SpcexObjectBase> map = testConfig.getHazelcastInstance().getMap(objectForCheck.getMapName());
|
||||
map.remove(ID);
|
||||
String sql = String.format("SELECT * FROM %s WHERE id = %d", getTableNameFromMapStore(objectForCheck.getMapName()), ID);
|
||||
|
|
@ -250,7 +250,7 @@ public class AllMapStoreTest {
|
|||
}
|
||||
|
||||
private void saveBusinessObjectAndBusinessEventToMaps() {
|
||||
for (BusinessObjectAndBusinessEventForCheckMapStore objectForCheck : businessObjectAndBusinessEventForCheckMapStores) {
|
||||
for (CheckerBusinessMapStore objectForCheck : checkerBusinessMapStores) {
|
||||
String mapName = objectForCheck.getMapName();
|
||||
SpcexObjectBase spcexObjectBase = objectForCheck.getPredictableObj();
|
||||
spcexObjectBase.setId(ID);
|
||||
|
|
@ -261,7 +261,7 @@ public class AllMapStoreTest {
|
|||
}
|
||||
|
||||
private void saveDictionaryObjectToMaps() {
|
||||
for (DictionaryObjectForCheckMapStore objectForCheck : dictionaryObjectForCheckMapStores) {
|
||||
for (CheckerDictionaryMapStore objectForCheck : checkerDictionaryMapStores) {
|
||||
String mapName = objectForCheck.getMapName();
|
||||
AbstractDictionary dictionaryObj = objectForCheck.getPredictableObj();
|
||||
dictionaryObj.setId(ID);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import java.lang.reflect.Method;
|
|||
|
||||
import static ru.spcex.clearing.imdg.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
|
||||
public class BusinessObjectAndBusinessEventForCheckMapStore<T> {
|
||||
|
||||
public class CheckerBusinessMapStore<T> {
|
||||
|
||||
public final Matcher<T> MATCHER;
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
|
@ -21,20 +22,20 @@ public class BusinessObjectAndBusinessEventForCheckMapStore<T> {
|
|||
|
||||
private SpcexObjectBase predictableObj;
|
||||
|
||||
public BusinessObjectAndBusinessEventForCheckMapStore(String mapName, Class<T> clazz) {
|
||||
public CheckerBusinessMapStore(String mapName, Class<T> clazz) {
|
||||
this.mapName = mapName;
|
||||
this.clazz = clazz;
|
||||
this.MATCHER = usingIgnoringFieldsComparator();
|
||||
}
|
||||
|
||||
public BusinessObjectAndBusinessEventForCheckMapStore(String mapName, Class<T> clazz, SettingOperation... settingOperations) {
|
||||
public CheckerBusinessMapStore(String mapName, Class<T> clazz, SettingOperation... settingOperations) {
|
||||
this.mapName = mapName;
|
||||
this.clazz = clazz;
|
||||
this.settingOperations = settingOperations;
|
||||
this.MATCHER = usingIgnoringFieldsComparator();
|
||||
}
|
||||
|
||||
public BusinessObjectAndBusinessEventForCheckMapStore(String mapName, Class<T> clazz, Matcher<T> MATCHER) {
|
||||
public CheckerBusinessMapStore(String mapName, Class<T> clazz, Matcher<T> MATCHER) {
|
||||
this.mapName = mapName;
|
||||
this.clazz = clazz;
|
||||
this.MATCHER = MATCHER;
|
||||
|
|
@ -8,7 +8,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
|
||||
import static ru.spcex.clearing.imdg.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
|
||||
public class DictionaryObjectForCheckMapStore<T> {
|
||||
public class CheckerDictionaryMapStore<T> {
|
||||
|
||||
public final Matcher<T> MATCHER = usingIgnoringFieldsComparator();
|
||||
private final String mapName;
|
||||
|
|
@ -16,7 +16,7 @@ public class DictionaryObjectForCheckMapStore<T> {
|
|||
|
||||
private AbstractDictionary predictableObj;
|
||||
|
||||
public DictionaryObjectForCheckMapStore(String mapName, Class<T> clazz) {
|
||||
public CheckerDictionaryMapStore(String mapName, Class<T> clazz) {
|
||||
this.mapName = mapName;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ import ru.clearing.classes.statics.data.statement.Statement;
|
|||
import ru.clearing.classes.statics.data.user.*;
|
||||
import ru.clearing.platform.dictionary.*;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.structure.BusinessObjectAndBusinessEventForCheckMapStore.SettingOperation;
|
||||
import ru.spcex.clearing.imdg.structure.CheckerBusinessMapStore.SettingOperation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
|
|
@ -40,24 +40,24 @@ import static ru.spcex.clearing.imdg.utils.DbDataUtils.generatingRandomInstant;
|
|||
import static ru.spcex.clearing.imdg.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
|
||||
public class RunnableMapNamesForTesting {
|
||||
public static List<BusinessObjectAndBusinessEventForCheckMapStore> businessObjectAndBusinessEventForCheckMapStores;
|
||||
public static List<DictionaryObjectForCheckMapStore> dictionaryObjectForCheckMapStores;
|
||||
public static List<CheckerBusinessMapStore> checkerBusinessMapStores;
|
||||
public static List<CheckerDictionaryMapStore> checkerDictionaryMapStores;
|
||||
|
||||
static {
|
||||
init();
|
||||
}
|
||||
|
||||
private static void init() {
|
||||
businessObjectAndBusinessEventForCheckMapStores = new LinkedList<>();
|
||||
dictionaryObjectForCheckMapStores = new LinkedList<>();
|
||||
checkerBusinessMapStores = new LinkedList<>();
|
||||
checkerDictionaryMapStores = new LinkedList<>();
|
||||
|
||||
//business event
|
||||
// businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_AccountBalanceHistory, AccountBalanceHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_AccountHistory, AccountHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_BankAccountHistory, BankAccountHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_CompanyHistory, CompanyHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_AccountHistory, AccountHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_BankAccountHistory, BankAccountHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_CompanyHistory, CompanyHistory.class,
|
||||
usingIgnoringFieldsComparator("object.profile.clearingCode", "object.profile.fullName", "object.profile.registrationCode", "object.profile.shortName", "object.profile.tradingCode")));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ExecutionDepositHistory, ExecutionDepositHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ExecutionDepositHistory, ExecutionDepositHistory.class,
|
||||
usingIgnoringFieldsComparator(
|
||||
"object.firstLegAmount",
|
||||
"object.interestAmount",
|
||||
|
|
@ -70,7 +70,7 @@ public class RunnableMapNamesForTesting {
|
|||
new SettingOperation("object.quantity", new Object[]{new BigDecimal("853.640000000000000000")}),
|
||||
new SettingOperation("object.secondLegAmount", new Object[]{new BigDecimal("854.640000000000000000")})*/
|
||||
));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ExecutionFondHistory, ExecutionFondHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ExecutionFondHistory, ExecutionFondHistory.class,
|
||||
usingIgnoringFieldsComparator(
|
||||
"object.interestAmount",
|
||||
"object.lots",
|
||||
|
|
@ -80,22 +80,22 @@ public class RunnableMapNamesForTesting {
|
|||
new SettingOperation("object.lots", new Object[]{new BigDecimal("851.640000000000000000")}),
|
||||
new SettingOperation("object.quantity", new Object[]{new BigDecimal("852.640000000000000000")}),
|
||||
new SettingOperation("object.settlementAmount", new Object[]{new BigDecimal("853.640000000000000000")})*/));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_InformationAccountHistory, InformationAccountHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_RelationHistory, RelationHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SessionHistory, SessionHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_InformationAccountHistory, InformationAccountHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_RelationHistory, RelationHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SessionHistory, SessionHistory.class));
|
||||
// businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SecurityHistory, SecurityHistory.class)); // parent table
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UserConnectHistory, UserConnectHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UserHistory, UserHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_CurrencyHistory, CurrencyHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ListingHistory, ListingHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_UserConnectHistory, UserConnectHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_UserHistory, UserHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_CurrencyHistory, CurrencyHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ListingHistory, ListingHistory.class,
|
||||
usingIgnoringFieldsComparator(
|
||||
"object.lotSize")
|
||||
/*new SettingOperation("object.lotSize", new Object[]{new BigDecimal("850.640000000000000000")}),*/));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_MarketHistory, MarketHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_CompanySymbolsHistory, CompanySymbolsHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ProfileDocumentHistory, ProfileDocumentHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ClearingMemberCategoryHistory, ClearingMemberCategoryHistory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_MoneyMarketSecurityHistory, MoneyMarketSecurityHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_MarketHistory, MarketHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_CompanySymbolsHistory, CompanySymbolsHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ProfileDocumentHistory, ProfileDocumentHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ClearingMemberCategoryHistory, ClearingMemberCategoryHistory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_MoneyMarketSecurityHistory, MoneyMarketSecurityHistory.class,
|
||||
usingIgnoringFieldsComparator( // todo поправить тест для ASecurityHistoryMapStore
|
||||
"object.created", "object.updated",
|
||||
"object.fullName", "object.fullNameEng",
|
||||
|
|
@ -106,7 +106,7 @@ public class RunnableMapNamesForTesting {
|
|||
"object.shortName", "object.shortNameEng",
|
||||
"object.uuid", "object.workflowStatus"
|
||||
)));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_EquitySecurityHistory, EquitySecurityHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_EquitySecurityHistory, EquitySecurityHistory.class,
|
||||
usingIgnoringFieldsComparator( // todo поправить тест для ASecurityHistoryMapStore
|
||||
"object.created", "object.updated",
|
||||
"object.fullName", "object.fullNameEng",
|
||||
|
|
@ -117,7 +117,7 @@ public class RunnableMapNamesForTesting {
|
|||
"object.shortName", "object.shortNameEng",
|
||||
"object.uuid", "object.workflowStatus"
|
||||
)));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_FixedIncomeSecurityHistory, FixedIncomeSecurityHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_FixedIncomeSecurityHistory, FixedIncomeSecurityHistory.class,
|
||||
usingIgnoringFieldsComparator( // todo поправить тест для ASecurityHistoryMapStore
|
||||
"object.created", "object.updated",
|
||||
"object.fullName", "object.fullNameEng",
|
||||
|
|
@ -128,43 +128,43 @@ public class RunnableMapNamesForTesting {
|
|||
"object.shortName", "object.shortNameEng",
|
||||
"object.uuid", "object.workflowStatus"
|
||||
)));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_FixedIncomeCashFlowHistory, FixedIncomeCashFlowHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_FixedIncomeCashFlowHistory, FixedIncomeCashFlowHistory.class,
|
||||
usingIgnoringFieldsComparator("object.accruedCoupon")
|
||||
/* new SettingOperation("getObject.setAccruedCoupon", new Object[]{new BigDecimal("870.680000000000000000")})*/));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_CouponPeriodHistory, CouponPeriodHistory.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_CouponPeriodHistory, CouponPeriodHistory.class,
|
||||
usingIgnoringFieldsComparator("object.couponRate")
|
||||
/* new SettingOperation("getObject.setCouponRate", new Object[]{new BigDecimal("870.680000000000000000")})*/));
|
||||
|
||||
//business object
|
||||
// businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_AccountBalance, AccountBalance.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Account, Account.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ClearingCalendar, ClearingCalendar.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Company, Company.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Account, Account.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ClearingCalendar, ClearingCalendar.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Company, Company.class,
|
||||
usingIgnoringFieldsComparator("profile.clearingCode", "profile.fullName", "profile.registrationCode", "profile.shortName", "profile.tradingCode")));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ErrorText, ErrorText.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ExecutionFond, ExecutionFond.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ErrorText, ErrorText.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ExecutionFond, ExecutionFond.class,
|
||||
new SettingOperation("setInterestAmount", new Object[]{new BigDecimal("850.64")}),
|
||||
new SettingOperation("setLots", new Object[]{new BigDecimal("851.64")}),
|
||||
new SettingOperation("setQuantity", new Object[]{new BigDecimal("852.64")}),
|
||||
new SettingOperation("setSettlementAmount", new Object[]{new BigDecimal("853.64")})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Launcher, Launcher.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_LiabilitiesClaimsAssets, LiabilitiesClaimsAssets.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_LiabilitiesClaimsMoney, LiabilitiesClaimsMoney.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Launcher, Launcher.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_LiabilitiesClaimsAssets, LiabilitiesClaimsAssets.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_LiabilitiesClaimsMoney, LiabilitiesClaimsMoney.class,
|
||||
new SettingOperation("setClaimsAmount", new Class[]{BigDecimal.class}, new Object[]{new BigDecimal("04.92")}),
|
||||
new SettingOperation("setLiabilitiesAmount", new Class[]{BigDecimal.class}, new Object[]{new BigDecimal("06.26")})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Listing, Listing.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Listing, Listing.class,
|
||||
new SettingOperation("setLotSize", new Class[]{BigDecimal.class}, new Object[]{new BigDecimal("21.11")})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ManagementJournal, ManagementJournal.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Market, Market.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Planner, Planner.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_PlannerTemplate, PlannerTemplate.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Relation, Relation.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ManagementJournal, ManagementJournal.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Market, Market.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Planner, Planner.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_PlannerTemplate, PlannerTemplate.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Relation, Relation.class));
|
||||
// businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Security, Security.class)); // класс наследуется
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Statement, Statement.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Statement, Statement.class,
|
||||
new SettingOperation("setAmount", new Class[]{BigDecimal.class}, new Object[]{new BigDecimal("23.22")})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UserConnect, UserConnect.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_User, User.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_EquitySecurity, EquitySecurity.class
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_UserConnect, UserConnect.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_User, User.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_EquitySecurity, EquitySecurity.class
|
||||
, usingIgnoringFieldsComparator( // todo поправить тест для ASecurityMapStore - проблема в заполнении securityId
|
||||
"created", "updated",
|
||||
"fullName", "fullNameEng",
|
||||
|
|
@ -176,7 +176,7 @@ public class RunnableMapNamesForTesting {
|
|||
"uuid", "workflowStatus"
|
||||
)
|
||||
));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_FixedIncomeSecurity, FixedIncomeSecurity.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_FixedIncomeSecurity, FixedIncomeSecurity.class,
|
||||
usingIgnoringFieldsComparator( // todo поправить тест для ASecurityMapStore
|
||||
"created", "updated",
|
||||
"fullName", "fullNameEng",
|
||||
|
|
@ -189,88 +189,88 @@ public class RunnableMapNamesForTesting {
|
|||
)));
|
||||
|
||||
//dictionary
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_AllowedDictionary, AllowedDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_BalanceAccountTypeDictionary, BalanceAccountTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ChargeDirectionDictionary, ChargeDirectionDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ClearingCategoryDictionary, ClearingCategoryDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ClearingStatusDictionary, ClearingStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CompanyRoleDictionary, CompanyRoleDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CompanySymbolDictionary, CompanySymbolDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ConnectionStateDictionary, ConnectionStateDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ContactTypeDictionary, ContactTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CorporationSoleTypeDictionary, CorporationSoleTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CountryCodeDictionary, CountryCodeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CourierTypeDictionary, CourierTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_DayStatusDictionary, DayStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_DocumentTypeDictionary, DocumentTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ErrorCodeDictionary, ErrorCodeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_InOutDirectionDictionary, InOutDirectionDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_InstrumentTypeDictionary, InstrumentTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_LegalKindDictionary, LegalKindDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ManagementJournalPurposeDictionary, ManagementJournalPurposeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ManagementJournalStatusDictionary, ManagementJournalStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ManagementJournalTypeDictionary, ManagementJournalTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_MoneyFlowSideDictionary, MoneyFlowSideDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_MarketCodeDictionary, MarketCodeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_OperationStatusDictionary, OperationStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_OperationTypeDictionary, OperationTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_OrganizationTypeDictionary, OrganizationTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ParentDictionary, ParentDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ResultStatusDictionary, ResultStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_SessionStatusDictionary, SessionStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_SessionTypeDictionary, SessionTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ServiceDictionary, ServiceDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ServiceProductDictionary, ServiceProductDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ServiceStatusDictionary, ServiceStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_StatementTypeDictionary, StatementTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_SideDictionary, SideDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_TaskDictionary, TaskDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_TaskStatusDictionary, TaskStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_TermTypeDictionary, TermTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_UserRoleDictionary, UserRoleDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_WorkflowStatusDictionary, WorkflowStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_SectionDictionary, SectionDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ShareTypeDictionary, ShareTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_BondTypeDictionary, BondTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_TradingClearingRegistryTypeDictionary, TradingClearingRegistryTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_TradingClearingRegistryLevelDictionary, TradingClearingRegistryLevelDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_TradingClearingRegistryPurposeDictionary, TradingClearingRegistryPurposeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_RegistryDesignationDictionary, RegistryDesignationDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_RegistryInstrumentTypeDictionary, RegistryInstrumentTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_RegistryCapacityDictionary, RegistryCapacityDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_RegistryUnitDictionary, RegistryUnitDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_RegistryCodeDictionary, RegistryCodeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_RegistryStatusDictionary, RegistryStatusDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_BalanceDimensionDictionary, BalanceDimensionDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_DepoAccountTypeDictionary, DepoAccountTypeDictionary.class));
|
||||
dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ClearingAccountTypeDictionary, ClearingAccountTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_AllowedDictionary, AllowedDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_BalanceAccountTypeDictionary, BalanceAccountTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ChargeDirectionDictionary, ChargeDirectionDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ClearingCategoryDictionary, ClearingCategoryDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ClearingStatusDictionary, ClearingStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_CompanyRoleDictionary, CompanyRoleDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_CompanySymbolDictionary, CompanySymbolDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ConnectionStateDictionary, ConnectionStateDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ContactTypeDictionary, ContactTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_CorporationSoleTypeDictionary, CorporationSoleTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_CountryCodeDictionary, CountryCodeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_CourierTypeDictionary, CourierTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_DayStatusDictionary, DayStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_DocumentTypeDictionary, DocumentTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ErrorCodeDictionary, ErrorCodeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_InOutDirectionDictionary, InOutDirectionDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_InstrumentTypeDictionary, InstrumentTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_LegalKindDictionary, LegalKindDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ManagementJournalPurposeDictionary, ManagementJournalPurposeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ManagementJournalStatusDictionary, ManagementJournalStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ManagementJournalTypeDictionary, ManagementJournalTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_MoneyFlowSideDictionary, MoneyFlowSideDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_MarketCodeDictionary, MarketCodeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_OperationStatusDictionary, OperationStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_OperationTypeDictionary, OperationTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_OrganizationTypeDictionary, OrganizationTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ParentDictionary, ParentDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ResultStatusDictionary, ResultStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_SessionStatusDictionary, SessionStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_SessionTypeDictionary, SessionTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ServiceDictionary, ServiceDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ServiceProductDictionary, ServiceProductDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ServiceStatusDictionary, ServiceStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_StatementTypeDictionary, StatementTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_SideDictionary, SideDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_TaskDictionary, TaskDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_TaskStatusDictionary, TaskStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_TermTypeDictionary, TermTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_UserRoleDictionary, UserRoleDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_WorkflowStatusDictionary, WorkflowStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_SectionDictionary, SectionDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ShareTypeDictionary, ShareTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_BondTypeDictionary, BondTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_TradingClearingRegistryTypeDictionary, TradingClearingRegistryTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_TradingClearingRegistryLevelDictionary, TradingClearingRegistryLevelDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_TradingClearingRegistryPurposeDictionary, TradingClearingRegistryPurposeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_RegistryDesignationDictionary, RegistryDesignationDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_RegistryInstrumentTypeDictionary, RegistryInstrumentTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_RegistryCapacityDictionary, RegistryCapacityDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_RegistryUnitDictionary, RegistryUnitDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_RegistryCodeDictionary, RegistryCodeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_RegistryStatusDictionary, RegistryStatusDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_BalanceDimensionDictionary, BalanceDimensionDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_DepoAccountTypeDictionary, DepoAccountTypeDictionary.class));
|
||||
checkerDictionaryMapStores.add(new CheckerDictionaryMapStore<>(IMDGDistributedNames.Map_ClearingAccountTypeDictionary, ClearingAccountTypeDictionary.class));
|
||||
|
||||
//object
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_AdmittedDealRegister, AdmittedDealRegister.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_AdmittedDealRegister, AdmittedDealRegister.class,
|
||||
new SettingOperation("setCreated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setUpdated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setAmount", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_BankAccount, BankAccount.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ClearMemberRegister, ClearMemberRegister.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_CompanyRoleSet, CompanyRoleSet.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Contact, Contact.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ContractRegister, ContractRegister.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_BankAccount, BankAccount.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ClearMemberRegister, ClearMemberRegister.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_CompanyRoleSet, CompanyRoleSet.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Contact, Contact.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ContractRegister, ContractRegister.class,
|
||||
new SettingOperation("setCreated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setUpdated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_CoveredDealRegister, CoveredDealRegister.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_CoveredDealRegister, CoveredDealRegister.class,
|
||||
new SettingOperation("setCreated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setUpdated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setAmount", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Currency, Currency.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_DealRegister, DealRegister.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Currency, Currency.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_DealRegister, DealRegister.class,
|
||||
new SettingOperation("setCreated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setUpdated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setAmount", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ExecutionDeposit, ExecutionDeposit.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ExecutionDeposit, ExecutionDeposit.class,
|
||||
new SettingOperation("setCreated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setUpdated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setFirstLegAmount", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)}),
|
||||
|
|
@ -278,11 +278,11 @@ public class RunnableMapNamesForTesting {
|
|||
new SettingOperation("setInterestAmount", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)}),
|
||||
new SettingOperation("setLots", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)}),
|
||||
new SettingOperation("setQuantity", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_InDocumentJournal, InDocumentJournal.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_InDocumentJournal, InDocumentJournal.class,
|
||||
new SettingOperation("setAmount", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_KeyRate, KeyRate.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_MoneyMarketSecurity, MoneyMarketSecurity.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_KeyRate, KeyRate.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_MoneyMarketSecurity, MoneyMarketSecurity.class,
|
||||
usingIgnoringFieldsComparator( // todo поправить тест для ASecurityHistoryMapStore
|
||||
"created", "updated",
|
||||
"fullName", "fullNameEng",
|
||||
|
|
@ -297,58 +297,58 @@ public class RunnableMapNamesForTesting {
|
|||
)//,
|
||||
//new SettingOperation("setNominalValue", new Class[]{BigDecimal.class}, new Object[]{new BigDecimal("25.25")})
|
||||
));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Notification, Notification.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_OrderRegister, OrderRegister.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_OutDocumentJournal, OutDocumentJournal.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Notification, Notification.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_OrderRegister, OrderRegister.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_OutDocumentJournal, OutDocumentJournal.class,
|
||||
new SettingOperation("setAmount", new Class[]{BigDecimal.class}, new Object[]{new BigDecimal("28.28")})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_PaymentInstruction, PaymentInstruction.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_PlannerAllToday, PlannerAllToday.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ProfileDocument, ProfileDocument.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ReportRegister, ReportRegister.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_PaymentInstruction, PaymentInstruction.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_PlannerAllToday, PlannerAllToday.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ProfileDocument, ProfileDocument.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_ReportRegister, ReportRegister.class,
|
||||
new SettingOperation("setCreated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setUpdated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf01, SDf01.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf02, SDf02.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf03, SDf03.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf04, SDf04.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf05, SDf05.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf08, SDf08.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf09, SDf09.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf10, SDf10.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf11, SDf11.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf12, SDf12.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf13, SDf13.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf16, SDf16.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf17, SDf17.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf18, SDf18.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Session, Session.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_STrades, STrades.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf01, SDf01.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf02, SDf02.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf03, SDf03.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf04, SDf04.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf05, SDf05.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf08, SDf08.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf09, SDf09.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf10, SDf10.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf11, SDf11.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf12, SDf12.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf13, SDf13.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf16, SDf16.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf17, SDf17.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf18, SDf18.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_Session, Session.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_STrades, STrades.class,
|
||||
new SettingOperation("setQty", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)}),
|
||||
new SettingOperation("setValue", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)}),
|
||||
new SettingOperation("setExchangeCommission", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(18)}),
|
||||
new SettingOperation("setQty", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(18)}),
|
||||
new SettingOperation("setValue", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(18)})
|
||||
));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UncoveredDealRegister, UncoveredDealRegister.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_UncoveredDealRegister, UncoveredDealRegister.class,
|
||||
new SettingOperation("setCreated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setUpdated", new Class[]{Instant.class}, new Object[]{generatingRandomInstant(true)}),
|
||||
new SettingOperation("setAmount", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UserRoleSession, UserRoleSession.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UserSettings, UserSettings.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_VerificationResult, VerificationResult.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_UserRoleSession, UserRoleSession.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_UserSettings, UserSettings.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_VerificationResult, VerificationResult.class,
|
||||
new SettingOperation("setDiffSum", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)}),
|
||||
new SettingOperation("setInSum", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)}),
|
||||
new SettingOperation("setOutExtSum", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)}),
|
||||
new SettingOperation("setOutIntSum", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_FixedIncomeCashFlow, FixedIncomeCashFlow.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_FixedIncomeCashFlow, FixedIncomeCashFlow.class,
|
||||
new SettingOperation("setAccruedCoupon", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})
|
||||
));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_CouponPeriod, CouponPeriod.class,
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_CouponPeriod, CouponPeriod.class,
|
||||
new SettingOperation("setCouponRate", new Class[]{BigDecimal.class}, new Object[]{generatingRandomBigDecimal(2)})
|
||||
));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf51, SDf51.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf52, SDf52.class));
|
||||
businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SDf53, SDf53.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf51, SDf51.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf52, SDf52.class));
|
||||
checkerBusinessMapStores.add(new CheckerBusinessMapStore<>(IMDGDistributedNames.Map_SDf53, SDf53.class));
|
||||
//todo other...
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
<module>registry-service</module>
|
||||
<module>test-clearing</module>
|
||||
<module>cleaning-builders</module>
|
||||
<module>trade-importer</module>
|
||||
<module>lim-exporter</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ package ru.spcex.clearing.scheduler.config;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.enumeration.SimpleMessageResolver;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
@Configuration
|
||||
public class ErrorResolverConfig {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver() {
|
||||
return new SimpleMessageResolver();
|
||||
public IMessageResolver messageResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ package ru.spcex.clearing.securities.config;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.enumeration.SimpleMessageResolver;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
@Configuration
|
||||
public class ErrorResolverConfig {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver() {
|
||||
return new SimpleMessageResolver();
|
||||
public IMessageResolver messageResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ public class UserRoleVerification {
|
|||
Objects.requireNonNull(roleForVerification);
|
||||
Long requesterId = req.getUserId();
|
||||
if (requesterId != null && !userHasRole(requesterId, roleForVerification)) {
|
||||
log.debug("User {} has no role to allow this action", requesterId);
|
||||
String errMsg = messageResolver.resolve(new EnumMessage(roleVerificationError, requesterId));
|
||||
log.info("User {} has no role: {}", requesterId, errMsg);
|
||||
return new RequestInfoUpdate()
|
||||
.setId(req.getId())
|
||||
.setStatus(ru.spcex.clearing.platform.messaging.service.Status.Error)
|
||||
|
|
|
|||
131
clearing-parent/trade-importer/pom.xml
Normal file
131
clearing-parent/trade-importer/pom.xml
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-parent</artifactId>
|
||||
<version>SPCEX-1.0.0.0</version>
|
||||
</parent>
|
||||
<artifactId>trade-importer</artifactId>
|
||||
<name>trade-importer</name>
|
||||
<description>Trade importer module</description>
|
||||
<version>SPCEX-1.0.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JDBC -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>classes</artifactId>
|
||||
<version>SPCEX-1.0.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-messaging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-imdg-api-hazelcast-impl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-enum</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>test-clearing</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>application.properties</exclude>
|
||||
</excludes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.21.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-surefire-provider</artifactId>
|
||||
<version>1.2.0-M1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.2.0-M1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package ru.spcex.clearing.trade.importer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class TradeImporterApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication app = new SpringApplication(TradeImporterApplication.class);
|
||||
app.run(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package ru.spcex.clearing.trade.importer.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import ru.spcex.clearing.trade.importer.config.settings.DatabaseSettings;
|
||||
import ru.spcex.clearing.trade.importer.config.settings.ImportTradeServiceSettings;
|
||||
import ru.spcex.clearing.trade.importer.error.ModuleInitializeException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
|
||||
import static org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection;
|
||||
|
||||
@SuppressWarnings("UnnecessaryLocalVariable")
|
||||
@Configuration
|
||||
public class DbConnectionConfig {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final DatabaseSettings settings;
|
||||
|
||||
public DbConnectionConfig(ImportTradeServiceSettings settings) {
|
||||
this.settings = settings.getDatabase();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
String login = settings.getLogin();
|
||||
String password = settings.getPassword();
|
||||
String dbUrl = settings.getUrl();
|
||||
String driver = settings.getDriver();
|
||||
|
||||
DriverManagerDataSource ds = new DriverManagerDataSource();
|
||||
try {
|
||||
ds.setDriverClassName(driver);
|
||||
} catch (Exception ue) {
|
||||
throw new RuntimeException(ue);
|
||||
}
|
||||
ds.setUrl(dbUrl);
|
||||
ds.setUsername(login);
|
||||
ds.setPassword(password);
|
||||
|
||||
String OPERATION_DATABASE_CONNECTION_CHECK = String.format("Database [%s] connection check", dbUrl);
|
||||
try {
|
||||
Connection conn = ds.getConnection();
|
||||
doCloseConnection(conn, ds);
|
||||
log.info("{}: success", OPERATION_DATABASE_CONNECTION_CHECK);
|
||||
return ds;
|
||||
} catch (Throwable e) {
|
||||
String msg = String.format("%s: failed: %s -> %s",
|
||||
OPERATION_DATABASE_CONNECTION_CHECK, e.getClass().getSimpleName(), e.getMessage());
|
||||
log.error(msg);
|
||||
throw new ModuleInitializeException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
return jdbcTemplate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package ru.spcex.clearing.trade.importer.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
@Configuration
|
||||
public class ErrorResolverConfig {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package ru.spcex.clearing.trade.importer.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import ru.spcex.clearing.trade.importer.config.settings.ImportTradeServiceSettings;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
@Configuration
|
||||
public class ImdgConfig {
|
||||
private static ThreadPoolTaskExecutor createThreadPoolTaskExecutor(int maxPoolSz, boolean waitForCompletion) {
|
||||
ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
|
||||
if (maxPoolSz > 2) {
|
||||
pool.setKeepAliveSeconds(60);
|
||||
pool.setAllowCoreThreadTimeOut(true);
|
||||
}
|
||||
pool.setCorePoolSize(maxPoolSz);
|
||||
pool.setWaitForTasksToCompleteOnShutdown(waitForCompletion);
|
||||
return pool;
|
||||
}
|
||||
|
||||
@Bean(name = "taskExecutorHazelcastClientInitializer")
|
||||
public ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer() {
|
||||
return createThreadPoolTaskExecutor(1, true);
|
||||
}
|
||||
|
||||
@Bean(name = "taskExecutorIdGeneratorAwaiter")
|
||||
public ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter() {
|
||||
return createThreadPoolTaskExecutor(1, false);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public ImdgProvider imdgProvider(
|
||||
@Qualifier("taskExecutorHazelcastClientInitializer") ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer,
|
||||
@Qualifier("taskExecutorIdGeneratorAwaiter") ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter,
|
||||
ImportTradeServiceSettings settings
|
||||
) {
|
||||
return new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||
taskExecutorIdGeneratorAwaiter,
|
||||
settings.getHazelcast());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package ru.spcex.clearing.trade.importer.config;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaConsumerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaProducerFactory;
|
||||
import ru.spcex.clearing.trade.importer.config.settings.ImportTradeServiceSettings;
|
||||
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
|
||||
@Autowired
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Bean
|
||||
public Consumer<String, Object> createConsumer(ImportTradeServiceSettings settings) {
|
||||
return KafkaConsumerFactory.consumer(settings.getKafkaConsumer());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public Producer<String, Object> createProducer(ImportTradeServiceSettings settings) {
|
||||
return KafkaProducerFactory.producer(settings.getKafkaProducer());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package ru.spcex.clearing.trade.importer.config;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.clearing.trade.importer.config.settings.ImportTradeServiceSettings;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties
|
||||
@ComponentScan(basePackages = {"ru.spcex.clearing.trade.importer"})
|
||||
public class TradeImporterConfig {
|
||||
private final ImportTradeServiceSettings settings;
|
||||
private final ApplicationContext context;
|
||||
|
||||
public TradeImporterConfig(ImportTradeServiceSettings settings, ApplicationContext context) {
|
||||
this.settings = settings;
|
||||
this.context = context;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package ru.spcex.clearing.trade.importer.config.settings;
|
||||
|
||||
public class Cron {
|
||||
|
||||
private String checkSrcDirCron;
|
||||
|
||||
public String getCheckSrcDirCron() {
|
||||
return checkSrcDirCron;
|
||||
}
|
||||
|
||||
public void setCheckSrcDirCron(String checkSrcDirCron) {
|
||||
this.checkSrcDirCron = checkSrcDirCron;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package ru.spcex.clearing.trade.importer.config.settings;
|
||||
|
||||
public class DatabaseSettings {
|
||||
private String login;
|
||||
private String password;
|
||||
private String url;
|
||||
private String driver;
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package ru.spcex.clearing.trade.importer.config.settings;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.platform.messaging.config.element.KafkaConsumerSettings;
|
||||
import ru.spcex.clearing.platform.messaging.config.element.KafkaProducerSettings;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.config.HazelcastClientParams;
|
||||
|
||||
@Component
|
||||
@PropertySource("file:${spring.config.location}/application.properties")
|
||||
@ConfigurationProperties("trade-importer")
|
||||
public class ImportTradeServiceSettings {
|
||||
private HazelcastClientParams hazelcast;
|
||||
private KafkaProducerSettings kafkaProducer;
|
||||
private KafkaConsumerSettings kafkaConsumer;
|
||||
private DatabaseSettings database;
|
||||
private Cron cron;
|
||||
|
||||
public HazelcastClientParams getHazelcast() {
|
||||
return hazelcast;
|
||||
}
|
||||
|
||||
public void setHazelcast(HazelcastClientParams hazelcast) {
|
||||
this.hazelcast = hazelcast;
|
||||
}
|
||||
|
||||
public KafkaProducerSettings getKafkaProducer() {
|
||||
return kafkaProducer;
|
||||
}
|
||||
|
||||
public void setKafkaProducer(KafkaProducerSettings kafkaProducer) {
|
||||
this.kafkaProducer = kafkaProducer;
|
||||
}
|
||||
|
||||
public KafkaConsumerSettings getKafkaConsumer() {
|
||||
return kafkaConsumer;
|
||||
}
|
||||
|
||||
public void setKafkaConsumer(KafkaConsumerSettings kafkaConsumer) {
|
||||
this.kafkaConsumer = kafkaConsumer;
|
||||
}
|
||||
|
||||
|
||||
public DatabaseSettings getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(DatabaseSettings database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public Cron getCron() {
|
||||
return cron;
|
||||
}
|
||||
|
||||
public void setCron(Cron cron) {
|
||||
this.cron = cron;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package ru.spcex.clearing.trade.importer.error;
|
||||
|
||||
public class ModuleInitializeException extends RuntimeException {
|
||||
public ModuleInitializeException() {
|
||||
}
|
||||
|
||||
public ModuleInitializeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ModuleInitializeException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ModuleInitializeException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package ru.spcex.clearing.trade.importer.error;
|
||||
|
||||
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
||||
|
||||
public enum TradeImporterError implements IErrorEnumId {
|
||||
sTradesNotValid(10001L),
|
||||
;
|
||||
|
||||
private final Long id;
|
||||
|
||||
TradeImporterError(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package ru.spcex.clearing.trade.importer.services;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.platform.enumeration.Task;
|
||||
|
||||
@Service
|
||||
public class LauncherCommandReceiver extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final TradeImporterService importer;
|
||||
|
||||
@Autowired
|
||||
public LauncherCommandReceiver(Consumer<String, Object> kafkaQueue,
|
||||
TradeImporterService importer) {
|
||||
super(kafkaQueue);
|
||||
this.importer = importer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(LauncherCommandRequest.class)
|
||||
.setConsumer(action -> importer.process(true))
|
||||
.forDestination(Task.getOfTrades.topic(), callbacks::put); // GTRD
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
package ru.spcex.clearing.trade.importer.services;
|
||||
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.clearing.classes.statics.data.misc.STrades;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.STradesImportedRequest;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import static ru.spcex.clearing.platform.messaging.domain.Consts.S_TRADES_IMPORTED;
|
||||
import static ru.spcex.clearing.trade.importer.error.TradeImporterError.sTradesNotValid;
|
||||
|
||||
@Service
|
||||
@EnableScheduling
|
||||
public class TradeImporterService {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Imdg<STrades> sTradesImdg;
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final Producer<String, Object> producer;
|
||||
private final IMessageResolver messageResolver;
|
||||
|
||||
|
||||
public TradeImporterService(ImdgProvider imdgProvider, JdbcTemplate jdbcTemplate, Producer<String, Object> producer, IMessageResolver messageResolver) {
|
||||
this.sTradesImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_STrades, STrades.class);
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.producer = producer;
|
||||
this.messageResolver = messageResolver;
|
||||
}
|
||||
|
||||
@Scheduled(cron = "${trade-importer.cron.load-from-db-cron}")
|
||||
public void run() {
|
||||
process(false);
|
||||
}
|
||||
|
||||
public void process(boolean byCommand) {
|
||||
log.debug("Start process import STrades from DB");
|
||||
Collection<STrades> tradesFromDB = jdbcTemplate.query("SELECT * FROM Trades", (resultSet, i) -> readSTrades(resultSet));
|
||||
|
||||
log.debug("load from DB STrades: {}", tradesFromDB.size());
|
||||
for (STrades tradesDb : tradesFromDB) {
|
||||
if (isValidTrades(tradesDb)) {
|
||||
STrades sTrades = getSTradesFromImdg(tradesDb, sTradesImdg);
|
||||
if (sTrades != null) tradesDb.setId(sTrades.getId());
|
||||
sTradesImdg.insert(tradesDb);
|
||||
} else {
|
||||
log.warn(messageResolver.resolve(new EnumMessage(sTradesNotValid, tradesDb.getTradeNum())));
|
||||
}
|
||||
}
|
||||
|
||||
if (byCommand) {
|
||||
log.debug("Successfully import STrades from DB by command. Send to kafka command, topic={}", S_TRADES_IMPORTED);
|
||||
} else {
|
||||
log.debug("Successfully import STrades from DB by scheduled. Send to kafka command, topic={}", S_TRADES_IMPORTED);
|
||||
}
|
||||
STradesImportedRequest sTradesImportedRequest = new STradesImportedRequest();
|
||||
producer.send(new ProducerRecord<>(S_TRADES_IMPORTED, sTradesImportedRequest));
|
||||
}
|
||||
|
||||
public STrades getSTradesFromImdg(STrades tradesDb, Imdg<STrades> sTradesImdg) {
|
||||
return sTradesImdg.getSingleObjectByFieldValues(Map.of("tradeDate", tradesDb.getTradeDate(),
|
||||
"tradeNum", tradesDb.getTradeNum(),
|
||||
"operation", tradesDb.getOperation(),
|
||||
"classCode", tradesDb.getClassCode()));
|
||||
}
|
||||
|
||||
private boolean isValidTrades(STrades trades) {
|
||||
return trades.getTradeDate() != null
|
||||
&& trades.getTradeNum() != null
|
||||
&& StringUtils.hasText(trades.getOperation())
|
||||
&& trades.getTradeNum() != null;
|
||||
}
|
||||
|
||||
public STrades readSTrades(ResultSet resultSet) throws SQLException {
|
||||
STrades sTrades = new STrades();
|
||||
sTrades.setTradeNum(resultSet.getObject("TradeNum", Long.class));
|
||||
sTrades.setOperation(resultSet.getObject("Operation", String.class));
|
||||
sTrades.setClassCode(resultSet.getObject("ClassCode", String.class));
|
||||
sTrades.setTradeDate(getLocalDateFromSqlDate(resultSet, "TradeDate"));
|
||||
sTrades.setSecCode(resultSet.getObject("SecCode", String.class));
|
||||
sTrades.setAccruedint(resultSet.getObject("Accruedint", BigDecimal.class));
|
||||
sTrades.setAccruedint2(resultSet.getObject("Accruedint2", BigDecimal.class));
|
||||
sTrades.setLowerDiscount(resultSet.getObject("LowerDiscount", BigDecimal.class));
|
||||
sTrades.setOrderNum(resultSet.getObject("OrderNum", Long.class));
|
||||
sTrades.setPrice(resultSet.getObject("Price", BigDecimal.class));
|
||||
sTrades.setPrice2(resultSet.getObject("Price2", BigDecimal.class));
|
||||
sTrades.setRepoRate(resultSet.getObject("RepoRate", BigDecimal.class));
|
||||
sTrades.setRepoValue(resultSet.getObject("RepoValue", BigDecimal.class));
|
||||
sTrades.setRepo2Value(resultSet.getObject("Repo2Value", BigDecimal.class));
|
||||
sTrades.setStartDiscount(resultSet.getObject("StartDiscount", BigDecimal.class));
|
||||
sTrades.setTsCommission(resultSet.getObject("TSCommission", BigDecimal.class));
|
||||
sTrades.setUpperDiscount(resultSet.getObject("UpperDiscount", BigDecimal.class));
|
||||
sTrades.setValue(resultSet.getObject("Value", BigDecimal.class));
|
||||
sTrades.setYield(resultSet.getObject("Yield", BigDecimal.class));
|
||||
sTrades.setQty(resultSet.getObject("Qty", BigDecimal.class));
|
||||
sTrades.setQtyPcs(resultSet.getObject("Qty_pcs", BigDecimal.class));
|
||||
sTrades.setTradeDateTime(getInstantFromTimestamp(resultSet, "TradeDateTime"));
|
||||
sTrades.setRepoTerm(resultSet.getObject("RepoTerm", Long.class));
|
||||
sTrades.setClearingCommission(resultSet.getObject("ClearingCommission", BigDecimal.class));
|
||||
sTrades.setExchangeCommission(resultSet.getObject("ExchangeCommission", BigDecimal.class));
|
||||
sTrades.setTechCenterCommission(resultSet.getObject("TechCenterCommission", BigDecimal.class));
|
||||
sTrades.setAccount(resultSet.getObject("Account", String.class));
|
||||
sTrades.setBrokerRef(resultSet.getObject("BrokerRef", String.class));
|
||||
sTrades.setClientCode(resultSet.getObject("ClientCode", String.class));
|
||||
sTrades.setSettleCode(resultSet.getObject("SettleCode", String.class));
|
||||
sTrades.setUserId(resultSet.getObject("UserId", String.class));
|
||||
sTrades.setExchangeCode(resultSet.getObject("ExchangeCode", String.class));
|
||||
sTrades.setFirmId(resultSet.getObject("FirmId", String.class));
|
||||
sTrades.setFirmName(resultSet.getObject("FirmName", String.class));
|
||||
sTrades.setCpFirmId(resultSet.getObject("CPFirmId", String.class));
|
||||
sTrades.setCpFirmName(resultSet.getObject("CPFirmName", String.class));
|
||||
sTrades.setClassName(resultSet.getObject("ClassName", String.class));
|
||||
sTrades.setSecName(resultSet.getObject("SecName", String.class));
|
||||
sTrades.setSettleDate(getLocalDateFromSqlDate(resultSet, "SettleDate"));
|
||||
sTrades.setSettleCurrency(resultSet.getObject("SettleCurrency", String.class));
|
||||
sTrades.setTradeCurrency(resultSet.getObject("TradeCurrency", String.class));
|
||||
sTrades.setTradeTimeMs(resultSet.getObject("TradeTimeMs", Long.class));
|
||||
sTrades.setBankAccId(resultSet.getObject("BankAccId", String.class));
|
||||
sTrades.setSection(resultSet.getObject("Section", String.class));
|
||||
return sTrades;
|
||||
}
|
||||
|
||||
private Instant getInstantFromTimestamp(ResultSet rs, String column) throws SQLException {
|
||||
Timestamp date = rs.getTimestamp(column);
|
||||
return date != null ? date.toInstant() : null;
|
||||
}
|
||||
|
||||
private LocalDate getLocalDateFromSqlDate(ResultSet rs, String column) throws SQLException {
|
||||
Date date = rs.getDate(column);
|
||||
return date != null ? date.toLocalDate() : null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
spring.main.web-application-type=none
|
||||
|
||||
#trade-importer.cron.load-from-db-cron=0 0/5 * * * ? - каждые 5 минут
|
||||
trade-importer.cron.load-from-db-cron=0 0/5 * * * ?
|
||||
|
||||
trade-importer.database.login=sa
|
||||
trade-importer.database.password=Aa123456
|
||||
trade-importer.database.url=jdbc:sqlserver://localhost:1433;database=SPVB_TS;schema=dbo
|
||||
trade-importer.database.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
|
||||
trade-importer.hazelcast.cluster-members=127.0.0.1:5701
|
||||
trade-importer.hazelcast.login=dev
|
||||
trade-importer.hazelcast.password=dev-pass
|
||||
|
||||
trade-importer.kafka-consumer.bootstrap-servers=localhost:9092
|
||||
trade-importer.kafka-consumer.group-id=dev-group-trade-importer
|
||||
trade-importer.kafka-consumer.enable-auto-commit=false
|
||||
trade-importer.kafka-consumer.session-timeout-ms=30000
|
||||
trade-importer.kafka-consumer.auto-offset-reset=latest
|
||||
trade-importer.kafka-consumer.linger-ms=1
|
||||
trade-importer.kafka-consumer.buffer-memory=33554432
|
||||
|
||||
trade-importer.kafka-producer.bootstrap-servers=localhost:9092
|
||||
trade-importer.kafka-producer.acks=all
|
||||
trade-importer.kafka-producer.retries=0
|
||||
trade-importer.kafka-producer.batch-size=16384
|
||||
trade-importer.kafka-producer.linger-ms=1
|
||||
trade-importer.kafka-producer.buffer-memory=33554432
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<!-- |%X{ru.nbch.scoring.web.logging.mdc_key}-->
|
||||
<Pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %class{0}:%line - %message%n</Pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>./logs/trade-importer.log</file>
|
||||
<encoder>
|
||||
<!-- |%X{ru.nbch.scoring.web.logging.mdc_key}-->
|
||||
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %class{0}:%msg%n</Pattern>
|
||||
<charset>utf8</charset>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<fileNamePattern>
|
||||
./logs/trade-importer.%i.log
|
||||
</fileNamePattern>
|
||||
<minIndex>1</minIndex>
|
||||
<maxIndex>10</maxIndex>
|
||||
</rollingPolicy>
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<maxFileSize>500MB</maxFileSize>
|
||||
</triggeringPolicy>
|
||||
</appender>
|
||||
|
||||
<root level="warn">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
|
||||
<logger name="ru.spcex" level="debug" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package ru.spcex.clearing.trade.importer;
|
||||
|
||||
import org.apache.kafka.clients.producer.MockProducer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.misc.STrades;
|
||||
import ru.clearing.classes.statics.data.scheduler.PlannerAllToday;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.test.TestUtils;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.clearing.trade.importer.config.ErrorResolverConfig;
|
||||
import ru.spcex.clearing.trade.importer.config.config.DbTestConnectionConfig;
|
||||
import ru.spcex.clearing.trade.importer.config.settings.ImportTradeServiceSettings;
|
||||
import ru.spcex.clearing.trade.importer.services.LauncherCommandReceiver;
|
||||
import ru.spcex.clearing.trade.importer.services.TradeImporterService;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.config.ImdgTestConfig.currentID;
|
||||
import static ru.spcex.clearing.test.config.ImdgTestConfig.waitAvailableImdgProviderAndAddAdminWithDefaultId;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
DbTestConnectionConfig.class,
|
||||
ErrorResolverConfig.class,
|
||||
ImportTradeServiceSettings.class,
|
||||
LauncherCommandReceiver.class,
|
||||
TradeImporterService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
public abstract class AbstractServiceTest {
|
||||
protected static final MatcherFactory.Matcher<PlannerAllToday> PLANNER_ALL_TODAY_MATCHER = usingIgnoringFieldsComparator("created", "updated");
|
||||
protected static final long id = currentID.getAndIncrement();
|
||||
protected Imdg<STrades> sTradesImdg;
|
||||
|
||||
@Captor
|
||||
protected ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@MockBean
|
||||
protected MockProducer<String, Object> mockProducer;
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
protected ImdgProvider imdgProvider;
|
||||
|
||||
protected void init() {
|
||||
waitAvailableImdgProviderAndAddAdminWithDefaultId();
|
||||
this.sTradesImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_STrades, STrades.class);
|
||||
|
||||
TestUtils.FutureRecordMetadata future = spy(new TestUtils.FutureRecordMetadata());
|
||||
doReturn(future).when(mockProducer).send(producerRecord.capture());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package ru.spcex.clearing.trade.importer.config.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
|
||||
import ru.spcex.clearing.trade.importer.error.ModuleInitializeException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
|
||||
@SuppressWarnings("UnnecessaryLocalVariable")
|
||||
@Configuration
|
||||
public class DbTestConnectionConfig {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Bean(destroyMethod = "destroy")
|
||||
public SingleConnectionDataSource dataSource() {
|
||||
String login = "sa";
|
||||
String password = "Aa123456";
|
||||
String dbUrl = "jdbc:sqlserver://localhost:1433;database=SPVB_TS;schema=dbo";
|
||||
|
||||
|
||||
SingleConnectionDataSource cpds = new SingleConnectionDataSource();
|
||||
try {
|
||||
cpds.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
||||
} catch (Exception ue) {
|
||||
throw new RuntimeException(ue);
|
||||
}
|
||||
cpds.setUrl(dbUrl);
|
||||
cpds.setUsername(login);
|
||||
cpds.setPassword(password);
|
||||
|
||||
String OPERATION_DATABASE_CONNECTION_CHECK = String.format("Database [%s] connection check", dbUrl);
|
||||
try {
|
||||
Connection conn = cpds.getConnection();
|
||||
// conn.close();
|
||||
log.info("{}: success", OPERATION_DATABASE_CONNECTION_CHECK);
|
||||
return cpds;
|
||||
} catch (Throwable e) {
|
||||
String msg = String.format("%s: failed: %s -> %s",
|
||||
OPERATION_DATABASE_CONNECTION_CHECK, e.getClass().getSimpleName(), e.getMessage());
|
||||
log.error(msg);
|
||||
throw new ModuleInitializeException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
return jdbcTemplate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
package ru.spcex.clearing.trade.importer.services;
|
||||
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import ru.clearing.classes.statics.data.misc.STrades;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.trade.importer.AbstractServiceTest;
|
||||
import ru.spcex.platform.enumeration.Task;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
|
||||
class TradeImporterServiceTest extends AbstractServiceTest {
|
||||
public static final MatcherFactory.Matcher<STrades> S_TRADES_MATCHER = usingIgnoringFieldsComparator();
|
||||
|
||||
@Autowired
|
||||
LauncherCommandReceiver launcherCommandReceiver;
|
||||
|
||||
@Autowired
|
||||
TradeImporterService tradeImporterService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
super.init();
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void setProperty() {
|
||||
Path path = Paths.get("src", "main", "resources");
|
||||
String currentPath = path.toAbsolutePath().toString();
|
||||
System.setProperty("spring.config.location", currentPath);
|
||||
// Hazelcast.shutdownAll();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
private void prepare(){
|
||||
clearAllInImdg(sTradesImdg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link TradeImporterService#process(boolean)}<br>
|
||||
* Тест проверяет обновление сущности {@link STrades}.<br>
|
||||
* Входной запрос {@link LauncherCommandRequest}:<br>
|
||||
*/
|
||||
// @Test //для работы теста нужна тестовая база Microsoft SQL с данными
|
||||
void process() {
|
||||
STrades sTrade = getSTrade();
|
||||
Long id = sTradesImdg.insert(sTrade);
|
||||
|
||||
addRecordToKafka((MockConsumer) launcherCommandReceiver.getConsumer(), Task.getOfTrades.topic(), 0, 1, getJsonStringForNew(new LauncherCommandRequest(),0));
|
||||
|
||||
//waiting for kafka producer send message
|
||||
verify(mockProducer, timeout(30_000L).times(1))
|
||||
.send(producerRecord.capture());
|
||||
|
||||
STrades sTrades = tradeImporterService.getSTradesFromImdg(sTrade, sTradesImdg);
|
||||
|
||||
assertEquals(sTrades.getId(), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link TradeImporterService#process(boolean)}<br>
|
||||
* Тест проверяет обновление сущности {@link STrades}.<br>
|
||||
* Входной запрос {@link LauncherCommandRequest}:<br>
|
||||
*/
|
||||
@Test
|
||||
void getSTradesFromImdg(){
|
||||
STrades sTrade = getSTrade();
|
||||
Long id = sTradesImdg.insert(sTrade);
|
||||
STrades sTradeRes = tradeImporterService.getSTradesFromImdg(sTrade, sTradesImdg);
|
||||
S_TRADES_MATCHER.assertMatch(sTradeRes, sTrade);
|
||||
|
||||
sTrade.setTradeNum(23L);
|
||||
sTradeRes = tradeImporterService.getSTradesFromImdg(sTrade, sTradesImdg);
|
||||
assertNull(sTradeRes);
|
||||
}
|
||||
|
||||
private STrades getSTrade(){
|
||||
STrades trades = new STrades();
|
||||
trades.setTradeDate(LocalDate.of(2023,4,19));
|
||||
trades.setTradeNum(661486L);
|
||||
trades.setOperation("operation20");
|
||||
trades.setClassCode("UESC");
|
||||
return trades;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package ru.spcex.platform.enumeration;
|
|||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
public enum AccountType implements IEnumKey {
|
||||
Clrn("CLRN"), Bank("BANK"), Info("INFO"), Tran("TRAN"), Corr("CORR"), Anlt("ANLT");
|
||||
Clrn("CLRN"), Bank("BANK"), Info("INFO"), Tran("TRAN"), Corr("CORR"), Anlt("ANLT"), Depo("DEPO");
|
||||
|
||||
private final String key;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package ru.spcex.platform.enumeration;
|
|||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
public enum Service implements IEnumKey {
|
||||
MKR("MKR");
|
||||
MKR("MKR"), FOND("FOND");
|
||||
|
||||
private final String key;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,12 +54,24 @@ public interface Consts {
|
|||
String DESTINATION_CLEARING_MEMBER_CATEGORY_UPDATE = "clearing-member-category-update";
|
||||
String DESTINATION_CLEARING_MEMBER_CATEGORY_DELETE = "clearing-member-category-delete";
|
||||
|
||||
String DESTINATION_ACCOUNT_DELETE = "account-delete";
|
||||
String DESTINATION_ACCOUNT_UPDATE = "account-update";
|
||||
String DESTINATION_ACCOUNT_NEW = "account-new";
|
||||
String DESTINATION_BANK_ACCOUNT_DELETE = "bank-account-delete";
|
||||
String DESTINATION_DEPO_ACCOUNT_NEW = "depo-account-new";
|
||||
|
||||
String DESTINATION_CLEARING_ACCOUNT_NEW = "clearing-account-new";
|
||||
String DESTINATION_CLEARING_ACCOUNT_UPDATE = "clearing-account-update";
|
||||
|
||||
String DESTINATION_INFORMATION_ACCOUNT_NEW = "information-account-new";
|
||||
|
||||
String DESTINATION_CORRESPONDENT_ACCOUNT_NEW = "correspondent-account-new";
|
||||
String DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE = "correspondent-account-update";
|
||||
String DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK = "correspondent-account-block";
|
||||
|
||||
String DESTINATION_BANK_ACCOUNT_BLOCK = "bank-account-block";
|
||||
String DESTINATION_BANK_ACCOUNT_UPDATE = "bank-account-update";
|
||||
String DESTINATION_BANK_ACCOUNT_NEW = "bank-account-new";
|
||||
|
||||
@Deprecated
|
||||
String ACCOUNT_NEW_SDF01 = "account-new-sdf01";
|
||||
|
||||
String DESTINATION_RELATION_UPDATE = "relation-update";
|
||||
String DESTINATION_PROFILE_DOCUMENT_NEW = "profile-document-new";
|
||||
String DESTINATION_PROFILE_DOCUMENT_UPDATE = "profile-document-update";
|
||||
|
|
@ -86,7 +98,7 @@ public interface Consts {
|
|||
String SDF03_PROCESS = "sdf03-process";
|
||||
String SDF11_PROCESS = "sdf11-process";
|
||||
String EXPORT_PROCESS = "export-process";
|
||||
String ACCOUNT_NEW = "account-new";
|
||||
String S_TRADES_IMPORTED = "s_trades-imported";
|
||||
String ACCOUNT_TERMINATION = "account-termination";
|
||||
String BALANCE_ACCOUNT_NEW = "balance-account-new";
|
||||
String BALANCE_ACCOUNT_UPDATE = "balance-account-update";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ClearingAccountNewRequest {
|
||||
@JsonProperty
|
||||
public String account;
|
||||
|
||||
@JsonProperty
|
||||
public String clearingAccountType;
|
||||
|
||||
@JsonProperty
|
||||
public Long companyId;
|
||||
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getClearingAccountType() {
|
||||
return clearingAccountType;
|
||||
}
|
||||
|
||||
public void setClearingAccountType(String clearingAccountType) {
|
||||
this.clearingAccountType = clearingAccountType;
|
||||
}
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ClearingAccountUpdateRequest {
|
||||
@JsonProperty
|
||||
public String account;
|
||||
|
||||
@JsonProperty
|
||||
public Integer status;
|
||||
|
||||
@JsonProperty
|
||||
public String deal;
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDeal() {
|
||||
return deal;
|
||||
}
|
||||
|
||||
public void setDeal(String deal) {
|
||||
this.deal = deal;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class CorrespondentAccountNewRequest {
|
||||
@JsonProperty
|
||||
public Long companyId;
|
||||
|
||||
@JsonProperty
|
||||
public String account;
|
||||
|
||||
@JsonProperty
|
||||
public String status;
|
||||
|
||||
@JsonProperty
|
||||
public String accountType;
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(String accountType) {
|
||||
this.accountType = accountType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class CorrespondentAccountUpdateRequest {
|
||||
@JsonProperty
|
||||
public Long id;
|
||||
|
||||
@JsonProperty
|
||||
public Long companyId;
|
||||
|
||||
@JsonProperty
|
||||
public String account;
|
||||
|
||||
@JsonProperty
|
||||
public String status;
|
||||
|
||||
@JsonProperty
|
||||
public String accountType;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(String accountType) {
|
||||
this.accountType = accountType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class DepoAccountNewRequest {
|
||||
@JsonProperty
|
||||
public String account;
|
||||
|
||||
@JsonProperty
|
||||
public String depoAccountType;
|
||||
|
||||
@JsonProperty
|
||||
public Long companyId;
|
||||
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getDepoAccountType() {
|
||||
return depoAccountType;
|
||||
}
|
||||
|
||||
public void setDepoAccountType(String depoAccountType) {
|
||||
this.depoAccountType = depoAccountType;
|
||||
}
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class InformationAccountNewRequest {
|
||||
@JsonProperty
|
||||
public Long companyId;
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@Deprecated
|
||||
public class AccountSdf01Request {
|
||||
|
||||
private Long groupingSdf01Id;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Deprecated
|
||||
public class AccountSdfRequestPart {
|
||||
@JsonProperty
|
||||
private Long sdfId;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.utilities;
|
||||
|
||||
public class STradesImportedRequest {
|
||||
}
|
||||
|
|
@ -80,6 +80,7 @@ public class QueueConsumer implements AutoCloseable {
|
|||
consumer.subscribe(callbacks.keySet());
|
||||
}
|
||||
Object o = null;
|
||||
int lastErrors = 0;
|
||||
while (!closed.get()) {
|
||||
try {
|
||||
ConsumerRecords<String, Object> records = consumer.poll(Duration.of(10, ChronoUnit.SECONDS));
|
||||
|
|
@ -95,11 +96,21 @@ public class QueueConsumer implements AutoCloseable {
|
|||
}
|
||||
}
|
||||
}
|
||||
lastErrors = 0;
|
||||
} catch (Throwable e) {
|
||||
log.error(ExceptionUtils.getStackTrace(e));
|
||||
if (producer != null && o != null) {
|
||||
sendErrorResponse((BaseRequest<?>) o);
|
||||
}
|
||||
if (lastErrors++ > 20) {
|
||||
log.warn("Too many error at row, {}. Sleep.", lastErrors);
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException ie) {
|
||||
log.info("Thread interrupted. {}", ExceptionUtils.getStackTrace(ie));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (WakeupException e) {
|
||||
|
|
|
|||
1
pom.xml
1
pom.xml
|
|
@ -37,6 +37,7 @@
|
|||
<folder_root_clearing_imdg>${folder_root_clearing}/clearing-parent/imdg</folder_root_clearing_imdg>
|
||||
<folder_root_dbf-exporter>${folder_root_clearing}/clearing-parent/dbf-exporter</folder_root_dbf-exporter>
|
||||
<folder_root_dbf-importer>${folder_root_clearing}/clearing-parent/dbf-importer</folder_root_dbf-importer>
|
||||
<folder_root_trade-importer>${folder_root_clearing}/clearing-parent/trade-importer</folder_root_trade-importer>
|
||||
<folder_root_account-service>${folder_root_clearing}/clearing-parent/account-service</folder_root_account-service>
|
||||
<folder_root_balance-service>${folder_root_clearing}/clearing-parent/balance-service</folder_root_balance-service>
|
||||
<folder_root_company-service>${folder_root_clearing}/clearing-parent/company-service</folder_root_company-service>
|
||||
|
|
|
|||
|
|
@ -191,6 +191,25 @@
|
|||
</fileSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-trade-importer-bin</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<sourceFile>${folder_root_trade-importer}/target/trade-importer.jar</sourceFile>
|
||||
<destinationFile>${folder.clearing.distr.modules}/trade-importer/trade-importer.jar</destinationFile>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<sourceFile>${folder_root_trade-importer}/src/main/resources/application.properties</sourceFile>
|
||||
<destinationFile>${folder.clearing.distr.modules}/trade-importer/application.properties</destinationFile>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-account-service-bin</id>
|
||||
<phase>prepare-package</phase>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ kill -9 $(ps -ef | grep java | grep company-service.jar | awk '{print $2}')
|
|||
kill -9 $(ps -ef | grep java | grep clearing-service.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep dbf-exporter.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep dbf-importer.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep trade-importer.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep imdg.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep securities-service.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep utility-service.jar | awk '{print $2}')
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ cd /opt/mfd/clearing/bin
|
|||
/opt/mfd/clearing/bin/clearing-service.sh
|
||||
/opt/mfd/clearing/bin/dbf-exporter.sh
|
||||
/opt/mfd/clearing/bin/dbf-importer.sh
|
||||
/opt/mfd/clearing/bin/trade-importer.sh
|
||||
/opt/mfd/clearing/bin/securities-service.sh
|
||||
/opt/mfd/clearing/bin/utility-service.sh
|
||||
/opt/mfd/clearing/bin/scheduler-service.sh
|
||||
|
|
|
|||
9
z-distr/src/main/resources/distr/bin/trade-importer.sh
Normal file
9
z-distr/src/main/resources/distr/bin/trade-importer.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
CLEARING_HOME=/opt/mfd/clearing/
|
||||
cd $CLEARING_HOME/bin
|
||||
|
||||
CMD="java -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7100 -jar trade-importer.jar --spring.config.location=$CLEARING_HOME/settings/trade-importer/"
|
||||
|
||||
$CMD >/dev/null 2>&1 &
|
||||
|
||||
Loading…
Add table
Reference in a new issue