Fixing test for backend-api.

This commit is contained in:
psemenkov 2023-02-16 10:13:43 +03:00
parent 71de170b00
commit 4345254674
12 changed files with 138 additions and 56 deletions

View file

@ -29,8 +29,10 @@ import ru.spcex.clearing.backendapi.controller.queue.payment.PaymentInstructionC
import ru.spcex.clearing.backendapi.controller.queue.scheduler.ClearingCalendarController;
import ru.spcex.clearing.backendapi.controller.queue.scheduler.LauncherController;
import ru.spcex.clearing.backendapi.controller.queue.scheduler.PlannerAllTodayController;
import ru.spcex.clearing.backendapi.controller.queue.scheduler.PlannerController;
import ru.spcex.clearing.backendapi.controller.utils.MatcherFactory;
import ru.spcex.clearing.backendapi.controller.utils.TestUtils;
import ru.spcex.clearing.backendapi.domain.actions.IAction;
import ru.spcex.clearing.backendapi.meta.GetResponseFactory;
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
@ -38,6 +40,7 @@ import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
import javax.annotation.PostConstruct;
import java.util.concurrent.atomic.AtomicLong;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static ru.spcex.clearing.backendapi.controller.utils.MatcherFactory.usingIgnoringFieldsComparator;
@ -64,7 +67,8 @@ import static ru.spcex.clearing.backendapi.controller.utils.MatcherFactory.using
PaymentInstructionController.class,
//scheduler
ClearingCalendarController.class,
PlannerAllTodayController.class,//PlanerAllTodayController
PlannerAllTodayController.class,
PlannerController.class,
LauncherController.class,
//******* common configs *******
WebTestConfig.class,
@ -116,4 +120,14 @@ public abstract class AbstractControllerTest {
protected ResultActions perform(MockHttpServletRequestBuilder builder) throws Exception {
return mockMvc.perform(builder);
}
protected void checkSendedMessegeFromKafka(String topic, IAction action) {
BaseRequest<Object> predictableBaseRequest = new BaseRequest<>();
predictableBaseRequest.setActionType(action.getActionType());
predictableBaseRequest.setRequestPayload(action.toRequest());
assertEquals(topic, producerRecord.getValue().topic());
BaseRequest<Object> baseRequestResult = (BaseRequest<Object>) producerRecord.getValue().value();
predictableBaseRequest.setId(baseRequestResult.getId());
BASE_REQUEST_MATCHER.assertMatch(baseRequestResult, predictableBaseRequest);
}
}

View file

@ -9,6 +9,7 @@ import ru.clearing.classes.statics.data.account.BankAccount;
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
import ru.spcex.clearing.backendapi.controller.request.cud.account.BankAccountNewAction;
import ru.spcex.clearing.backendapi.controller.request.cud.account.BankAccountUpdateAction;
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
import ru.spcex.clearing.backendapi.controller.response.cud.QueueSuccessResponse;
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
@ -18,7 +19,9 @@ import ru.spcex.clearing.backendapi.domain.actions.IAction;
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.ActionType;
import ru.spcex.clearing.platform.messaging.domain.Consts;
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
import ru.spcex.platform.imdg.api.Imdg;
import java.util.Collection;
import java.util.Map;
@ -50,7 +53,7 @@ class BankAccountControllerTest extends AbstractControllerTest {
void add() throws Exception {
//ARRANGE
BankAccountNewAction bankAccountNewAction = getBankAccountNewAction(
"044525776",
0, "044525776",
"Beta Money Bank",
"30101111111111111776",
"correspondent",
@ -73,6 +76,7 @@ class BankAccountControllerTest extends AbstractControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_BANK_ACCOUNT_NEW, bankAccountNewAction);
}
/**
@ -91,15 +95,15 @@ class BankAccountControllerTest extends AbstractControllerTest {
*/
@Test
void addWithException() {
assertThrowsFor(getBankAccountNewAction("", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction("044525776", "", "30101111111111111776", "correspondent", "RUB", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction("044525776", "Beta Money Bank", "", "correspondent", "RUB", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction("044525776", "Beta Money Bank", "30101111111111111776", "", "RUB", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction("044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction("044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction("044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "destination", "", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction("044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "destination", "3664011397", "", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction("044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "destination", "3664011397", "01", ""));
assertThrowsFor(getBankAccountNewAction(0, "", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction(0, "044525776", "", "30101111111111111776", "correspondent", "RUB", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction(0, "044525776", "Beta Money Bank", "", "correspondent", "RUB", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction(0, "044525776", "Beta Money Bank", "30101111111111111776", "", "RUB", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction(0, "044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "", "destination", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction(0, "044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "", "3664011397", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction(0, "044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "destination", "", "01", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction(0, "044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "destination", "3664011397", "", "11111222223333344444"));
assertThrowsFor(getBankAccountNewAction(0, "044525776", "Beta Money Bank", "30101111111111111776", "correspondent", "RUB", "destination", "3664011397", "01", ""));
}
/**
@ -118,7 +122,9 @@ class BankAccountControllerTest extends AbstractControllerTest {
@Test
void update() throws Exception {
//ARRANGE
BankAccountUpdateAction bankAccountNewAction = getBankAccountUpdateAction(
long id = 0;
BankAccountUpdateAction bankAccountUpdateAction = getBankAccountUpdateAction(
id,
"044525776",
"Beta Money Bank",
"30101111111111111776",
@ -134,14 +140,15 @@ class BankAccountControllerTest extends AbstractControllerTest {
expected.setMessage("success");
expected.setPayload(new QueueSuccessResponse(ActionType.UPDATE, currentId.getAndIncrement()));
//ACT
perform(MockMvcRequestBuilders.put(REST_URL + "0")
perform(MockMvcRequestBuilders.put(REST_URL + id)
.contentType(MediaType.APPLICATION_JSON)
.content(writeValue(bankAccountNewAction)))
.content(writeValue(bankAccountUpdateAction)))
.andDo(print())//output to the log request and response
// ASSERT
//ASSERT
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_BANK_ACCOUNT_UPDATE, bankAccountUpdateAction);
}
/**
@ -152,18 +159,22 @@ class BankAccountControllerTest extends AbstractControllerTest {
@Test
void delete() throws Exception {
//ARRANGE
long id = 0;
CudResponse expected = new CudResponse();
expected.setCode(0L);
expected.setMessage("success");
expected.setPayload(new QueueSuccessResponse(ActionType.DELETE, currentId.getAndIncrement()));
CommonDeleteAction deleteAction = new CommonDeleteAction();
deleteAction.setId(id);
//ACT
perform(MockMvcRequestBuilders.delete(REST_URL + "0")
perform(MockMvcRequestBuilders.delete(REST_URL + id)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())//output to the log request and response
//ASSERT
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_BANK_ACCOUNT_DELETE, deleteAction);
}
/**
@ -231,10 +242,10 @@ class BankAccountControllerTest extends AbstractControllerTest {
existBankAccount.setTaxRegistrationReasonCode("886886");
existBankAccount.setId(currentId.get());
IMap<Long, BankAccount> iMap = hazelcastServiceTest.getHazelcast().getMap(IMDGDistributedNames.Map_BankAccount);
iMap.put(existBankAccount.getId(), existBankAccount);
Imdg<BankAccount> bankAccountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
bankAccountImdg.insert(existBankAccount);
Collection<BankAccount> values = iMap.values();
Collection<BankAccount> values = bankAccountImdg.getAllValues();
Collection<Map<String, Object>> all = responseFactory.responseFromObjectCollection(values);
CommonGetAllResponse expected = new CommonGetAllResponse();
expected.fromEntity(all);
@ -259,7 +270,7 @@ class BankAccountControllerTest extends AbstractControllerTest {
});
}
private BankAccountNewAction getBankAccountNewAction(String BankIdentificationCode, String BankName, String CorrespondentAccount, String CorrespondentAccountName,
private BankAccountNewAction getBankAccountNewAction(long id, String BankIdentificationCode, String BankName, String CorrespondentAccount, String CorrespondentAccountName,
String Currency, String Destination, String TaxpayerIdentificationNumber, String TaxRegistrationReasonCode,
String Account) {
BankAccountNewAction bankAccountNewAction = new BankAccountNewAction();
@ -275,10 +286,11 @@ class BankAccountControllerTest extends AbstractControllerTest {
return bankAccountNewAction;
}
private BankAccountUpdateAction getBankAccountUpdateAction(String BankIdentificationCode, String BankName, String CorrespondentAccount, String CorrespondentAccountName,
private BankAccountUpdateAction getBankAccountUpdateAction(long id, String BankIdentificationCode, String BankName, String CorrespondentAccount, String CorrespondentAccountName,
String Currency, String Destination, String TaxpayerIdentificationNumber, String TaxRegistrationReasonCode,
String Account) {
BankAccountUpdateAction bankAccountUpdateAction = new BankAccountUpdateAction();
bankAccountUpdateAction.setId(id);
bankAccountUpdateAction.setBankIdentificationCode(BankIdentificationCode);
bankAccountUpdateAction.setBankName(BankName);
bankAccountUpdateAction.setCorrespondentAccount(CorrespondentAccount);

View file

@ -6,11 +6,13 @@ import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import ru.clearing.classes.statics.data.company.Company;
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
import ru.spcex.clearing.backendapi.controller.response.cud.QueueSuccessResponse;
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.ActionType;
import ru.spcex.clearing.platform.messaging.domain.Consts;
import java.util.Collection;
import java.util.Map;
@ -31,18 +33,22 @@ class DeleteCompanyControllerTest extends AbstractControllerTest {
@Test
void delete() throws Exception {
//ARRANGE
long id = 0;
CudResponse extended = new CudResponse();
extended.setCode(0L);
extended.setMessage("success");
extended.setPayload(new QueueSuccessResponse(ActionType.DELETE, currentId.getAndIncrement()));
CommonDeleteAction deleteAction = new CommonDeleteAction();
deleteAction.setId(id);
//ACT
perform(MockMvcRequestBuilders.delete(REST_URL + "0")
perform(MockMvcRequestBuilders.delete(REST_URL + id)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())//output to the log request and response
// ASSERT
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(extended)));
checkSendedMessegeFromKafka(Consts.DESTINATION_COMPANY_DELETE, deleteAction);
}
/**

View file

@ -7,6 +7,7 @@ import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import ru.clearing.classes.statics.data.generated.ClearingMemberCategory;
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
import ru.spcex.clearing.backendapi.controller.request.cud.company.ClearingMemberCategoryNewAction;
import ru.spcex.clearing.backendapi.controller.request.cud.company.ClearingMemberCategoryUpdateAction;
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
@ -16,6 +17,7 @@ import ru.spcex.clearing.backendapi.domain.actions.IAction;
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.ActionType;
import ru.spcex.clearing.platform.messaging.domain.Consts;
import java.util.Collection;
import java.util.Map;
@ -56,6 +58,7 @@ class EditClearingMemberCategoryControllerTest extends AbstractControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_CLEARING_MEMBER_CATEGORY_NEW, clearingMemberCategoryNewAction);
}
/**
@ -98,6 +101,7 @@ class EditClearingMemberCategoryControllerTest extends AbstractControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_CLEARING_MEMBER_CATEGORY_UPDATE, clearingMemberCategoryUpdateAction);
}
/**
@ -108,18 +112,22 @@ class EditClearingMemberCategoryControllerTest extends AbstractControllerTest {
@Test
void delete() throws Exception {
//ARRANGE
long id = currentId.getAndIncrement();
CudResponse expected = new CudResponse();
expected.setCode(0L);
expected.setMessage("success");
expected.setPayload(new QueueSuccessResponse(ActionType.DELETE, currentId.getAndIncrement()));
expected.setPayload(new QueueSuccessResponse(ActionType.DELETE, id));
CommonDeleteAction deleteAction = new CommonDeleteAction();
deleteAction.setId(id);
//ACT
perform(MockMvcRequestBuilders.delete(REST_URL + expected.getPayload().getId())
perform(MockMvcRequestBuilders.delete(REST_URL + id)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())//output to the log request and response
//ASSERT
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_CLEARING_MEMBER_CATEGORY_DELETE, deleteAction);
}
/**

View file

@ -4,14 +4,24 @@ import org.junit.jupiter.api.Test;
import org.springframework.core.NestedExceptionUtils;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import ru.clearing.classes.statics.data.company.Company;
import ru.clearing.classes.statics.data.profile.CompanyInfo;
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
import ru.spcex.clearing.backendapi.controller.request.cud.company.ClearingMemberCategoryNewAction;
import ru.spcex.clearing.backendapi.controller.request.cud.company.CompanyInfoUpdateAction;
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
import ru.spcex.clearing.backendapi.controller.response.cud.QueueSuccessResponse;
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
import ru.spcex.clearing.backendapi.domain.actions.IAction;
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.ActionType;
import ru.spcex.clearing.platform.messaging.domain.Consts;
import ru.spcex.platform.imdg.api.Imdg;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
@ -39,9 +49,6 @@ class EditCompanyInfoControllerTest extends AbstractControllerTest {
* {@link CompanyInfoUpdateAction#fullNameEng} - exists fullNameEng<br>
* {@link CompanyInfoUpdateAction#shortName} - exists shortName<br>
* {@link CompanyInfoUpdateAction#fullName} - exists fullName<br>
* {@link CompanyInfoUpdateAction- Category<br>
* {@link CompanyInfoUpdateAction- Category<br>
* {@link CompanyInfoUpdateAction- Category<br>
* {@link CompanyInfoUpdateAction#id} - currentId<br>
*/
// @Test валидации пока нет
@ -67,9 +74,6 @@ class EditCompanyInfoControllerTest extends AbstractControllerTest {
* {@link CompanyInfoUpdateAction#fullNameEng} - exists fullNameEng<br>
* {@link CompanyInfoUpdateAction#shortName} - exists shortName<br>
* {@link CompanyInfoUpdateAction#fullName} - exists fullName<br>
* {@link CompanyInfoUpdateAction- Category<br>
* {@link CompanyInfoUpdateAction- Category<br>
* {@link CompanyInfoUpdateAction- Category<br>
* {@link CompanyInfoUpdateAction#id} - currentId<br>
*/
@Test
@ -104,6 +108,57 @@ class EditCompanyInfoControllerTest extends AbstractControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_COMPANY_INFO_UPDATE, companyInfoUpdateAction);
}
/**
* {@link EditCompanyInfoController#getAll()} <br>
* Тест проверяет получение запроса по REST API и отправку всех записей из таблицы hazelcast Map_Company.<br>
* Входной запрос /securities/bank-accounts/ <br>
* Ответ CommonGetAllResponse <br>
*/
@Test
void getAll() throws Exception {
//ARRANGE
Long ID = 0L;
CompanyInfo existsCompanyInfo = new CompanyInfo();
existsCompanyInfo.setId(ID);
existsCompanyInfo.setCompanyId(ID);
existsCompanyInfo.setCorporationSoleType("0000");
existsCompanyInfo.setCountryCode("0000");
existsCompanyInfo.setDescription("exists description");
existsCompanyInfo.setProfessionalSign("0000");
existsCompanyInfo.setLegalKind("0000");
existsCompanyInfo.setOrganizationType("0000");
existsCompanyInfo.setResidence("0000");
existsCompanyInfo.setShortNameEng("exists shortNameEng");
existsCompanyInfo.setFullNameEng("exists fullNameEng");
existsCompanyInfo.setShortName("exists shortName");
existsCompanyInfo.setFullName("exists fullName");
Company existsCompany = new Company();
existsCompany.setId(ID);
existsCompany.setProfile(existsCompanyInfo);
Imdg<Company> companyImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Company, Company.class);
companyImdg.insert(existsCompany);
Collection<Map<String, Object>> all = new ArrayList<>();
Collection<Company> companies = companyImdg.getAllValues();
for (Company company : companies) {
if (company.getProfile() != null && company.getProfile().getId() != null) { // пока возвращает "пустой" CompanyInfo если его нет для Company
all.add(responseFactory.responseFromObject(company.getProfile()));
}
}
CommonGetAllResponse expected = new CommonGetAllResponse();
expected.fromEntity(all);
//ACT
perform(MockMvcRequestBuilders.get(REST_URL)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())//output to the log request and response
//ASSERT
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
}
private void assertThrowsFor(IAction<?> iAction) {

View file

@ -16,6 +16,7 @@ import ru.spcex.clearing.backendapi.domain.actions.IAction;
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.ActionType;
import ru.spcex.clearing.platform.messaging.domain.Consts;
import java.util.Collection;
import java.util.Map;
@ -75,6 +76,7 @@ class EditCompanySymbolControllerTest extends AbstractControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_COMPANY_SYMBOL_UPDATE, companySymbolUpdateAction);
}
/**

View file

@ -17,6 +17,7 @@ import ru.spcex.clearing.backendapi.domain.actions.IAction;
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.ActionType;
import ru.spcex.clearing.platform.messaging.domain.Consts;
import java.util.Collection;
import java.util.Map;
@ -76,6 +77,7 @@ class EditContactControllerTest extends AbstractControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
checkSendedMessegeFromKafka(Consts.DESTINATION_CONTACT_UPDATE, companySymbolUpdateAction);
}
/**

View file

@ -7,8 +7,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import ru.clearing.classes.statics.data.account.BankAccount;
import ru.clearing.classes.statics.data.company.relation.Relation;
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
import ru.spcex.clearing.backendapi.controller.queue.account.BankAccountController;
import ru.spcex.clearing.backendapi.controller.request.cud.account.BankAccountUpdateAction;
import ru.spcex.clearing.backendapi.controller.request.cud.company.RelationUpdateAction;
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
import ru.spcex.clearing.backendapi.controller.response.cud.QueueSuccessResponse;
@ -17,14 +15,12 @@ import ru.spcex.clearing.backendapi.domain.actions.IAction;
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
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.platform.imdg.api.Imdg;
import java.util.Collection;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
@ -35,17 +31,10 @@ class RelationControllerTest extends AbstractControllerTest {
private static final String REST_URL = "/relations/";
/**
* {@link BankAccountController#update(Long, BankAccountUpdateAction)}<br>
* Тест проверяет получение сущности {@link BankAccountUpdateAction} по REST API и отправку в Apache Kafka.<br>
* Входной запрос {@link BankAccountUpdateAction}:<br>
* {@link BankAccountUpdateAction#bankIdentificationCode} - 044525776<br>
* {@link BankAccountUpdateAction#bankName} - Beta Money Bank<br>
* {@link BankAccountUpdateAction#correspondentAccount} - 30101111111111111776<br>
* {@link BankAccountUpdateAction#correspondentAccountName} - correspondent<br>
* {@link BankAccountUpdateAction#currency} - RUB<br>
* {@link BankAccountUpdateAction#destination} - destination<br>
* {@link BankAccountUpdateAction#taxpayerIdentificationNumber} - 3664011397<br>
* {@link BankAccountUpdateAction#taxRegistrationReasonCode} - 01<br>
* {@link RelationController#update(Long, RelationUpdateAction)}<br>
* Тест проверяет получение сущности {@link RelationUpdateAction} по REST API и отправку в Apache Kafka.<br>
* Входной запрос: id, {@link RelationUpdateAction}:<br>
* <br>
*/
@Test
void update() throws Exception {
@ -55,9 +44,6 @@ class RelationControllerTest extends AbstractControllerTest {
relationUpdateAction.setId(existsId);
relationUpdateAction.setServiceStatus("Ok");
relationUpdateAction.setComment("It`s good");
BaseRequest<Object> predictableBaseRequest = new BaseRequest<>();
predictableBaseRequest.setActionType(relationUpdateAction.getActionType());
predictableBaseRequest.setRequestPayload(relationUpdateAction.toRequest());
Relation relation = new Relation();
relation.setId(existsId);
@ -78,10 +64,7 @@ class RelationControllerTest extends AbstractControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(content().json(writeValue(expected)));
assertEquals(Consts.DESTINATION_RELATION_UPDATE, producerRecord.getValue().topic());
BaseRequest<Object> baseRequestResult = (BaseRequest<Object>) producerRecord.getValue().value();
predictableBaseRequest.setId(baseRequestResult.getId());
BASE_REQUEST_MATCHER.assertMatch(baseRequestResult, predictableBaseRequest);
checkSendedMessegeFromKafka(Consts.DESTINATION_RELATION_UPDATE, relationUpdateAction);
}
/**

View file

@ -20,7 +20,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static ru.spcex.clearing.backendapi.controller.utils.JsonUtil.writeValue;
class PaymentInstructionControllerTest extends AbstractControllerTest {
private static final String REST_URL = "/paymentInstructions/";
private static final String REST_URL = "/payment-instructions/";
/**
* {@link PaymentInstructionController#getAll()} <br>

View file

@ -38,7 +38,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static ru.spcex.clearing.backendapi.controller.utils.JsonUtil.writeValue;
class LauncherControllerTest extends AbstractControllerTest {
private static final String REST_URL = "/task-runners/";
private static final String REST_URL = "/launchers/";
/**
* {@link LauncherController#getAll()} <br>

View file

@ -20,7 +20,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static ru.spcex.clearing.backendapi.controller.utils.JsonUtil.writeValue;
class PlannerAllTodayControllerTest extends AbstractControllerTest {
private static final String REST_URL = "/schedule/schedulers-all-today/";
private static final String REST_URL = "/schedule/planners-all-today/";
/**
* {@link PlannerAllTodayController#getAll()} <br>

View file

@ -20,7 +20,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static ru.spcex.clearing.backendapi.controller.utils.JsonUtil.writeValue;
class PlannerControllerTest extends AbstractControllerTest {
private static final String REST_URL = "/schedule/schedulers/";
private static final String REST_URL = "/schedule/planners/";
/**
* {@link PlannerController#getAll()} <br>