Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
ialbert 2023-05-24 18:04:33 +03:00
commit 8a9cb9f201
7 changed files with 59 additions and 12 deletions

View file

@ -77,8 +77,7 @@ public class EquitySecurityController extends AbstractQueueController {
@ResponseBody
public CommonGetAllResponse getAll() {
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_EquitySecurity,
EquitySecurity.class,
Map.of("workflowStatus", Status.Active.getKey()));
EquitySecurity.class);
CommonGetAllResponse response = new CommonGetAllResponse();
response.fromEntity(all);
return response;

View file

@ -77,8 +77,7 @@ public class FixedIncomeSecurityController extends AbstractQueueController {
@ResponseBody
public CommonGetAllResponse getAll() {
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_FixedIncomeSecurity,
FixedIncomeSecurity.class,
Map.of("workflowStatus", Status.Active.getKey()));
FixedIncomeSecurity.class);
CommonGetAllResponse response = new CommonGetAllResponse();
response.fromEntity(all);
return response;

View file

@ -33,7 +33,7 @@ public enum Sdf57ValidationRule implements IValidationRule<ImdgValidationContext
}
if (companyDebFound.isEmpty() && companyCredFound.isEmpty()) {
return of(ClearingError.CompanyNotFound, String.format("dealDeb = '%s'/ deal_cred = '%s'",
return of(ClearingError.CompanyNotFound, String.format("dealDeb = '%s'/ dealCred = '%s'",
sdf57.getDeal_deb(), sdf57.getDeal_cred()));
}
return empty();
@ -56,7 +56,7 @@ public enum Sdf57ValidationRule implements IValidationRule<ImdgValidationContext
accountCredFound.ifPresent(accountCred -> context.storeObject(ValidationStored.Sdf57AccountCred, accountCred));
}
if (accountDebFound.isEmpty() && accountCredFound.isEmpty()) {
return of(ClearingError.AccountNotPresent, String.format("accDeb = '%s'/ accDred = '%s'",
return of(ClearingError.AccountNotPresent, String.format("accDeb = '%s'/ accCred = '%s'",
sdf57.getC_acc_deb(), sdf57.getC_acc_cred()));
}
return empty();

View file

@ -80,7 +80,7 @@ public record EndDtAfterStartDtRule<R>(
LocalDate startDt = getterStartDt.apply(validatedObject);
if (endDt == null) return required ? of(errorEmptyRequiredValue, endDtFieldName) : Optional.empty();
if (startDt == null) return required ? of(errorEmptyRequiredValue, startDtFieldName) : Optional.empty();
if (endDt.isAfter(startDt)) return of(errorEndDtAfterStartDt, startDtFieldName, endDtFieldName);
if (startDt.isAfter(endDt)) return of(errorEndDtAfterStartDt, startDtFieldName, endDtFieldName);
return Optional.empty();
}
}

View file

@ -102,8 +102,14 @@ public class MoneyMarketSecurityService extends QueueConsumer implements Initial
ImdgTransaction transaction = imdgProvider.newTransaction();
MoneyMarketSecurityNewRequest req = userRequest.getRequestPayload();
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, validation.mmsNewValidator());
if (requestInfoUpdate != null) return requestInfoUpdate;
{
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
if (requestInfoUpdate != null) return requestInfoUpdate;
}
{
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, validation.mmsNewValidator());
if (requestInfoUpdate != null) return requestInfoUpdate;
}
log.debug("MoneyMarketSecurityNewRequest received");
MoneyMarketSecurity mms = new MoneyMarketSecurity();
@ -165,6 +171,7 @@ public class MoneyMarketSecurityService extends QueueConsumer implements Initial
.setMessage(errorMsg);
}
MoneyMarketSecurity mms = validator.getStored(Stored.PresentById);
if (mms == null) log.error("Validator return null stored mms object.");
Instant updateTime = Instant.now();
mms.setUpdated(updateTime);
mms.setStartDate(req.getStartDate());
@ -216,6 +223,7 @@ public class MoneyMarketSecurityService extends QueueConsumer implements Initial
}
Instant updateTime = Instant.now();
MoneyMarketSecurity mms = validator.getStored(Stored.PresentById);
if (mms == null) log.error("Validator return null stored mms object.");
mms.setWorkflowStatus(ru.spcex.platform.enumeration.Status.Blocked.getKey());
mms.setUpdated(updateTime);
moneyMarketSecurityMap.update(mms);

View file

@ -4,7 +4,7 @@ import org.springframework.util.StringUtils;
import ru.spcex.clearing.securities.errors.SecuritiesError;
import ru.spcex.platform.classes.base.SpcexObjectBase;
import ru.spcex.platform.classes.base.interfaces.WithSecuritySymbol;
import ru.spcex.platform.enumeration.Status;
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.enumeration.EnumMessage;
@ -30,11 +30,11 @@ public class NotPresentBySecuritySymbolAndWorkflowStatusActv<T extends SpcexObje
WithSecuritySymbol action = context.getValidatedObject();
Imdg<T> imdg = context.obtainMap(mapName, clazz);
if(!StringUtils.hasText(action.getSecuritySymbol())) {
return of(SecuritiesError.RequiredFieldIsEmpty, "securitySymbole");
return of(SecuritiesError.RequiredFieldIsEmpty, "securitySymbol");
}
T object = imdg.getSingleObjectByFieldValues(Map.of(
"securitySymbol", action.getSecuritySymbol(),
"workflowStatus", Status.Active.getKey()));
"workflowStatus", WorkflowStatus.Active.getKey()));
if (object != null) {
return of(errorEnum);
} else {

View file

@ -88,6 +88,47 @@ public class MoneyMarketSecurityServiceTest extends AbstractServiceTest {
LISTING_MATCHER.assertMatch(listingResult, listingPrediction);
}
// @Test todo тест с проверкой валидатора
// public void testNewMoneyMarketSecurity2() {
// clearAllInImdg(moneyMarketSecurityMap);
// final String TOPIC = Consts.DESTINATION_MONEY_MARKET_SECURITY_NEW;
//
// final MoneyMarketSecurity moneyMarketSecurityPrediction = moneyMarketSecurityFactory
// .getMoneyMarketSecurity();
// final MoneyMarketSecurityNewRequest keyRequest = moneyMarketSecurityFactory
// .getMoneyMarketSecurityNewRequest();
// Listing listingPrediction = ListingBuilder.builder()
// .append(moneyMarketSecurityPrediction).append(keyRequest).build();
//
// // Создание копии инструмента - не должен задублировать его
// MoneyMarketSecurity existMMS = new MoneyMarketSecurity();
// existMMS.setId(123L);
// existMMS.setSecuritySymbol(keyRequest.getSecuritySymbol());
// existMMS.setWorkflowStatus(WorkflowStatus.Active.getKey());
// moneyMarketSecurityMap.insert(existMMS);
//
// //ACT
// String jsonString = getJsonStringForNew(keyRequest, ID);
//
// addRecordToKafka((MockConsumer) moneyMarketSecurityService.getConsumer(), TOPIC, PARTITION, 0, jsonString);
//
// //ASSERT
// waitingWhenTryAddRecordAndCheckError(ID, mockProducer,
// "1010" //SecuritiesError.InstrumentAlreadyExists
// , Arrays.asList(""));
// waitingSendAndCheckRecord(ID, mockProducer);
//
// MoneyMarketSecurity moneyMarketSecurityResult = moneyMarketSecurityMap.getSingleObjectBySQL(String.format("fullName = %s", moneyMarketSecurityFactory.getFullName()));
// moneyMarketSecurityPrediction.setId(moneyMarketSecurityResult.getId());
// moneyMarketSecurityPrediction.setSecurityId(moneyMarketSecurityResult.getSecurityId());
// MONEY_MARKET_SECURITY_MATCHER.assertMatch(moneyMarketSecurityResult, moneyMarketSecurityPrediction);
//
// Listing listingResult = listingImdg.getSingleObjectByFieldValues(Map.of("securityId", moneyMarketSecurityPrediction.getId()));
// listingPrediction.setId(listingResult.getId());
// listingPrediction.setSecurityId(listingResult.getSecurityId());
// LISTING_MATCHER.assertMatch(listingResult, listingPrediction);
// }
/**
* {@link MoneyMarketSecurityService#deleteMoneyMarket(BaseRequest)}<br>
* Тест проверяет удаление сущности {@link MoneyMarketSecurity} в Hazelcast при передаче из Apache Kafka.<br>