account-service поправил правки по изменённому правками ТЗ. Поправил.
This commit is contained in:
parent
8991d915b3
commit
bc0f95e032
7 changed files with 22 additions and 14 deletions
|
|
@ -54,8 +54,9 @@ public class AccountValidationConfig {
|
||||||
IMDGDistributedNames.Map_Company,
|
IMDGDistributedNames.Map_Company,
|
||||||
Company.class,
|
Company.class,
|
||||||
AccountError.RequiredFieldEmpty,
|
AccountError.RequiredFieldEmpty,
|
||||||
AccountError.CompanyNotFound,
|
AccountError.CompanyNotFound
|
||||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive),
|
// company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive
|
||||||
|
),
|
||||||
FieldRequiredRule.instance("account",
|
FieldRequiredRule.instance("account",
|
||||||
CorrespondentAccountNewRequest::getAccount,
|
CorrespondentAccountNewRequest::getAccount,
|
||||||
AccountError.RequiredFieldEmpty,
|
AccountError.RequiredFieldEmpty,
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ public class BankAccountValidationConfig {
|
||||||
);
|
);
|
||||||
Account account = accountImdg.getSingleObjectByID(accountId);
|
Account account = accountImdg.getSingleObjectByID(accountId);
|
||||||
if (account == null) return AccountError.AccountNotFound;
|
if (account == null) return AccountError.AccountNotFound;
|
||||||
if (!AccountStatus.ACTIVE.equalsByKey(account.getStatus())) return AccountError.AccountNotActive;
|
// if (!AccountStatus.ACTIVE.equalsByKey(account.getStatus())) return AccountError.AccountNotActive;
|
||||||
return null;
|
return null;
|
||||||
}),
|
}),
|
||||||
DictionaryPresentRule.instance("currency",
|
DictionaryPresentRule.instance("currency",
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,9 @@ public class ClearingAccountValidationConfig {
|
||||||
IMDGDistributedNames.Map_Company,
|
IMDGDistributedNames.Map_Company,
|
||||||
Company.class,
|
Company.class,
|
||||||
AccountError.RequiredFieldEmpty,
|
AccountError.RequiredFieldEmpty,
|
||||||
AccountError.CompanyNotFound,
|
AccountError.CompanyNotFound
|
||||||
company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null),
|
// company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null
|
||||||
|
),
|
||||||
FieldRequiredRule.instance("account",
|
FieldRequiredRule.instance("account",
|
||||||
ClearingAccountNewRequest::getAccount,
|
ClearingAccountNewRequest::getAccount,
|
||||||
AccountError.RequiredFieldEmpty,
|
AccountError.RequiredFieldEmpty,
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,9 @@ public class DepoAccountValidationConfig {
|
||||||
IMDGDistributedNames.Map_Company,
|
IMDGDistributedNames.Map_Company,
|
||||||
Company.class,
|
Company.class,
|
||||||
AccountError.RequiredFieldEmpty,
|
AccountError.RequiredFieldEmpty,
|
||||||
AccountError.CompanyNotFound,
|
AccountError.CompanyNotFound
|
||||||
company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null),
|
// company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null
|
||||||
|
),
|
||||||
FieldRequiredRule.instance("account",
|
FieldRequiredRule.instance("account",
|
||||||
DepoAccountNewRequest::getAccount,
|
DepoAccountNewRequest::getAccount,
|
||||||
AccountError.RequiredFieldEmpty,
|
AccountError.RequiredFieldEmpty,
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,9 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
||||||
} else if (IEnumKey.contains(clearingCategoryValue, ClearingCategory.F, ClearingCategory.C)) {
|
} else if (IEnumKey.contains(clearingCategoryValue, ClearingCategory.F, ClearingCategory.C)) {
|
||||||
servicePredicate = relationPredicateBuilder.equals("service", ru.spcex.platform.enumeration.Service.FOND.getKey());
|
servicePredicate = relationPredicateBuilder.equals("service", ru.spcex.platform.enumeration.Service.FOND.getKey());
|
||||||
} else {
|
} else {
|
||||||
return makeError(requestId, AccountError.ClearingCategoryNotFound, companyId, clearingCategoryValue + " (case not implemented)");
|
log.info("ClearingCategoryNotFound with clearingCategoryValue={} not implemented. Do not search Relation.", clearingCategoryValue);
|
||||||
|
return null;
|
||||||
|
//return makeError(requestId, AccountError.ClearingCategoryNotFound, companyId, clearingCategoryValue + " (case not implemented)");
|
||||||
}
|
}
|
||||||
finalRelationPredicate = relationPredicateBuilder.and(consumerIdPredicate, servicePredicate);
|
finalRelationPredicate = relationPredicateBuilder.and(consumerIdPredicate, servicePredicate);
|
||||||
relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
||||||
|
|
@ -263,14 +265,15 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
||||||
relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relations.isEmpty()) return makeError(requestId, AccountError.WrongFieldValue, "companyId", finalRelationPredicate.toString());
|
if (relations.isEmpty()) {
|
||||||
|
//return makeError(requestId, AccountError.WrongFieldValue, "companyId", finalRelationPredicate.toString());
|
||||||
|
log.info("Relation not found: {}", finalRelationPredicate.toString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (relations.size() > 1)
|
if (relations.size() > 1)
|
||||||
log.warn("Relation for consumerId {} contains multiply elements, use first", companyId);
|
log.warn("Relation for consumerId {} contains multiply elements, use first", companyId);
|
||||||
Relation relation = relations.iterator().next();
|
Relation relation = relations.iterator().next();
|
||||||
account.setRelationId(relation.getId());
|
account.setRelationId(relation.getId());
|
||||||
if (account.getCompanyId() == null) {
|
|
||||||
account.setCompanyId(relation.getConsumerId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,9 @@ class ClientCodeServiceTest {
|
||||||
private HazelcastService hazelcastServiceTest;
|
private HazelcastService hazelcastServiceTest;
|
||||||
@Captor
|
@Captor
|
||||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||||
|
@Autowired
|
||||||
@Qualifier("mockProducer")
|
@Qualifier("mockProducer")
|
||||||
private MockProducer<String, Object> mockProducer;
|
protected Producer<String, Object> mockProducer;
|
||||||
|
|
||||||
private Imdg<ClientCode> clientCodeImdg;
|
private Imdg<ClientCode> clientCodeImdg;
|
||||||
|
|
||||||
|
|
@ -209,7 +210,7 @@ class ClientCodeServiceTest {
|
||||||
TestUtils.addRecordToKafka((MockConsumer) clientCodeService.getConsumer(), Consts.DESTINATION_CLIENT_CODE_NEW, PARTITION, 0, jsonString);
|
TestUtils.addRecordToKafka((MockConsumer) clientCodeService.getConsumer(), Consts.DESTINATION_CLIENT_CODE_NEW, PARTITION, 0, jsonString);
|
||||||
|
|
||||||
//ASSERT
|
//ASSERT
|
||||||
waitingSendAndCheckRecord(ID, mockProducer);
|
waitingSendAndCheckRecord(ID, mockProducer);
|
||||||
ClientCode resultNew = clientCodeImdg.getSingleObjectBySQL(String.format("code = '%s'", ccCode));
|
ClientCode resultNew = clientCodeImdg.getSingleObjectBySQL(String.format("code = '%s'", ccCode));
|
||||||
predictableClientCode.setId(resultNew.getId());
|
predictableClientCode.setId(resultNew.getId());
|
||||||
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
|
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
|
||||||
|
|
|
||||||
|
|
@ -255,6 +255,7 @@ class TradingClearingRegistryServiceTest {
|
||||||
predictableTradingClearingRegistry.setCode(predictableTradingClearingRegistry.getCode() + resultNew.getId());
|
predictableTradingClearingRegistry.setCode(predictableTradingClearingRegistry.getCode() + resultNew.getId());
|
||||||
predictableTradingClearingRegistry.setUpdated(resultNew.getUpdated());
|
predictableTradingClearingRegistry.setUpdated(resultNew.getUpdated());
|
||||||
predictableTradingClearingRegistry.setCreated(resultNew.getCreated());
|
predictableTradingClearingRegistry.setCreated(resultNew.getCreated());
|
||||||
|
predictableTradingClearingRegistry.setCompanyId(123L);
|
||||||
|
|
||||||
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultNew, predictableTradingClearingRegistry);
|
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultNew, predictableTradingClearingRegistry);
|
||||||
tradingClearingRegistryImdg.delete(resultNew);
|
tradingClearingRegistryImdg.delete(resultNew);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue