updateProfileDocument
This commit is contained in:
parent
30485d7104
commit
adf57e7b00
5 changed files with 207 additions and 9 deletions
|
|
@ -48,8 +48,8 @@ public record DictionaryPresentRule<R, D extends AbstractDictionary>(String fiel
|
||||||
getter,
|
getter,
|
||||||
dictionaryName,
|
dictionaryName,
|
||||||
dictionaryClass,
|
dictionaryClass,
|
||||||
errorWrongDictionaryValue,
|
|
||||||
errorEmptyRequiredValue,
|
errorEmptyRequiredValue,
|
||||||
|
errorWrongDictionaryValue,
|
||||||
required);
|
required);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ public class ClearingMemberCategoryValidationConfig {
|
||||||
EnumPresentRule.instance("clearingMemberCategory",
|
EnumPresentRule.instance("clearingMemberCategory",
|
||||||
ClearingMemberCategoryUpdateRequest::getClearingMemberCategory,
|
ClearingMemberCategoryUpdateRequest::getClearingMemberCategory,
|
||||||
ClearingCategory.values(),
|
ClearingCategory.values(),
|
||||||
|
false,
|
||||||
CompanyErrors.WrongFieldValue,
|
CompanyErrors.WrongFieldValue,
|
||||||
CompanyErrors.RequiredFieldEmpty),
|
CompanyErrors.RequiredFieldEmpty),
|
||||||
DictionaryPresentRule.instance("clearingMemberCategory",
|
DictionaryPresentRule.instance("clearingMemberCategory",
|
||||||
|
|
@ -91,7 +92,8 @@ public class ClearingMemberCategoryValidationConfig {
|
||||||
IMDGDistributedNames.Map_ClearingCategoryDictionary,
|
IMDGDistributedNames.Map_ClearingCategoryDictionary,
|
||||||
ClearingCategoryDictionary.class,
|
ClearingCategoryDictionary.class,
|
||||||
CompanyErrors.RequiredFieldEmpty,
|
CompanyErrors.RequiredFieldEmpty,
|
||||||
CompanyErrors.WrongFieldValue));
|
CompanyErrors.WrongFieldValue,
|
||||||
|
false));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,12 @@ package ru.spcex.clearing.company.config.validation;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import ru.clearing.classes.statics.data.company.Company;
|
import ru.clearing.classes.statics.data.company.Company;
|
||||||
|
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||||
import ru.clearing.platform.dictionary.DocumentTypeDictionary;
|
import ru.clearing.platform.dictionary.DocumentTypeDictionary;
|
||||||
import ru.spcex.clearing.company.error.CompanyErrors;
|
import ru.spcex.clearing.company.error.CompanyErrors;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentNewRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentNewRequest;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentUpdateRequest;
|
||||||
import ru.spcex.clearing.validation.common.rules.*;
|
import ru.spcex.clearing.validation.common.rules.*;
|
||||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||||
import ru.spcex.platform.enumeration.DocumentTypes;
|
import ru.spcex.platform.enumeration.DocumentTypes;
|
||||||
|
|
@ -79,4 +81,53 @@ public class ProfileDocumentValidationConfig {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean("profileDocumentUpdateRequestValidation")
|
||||||
|
public Function<ProfileDocumentUpdateRequest, IValidator> profileDocumentUpdateRequestValidator(
|
||||||
|
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||||
|
) {
|
||||||
|
return profileDocumentUpdateRequest -> {
|
||||||
|
ImdgValidationContext<ProfileDocumentUpdateRequest> context = new ImdgValidationContext<>();
|
||||||
|
context.setValidatedObject(profileDocumentUpdateRequest);
|
||||||
|
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||||
|
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||||
|
addImdg.accept(IMDGDistributedNames.Map_DocumentTypeDictionary);
|
||||||
|
addImdg.accept(IMDGDistributedNames.Map_ProfileDocument);
|
||||||
|
return new ValidatorImpl<>(context,
|
||||||
|
IdPresentRule.instance("id",
|
||||||
|
ProfileDocumentUpdateRequest::getId,
|
||||||
|
IMDGDistributedNames.Map_ProfileDocument,
|
||||||
|
ProfileDocument.class,
|
||||||
|
CompanyErrors.RequiredFieldEmpty,
|
||||||
|
CompanyErrors.RecordNotFound),
|
||||||
|
IdPresentRule.instance("companyId",
|
||||||
|
ProfileDocumentUpdateRequest::getCompanyId,
|
||||||
|
IMDGDistributedNames.Map_Company,
|
||||||
|
Company.class,
|
||||||
|
CompanyErrors.RequiredFieldEmpty,
|
||||||
|
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,
|
||||||
|
DocumentTypeDictionary.class,
|
||||||
|
CompanyErrors.RequiredFieldEmpty,
|
||||||
|
CompanyErrors.WrongFieldValue,
|
||||||
|
false),
|
||||||
|
EndDtAfterStartDtRule.instance("validFromDate", "validToDate",
|
||||||
|
ProfileDocumentUpdateRequest::getValidFromDate,
|
||||||
|
ProfileDocumentUpdateRequest::getValidToDate,
|
||||||
|
CompanyErrors.RequiredFieldEmpty,
|
||||||
|
CompanyErrors.WrongFieldValue,
|
||||||
|
false)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentNewRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentNewRequest;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentUpdateRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||||
import ru.spcex.platform.enumeration.DocumentTypes;
|
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
import ru.spcex.platform.utils.validation.IValidator;
|
import ru.spcex.platform.utils.validation.IValidator;
|
||||||
|
|
@ -35,6 +35,7 @@ public class ProfileDocumentService extends QueueConsumer implements Initializin
|
||||||
private KafkaSender kafkaReqProducer;
|
private KafkaSender kafkaReqProducer;
|
||||||
|
|
||||||
private final Function<ProfileDocumentNewRequest, IValidator> profileDocumentNewRequestValidator;
|
private final Function<ProfileDocumentNewRequest, IValidator> profileDocumentNewRequestValidator;
|
||||||
|
private final Function<ProfileDocumentUpdateRequest, IValidator> profileDocumentUpdateRequestValidator;
|
||||||
private final ValidationHelper validationHelper;
|
private final ValidationHelper validationHelper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -43,11 +44,13 @@ public class ProfileDocumentService extends QueueConsumer implements Initializin
|
||||||
KafkaSender kafkaReqProducer,
|
KafkaSender kafkaReqProducer,
|
||||||
ImdgProvider imdgProvider,
|
ImdgProvider imdgProvider,
|
||||||
@Qualifier("profileDocumentNewRequestValidation") Function<ProfileDocumentNewRequest, IValidator> profileDocumentNewRequestValidator,
|
@Qualifier("profileDocumentNewRequestValidation") Function<ProfileDocumentNewRequest, IValidator> profileDocumentNewRequestValidator,
|
||||||
|
@Qualifier("profileDocumentUpdateRequestValidation") Function<ProfileDocumentUpdateRequest, IValidator> profileDocumentUpdateRequestValidator,
|
||||||
ValidationHelper validationHelper) {
|
ValidationHelper validationHelper) {
|
||||||
super(kafkaQueue, kafkaProducer);
|
super(kafkaQueue, kafkaProducer);
|
||||||
this.imdgProvider = imdgProvider;
|
this.imdgProvider = imdgProvider;
|
||||||
this.kafkaReqProducer = kafkaReqProducer;
|
this.kafkaReqProducer = kafkaReqProducer;
|
||||||
this.profileDocumentNewRequestValidator = profileDocumentNewRequestValidator;
|
this.profileDocumentNewRequestValidator = profileDocumentNewRequestValidator;
|
||||||
|
this.profileDocumentUpdateRequestValidator = profileDocumentUpdateRequestValidator;
|
||||||
this.validationHelper = validationHelper;
|
this.validationHelper = validationHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,6 +62,9 @@ public class ProfileDocumentService extends QueueConsumer implements Initializin
|
||||||
callback(ProfileDocumentNewRequest.class)
|
callback(ProfileDocumentNewRequest.class)
|
||||||
.setConsumer(this::profileDocumentNew)
|
.setConsumer(this::profileDocumentNew)
|
||||||
.forDestination(Consts.DESTINATION_PROFILE_DOCUMENT_NEW, callbacks::put);
|
.forDestination(Consts.DESTINATION_PROFILE_DOCUMENT_NEW, callbacks::put);
|
||||||
|
callback(ProfileDocumentUpdateRequest.class)
|
||||||
|
.setConsumer(this::profileDocumentUpdate)
|
||||||
|
.forDestination(Consts.DESTINATION_PROFILE_DOCUMENT_UPDATE, callbacks::put);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,9 +94,71 @@ public class ProfileDocumentService extends QueueConsumer implements Initializin
|
||||||
profileDocument.setLink(profileDocumentNewRequest.getLink());
|
profileDocument.setLink(profileDocumentNewRequest.getLink());
|
||||||
profileDocumentMap.insert(profileDocument);
|
profileDocumentMap.insert(profileDocument);
|
||||||
|
|
||||||
if (profileDocument.getDocumentType().equalsIgnoreCase(DocumentTypes.xcnt.getKey())) {
|
// if (profileDocument.getDocumentType().equalsIgnoreCase(DocumentTypes.xcnt.getKey())) {
|
||||||
// kafkaReqProducer.sendRequestToQueue(Consts.EXPORT_PROCESS, exportRequest);
|
// todo create request for update and check request for new account (something wrong)
|
||||||
}
|
// kafkaReqProducer.sendRequestToQueue(Consts.ACCOUNT_UPDATE, )
|
||||||
|
// }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private RequestInfoUpdate profileDocumentUpdate(BaseRequest<ProfileDocumentUpdateRequest> profileDocumentUpdateRequestBaseRequest) {
|
||||||
|
log.trace("Start processing ProfileDocumentUpdateRequest!");
|
||||||
|
|
||||||
|
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(
|
||||||
|
profileDocumentUpdateRequestBaseRequest,
|
||||||
|
profileDocumentUpdateRequestValidator
|
||||||
|
);
|
||||||
|
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||||
|
|
||||||
|
ProfileDocumentUpdateRequest profileDocumentUpdateRequest = profileDocumentUpdateRequestBaseRequest.getRequestPayload();
|
||||||
|
ProfileDocument profileDocument = profileDocumentMap.getSingleObjectByID(profileDocumentUpdateRequest.getId());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getCompanyId() != null)
|
||||||
|
profileDocument.setCompanyId(profileDocumentUpdateRequest.getCompanyId());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getDocumentType() != null)
|
||||||
|
profileDocument.setDocumentType(profileDocumentUpdateRequest.getDocumentType());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getIssueDate() != null)
|
||||||
|
profileDocument.setIssueDate(profileDocumentUpdateRequest.getIssueDate());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getIssuePlace() != null)
|
||||||
|
profileDocument.setIssuePlace(profileDocumentUpdateRequest.getIssuePlace());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getIssuer() != null)
|
||||||
|
profileDocument.setIssuer(profileDocumentUpdateRequest.getIssuer());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getIssuerCode() != null)
|
||||||
|
profileDocument.setIssuerCode(profileDocumentUpdateRequest.getIssuerCode());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getName() != null)
|
||||||
|
profileDocument.setName(profileDocumentUpdateRequest.getName());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getNumber() != null)
|
||||||
|
profileDocument.setNumber(profileDocumentUpdateRequest.getNumber());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getPlace() != null)
|
||||||
|
profileDocument.setPlace(profileDocumentUpdateRequest.getPlace());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getValidFromDate() != null)
|
||||||
|
profileDocument.setValidFromDate(profileDocumentUpdateRequest.getValidFromDate());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getValidToDate() != null)
|
||||||
|
profileDocument.setValidToDate(profileDocumentUpdateRequest.getValidToDate());
|
||||||
|
|
||||||
|
if (profileDocumentUpdateRequest.getLink() != null)
|
||||||
|
profileDocument.setLink(profileDocumentUpdateRequest.getLink());
|
||||||
|
|
||||||
|
profileDocumentMap.insert(profileDocument);
|
||||||
|
|
||||||
|
log.trace("successfully processed, id {}", profileDocument.getId());
|
||||||
|
|
||||||
|
// if (profileDocument.getDocumentType().equalsIgnoreCase(DocumentTypes.xcnt.getKey())) {
|
||||||
|
// todo if update profileDocument with documentType == XCNT... need send?
|
||||||
|
// kafkaReqProducer.sendRequestToQueue(Consts.ACCOUNT_UPDATE, )
|
||||||
|
// }
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentNewRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentNewRequest;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentUpdateRequest;
|
||||||
import ru.spcex.platform.enumeration.DocumentTypes;
|
import ru.spcex.platform.enumeration.DocumentTypes;
|
||||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
|
|
@ -51,6 +52,8 @@ class ProfileDocumentServiceTest {
|
||||||
public static final MatcherFactory.Matcher<ProfileDocument> PROFILE_DOCUMENT_MATCHER = usingIgnoringFieldsComparator();
|
public static final MatcherFactory.Matcher<ProfileDocument> PROFILE_DOCUMENT_MATCHER = usingIgnoringFieldsComparator();
|
||||||
private static final int PARTITION = 0;
|
private static final int PARTITION = 0;
|
||||||
private static final String TOPIC_DESTINATION_PROFILE_DOCUMENT_NEW = Consts.DESTINATION_PROFILE_DOCUMENT_NEW;
|
private static final String TOPIC_DESTINATION_PROFILE_DOCUMENT_NEW = Consts.DESTINATION_PROFILE_DOCUMENT_NEW;
|
||||||
|
private static final String TOPIC_DESTINATION_PROFILE_DOCUMENT_UPDATE = Consts.DESTINATION_PROFILE_DOCUMENT_UPDATE;
|
||||||
|
|
||||||
private static final Long ID = currentID.getAndIncrement();
|
private static final Long ID = currentID.getAndIncrement();
|
||||||
@Autowired
|
@Autowired
|
||||||
ProfileDocumentService profileDocumentService;
|
ProfileDocumentService profileDocumentService;
|
||||||
|
|
@ -71,6 +74,11 @@ class ProfileDocumentServiceTest {
|
||||||
private DocumentTypes TEST_DOCUMENT_TYPE = DocumentTypes.cio;
|
private DocumentTypes TEST_DOCUMENT_TYPE = DocumentTypes.cio;
|
||||||
private String TEST_DOCUMENT_TYPE_ID = TEST_DOCUMENT_TYPE.getKey();
|
private String TEST_DOCUMENT_TYPE_ID = TEST_DOCUMENT_TYPE.getKey();
|
||||||
|
|
||||||
|
private DocumentTypes NEW_TEST_DOCUMENT_TYPE = DocumentTypes.edoc;
|
||||||
|
private String NEW_TEST_DOCUMENT_TYPE_ID = NEW_TEST_DOCUMENT_TYPE.getKey();
|
||||||
|
|
||||||
|
private final long PROFILE_DOCUMENT_ID = ID;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void init() {
|
private void init() {
|
||||||
hazelcastServiceTest.waitAvailable();
|
hazelcastServiceTest.waitAvailable();
|
||||||
|
|
@ -82,15 +90,22 @@ class ProfileDocumentServiceTest {
|
||||||
TEST_COMPANY.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
TEST_COMPANY.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||||
companyMap.insert(TEST_COMPANY);
|
companyMap.insert(TEST_COMPANY);
|
||||||
|
|
||||||
DocumentTypeDictionary documentTypeDictionary = new DocumentTypeDictionary();
|
|
||||||
documentTypeDictionary.setCode(TEST_DOCUMENT_TYPE.getKey());
|
|
||||||
documentTypeDictionary.setName("test_name");
|
|
||||||
Imdg<DocumentTypeDictionary> documentTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
Imdg<DocumentTypeDictionary> documentTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||||
IMDGDistributedNames.Map_DocumentTypeDictionary,
|
IMDGDistributedNames.Map_DocumentTypeDictionary,
|
||||||
DocumentTypeDictionary.class
|
DocumentTypeDictionary.class
|
||||||
);
|
);
|
||||||
|
|
||||||
|
DocumentTypeDictionary documentTypeDictionary = new DocumentTypeDictionary();
|
||||||
|
documentTypeDictionary.setCode(TEST_DOCUMENT_TYPE.getKey());
|
||||||
|
documentTypeDictionary.setName("test_name");
|
||||||
documentTypeDictionaryImdg.insert(documentTypeDictionary);
|
documentTypeDictionaryImdg.insert(documentTypeDictionary);
|
||||||
|
|
||||||
|
DocumentTypeDictionary documentTypeDictionary1 = new DocumentTypeDictionary();
|
||||||
|
documentTypeDictionary1.setCode(NEW_TEST_DOCUMENT_TYPE.getKey());
|
||||||
|
documentTypeDictionary1.setName("new_test_name");
|
||||||
|
documentTypeDictionaryImdg.insert(documentTypeDictionary1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -116,6 +131,7 @@ class ProfileDocumentServiceTest {
|
||||||
profileDocumentNewRequest.setLink("link");
|
profileDocumentNewRequest.setLink("link");
|
||||||
|
|
||||||
ProfileDocument predictableProfileDocument = new ProfileDocument();
|
ProfileDocument predictableProfileDocument = new ProfileDocument();
|
||||||
|
predictableProfileDocument.setId(PROFILE_DOCUMENT_ID);
|
||||||
predictableProfileDocument.setCompanyId(profileDocumentNewRequest.getCompanyId());
|
predictableProfileDocument.setCompanyId(profileDocumentNewRequest.getCompanyId());
|
||||||
predictableProfileDocument.setDocumentType(profileDocumentNewRequest.getDocumentType());
|
predictableProfileDocument.setDocumentType(profileDocumentNewRequest.getDocumentType());
|
||||||
predictableProfileDocument.setIssueDate(profileDocumentNewRequest.getIssueDate());
|
predictableProfileDocument.setIssueDate(profileDocumentNewRequest.getIssueDate());
|
||||||
|
|
@ -140,4 +156,65 @@ class ProfileDocumentServiceTest {
|
||||||
predictableProfileDocument.setId(resultNew.getId());
|
predictableProfileDocument.setId(resultNew.getId());
|
||||||
PROFILE_DOCUMENT_MATCHER.assertMatch(resultNew, predictableProfileDocument);
|
PROFILE_DOCUMENT_MATCHER.assertMatch(resultNew, predictableProfileDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void updateProfileDocument() {
|
||||||
|
//ARRANGE
|
||||||
|
ProfileDocument existsProfileDocument = new ProfileDocument();
|
||||||
|
existsProfileDocument.setId(ID);
|
||||||
|
existsProfileDocument.setCompanyId(COMPANY_ID);
|
||||||
|
existsProfileDocument.setDocumentType(TEST_DOCUMENT_TYPE_ID);
|
||||||
|
existsProfileDocument.setIssueDate(LocalDate.now());
|
||||||
|
existsProfileDocument.setIssuePlace("place");
|
||||||
|
existsProfileDocument.setIssuer("issuer");
|
||||||
|
existsProfileDocument.setIssuerCode("issuerCode");
|
||||||
|
existsProfileDocument.setName("name");
|
||||||
|
existsProfileDocument.setNumber("number");
|
||||||
|
existsProfileDocument.setPlace("place");
|
||||||
|
existsProfileDocument.setValidFromDate(LocalDate.now());
|
||||||
|
existsProfileDocument.setValidToDate(LocalDate.now().plus(1, ChronoUnit.DAYS));
|
||||||
|
existsProfileDocument.setLink("link");
|
||||||
|
profileDocumentMap.insert(existsProfileDocument);
|
||||||
|
|
||||||
|
ProfileDocument predictableProfileDocument = new ProfileDocument();
|
||||||
|
predictableProfileDocument.setId(PROFILE_DOCUMENT_ID);
|
||||||
|
predictableProfileDocument.setCompanyId(COMPANY_ID);
|
||||||
|
predictableProfileDocument.setDocumentType(NEW_TEST_DOCUMENT_TYPE_ID);
|
||||||
|
predictableProfileDocument.setIssueDate(LocalDate.now());
|
||||||
|
predictableProfileDocument.setIssuePlace("new_place");
|
||||||
|
predictableProfileDocument.setIssuer("new_issuer");
|
||||||
|
predictableProfileDocument.setIssuerCode("new_issuerCode");
|
||||||
|
predictableProfileDocument.setName("new_name");
|
||||||
|
predictableProfileDocument.setNumber("new_number");
|
||||||
|
predictableProfileDocument.setPlace("new_place");
|
||||||
|
predictableProfileDocument.setValidFromDate(LocalDate.now());
|
||||||
|
predictableProfileDocument.setValidToDate(LocalDate.now().plus(1, ChronoUnit.DAYS));
|
||||||
|
predictableProfileDocument.setLink("new_link");
|
||||||
|
|
||||||
|
ProfileDocumentUpdateRequest profileDocumentUpdateRequest = new ProfileDocumentUpdateRequest();
|
||||||
|
profileDocumentUpdateRequest.setId(PROFILE_DOCUMENT_ID);
|
||||||
|
profileDocumentUpdateRequest.setCompanyId(COMPANY_ID);
|
||||||
|
profileDocumentUpdateRequest.setDocumentType(NEW_TEST_DOCUMENT_TYPE_ID);
|
||||||
|
profileDocumentUpdateRequest.setIssueDate(LocalDate.now());
|
||||||
|
profileDocumentUpdateRequest.setIssuePlace("new_place");
|
||||||
|
profileDocumentUpdateRequest.setIssuer("new_issuer");
|
||||||
|
profileDocumentUpdateRequest.setIssuerCode("new_issuerCode");
|
||||||
|
profileDocumentUpdateRequest.setName("new_name");
|
||||||
|
profileDocumentUpdateRequest.setNumber("new_number");
|
||||||
|
profileDocumentUpdateRequest.setPlace("new_place");
|
||||||
|
profileDocumentUpdateRequest.setValidFromDate(LocalDate.now());
|
||||||
|
profileDocumentUpdateRequest.setValidToDate(LocalDate.now().plus(1, ChronoUnit.DAYS));
|
||||||
|
profileDocumentUpdateRequest.setLink("new_link");
|
||||||
|
|
||||||
|
//ACT
|
||||||
|
String jsonString = getJsonStringForUPDATE(profileDocumentUpdateRequest, ID);
|
||||||
|
|
||||||
|
addRecordToKafka((MockConsumer) profileDocumentService.getConsumer(), TOPIC_DESTINATION_PROFILE_DOCUMENT_UPDATE, PARTITION, 0, jsonString);
|
||||||
|
|
||||||
|
//ASSERT
|
||||||
|
waitingWhenAddedRecordAndCheckIt(ID, mockProducer, producerRecord);
|
||||||
|
ProfileDocument resultUpdate = profileDocumentMap.getSingleObjectBySQL(String.format("companyId = %d", COMPANY_ID));
|
||||||
|
// predictableProfileDocument.setId(resultUpdate.getId());
|
||||||
|
PROFILE_DOCUMENT_MATCHER.assertMatch(resultUpdate, predictableProfileDocument);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue