clearingAccountUpdate test
This commit is contained in:
parent
09b65585c4
commit
2fc7c7e180
2 changed files with 44 additions and 2 deletions
|
|
@ -89,8 +89,10 @@ public class ClearingAccountValidationConfig {
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ 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;
|
||||
|
|
@ -50,13 +51,14 @@ import static ru.spcex.clearing.account.utils.TestUtils.*;
|
|||
HazelcastServiceTestConfiguration.class,
|
||||
KafkaConfigTest.class})
|
||||
class ClearingAccountServiceTest {
|
||||
public static final MatcherFactory.Matcher<ClearingAccount> INFORMATION_ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
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;
|
||||
|
|
@ -108,6 +110,7 @@ class ClearingAccountServiceTest {
|
|||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
company.setTradingCode(TRADING_CODE);
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
|
|
@ -169,10 +172,47 @@ class ClearingAccountServiceTest {
|
|||
predictableClearingAccount.setId(resultClearingAccountNew.getId());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(resultAccountNew, predictableAccount);
|
||||
INFORMATION_ACCOUNT_MATCHER.assertMatch(resultClearingAccountNew, predictableClearingAccount);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue