backend-api http://jira.mfd.msk:8088/browse/CLS-270
This commit is contained in:
parent
670d21b13f
commit
849130f8b3
8 changed files with 640 additions and 0 deletions
|
|
@ -0,0 +1,84 @@
|
||||||
|
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import io.swagger.annotations.ApiResponse;
|
||||||
|
import io.swagger.annotations.ApiResponses;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import ru.clearing.classes.statics.data.account.ClientCode;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.request.cud.account.ClientCodeNewAction;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.request.cud.account.ClientCodeUpdateAction;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||||
|
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||||
|
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||||
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/accounting/client-codes")
|
||||||
|
public class ClientCodeController extends AbstractQueueController {
|
||||||
|
private final IStateLoader stateLoader;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ClientCodeController(IOperator operator, IStateLoader stateLoader) {
|
||||||
|
super(operator);
|
||||||
|
this.stateLoader = stateLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "create client code.")
|
||||||
|
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||||
|
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@ResponseBody
|
||||||
|
public CudResponse add(
|
||||||
|
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||||
|
@RequestBody ClientCodeNewAction clientCodeNewAction) throws ExecutionException, InterruptedException {
|
||||||
|
return processRequest(Consts.DESTINATION_CLIENT_CODE_NEW, clientCodeNewAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "update client-code.")
|
||||||
|
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||||
|
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@ResponseBody
|
||||||
|
public CudResponse update(
|
||||||
|
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||||
|
@PathVariable("id") Long id,
|
||||||
|
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||||
|
@RequestBody ClientCodeUpdateAction clientCodeUpdateAction) throws ExecutionException, InterruptedException {
|
||||||
|
clientCodeUpdateAction.setId(id);
|
||||||
|
return processRequest(Consts.DESTINATION_CLIENT_CODE_UPDATE, clientCodeUpdateAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "delete client code.")
|
||||||
|
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||||
|
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||||
|
@ResponseBody
|
||||||
|
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||||
|
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||||
|
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||||
|
deleteAction.setId(id);
|
||||||
|
return processRequest(Consts.DESTINATION_CLIENT_CODE_DELETE, deleteAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "get all client codes.")
|
||||||
|
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||||
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonGetAllResponse getAll() {
|
||||||
|
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_ClientCode, ClientCode.class);
|
||||||
|
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||||
|
response.fromEntity(all);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
package ru.spcex.clearing.backendapi.controller.request.cud.account;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||||
|
import ru.spcex.clearing.backendapi.errors.BackEndError;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest;
|
||||||
|
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ClientCodeNewAction implements IAction<ClientCodeNewRequest> {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "Наименование компании", example = "1200")
|
||||||
|
@JsonProperty
|
||||||
|
private Long companyId;
|
||||||
|
@ApiModelProperty(value = "Код клиента", example = "A301011111")
|
||||||
|
@JsonProperty
|
||||||
|
private String code;
|
||||||
|
@ApiModelProperty(value = "Торгово-клиринговый регистр", example = "1234")
|
||||||
|
@JsonProperty
|
||||||
|
private Long tradingClearingRegistryId;
|
||||||
|
@ApiModelProperty(value = "Номер денежного счета", example = "1234")
|
||||||
|
@JsonProperty
|
||||||
|
private Long moneyAccountId;
|
||||||
|
@ApiModelProperty(value = "Номер депозитарного счета", example = "1234")
|
||||||
|
@JsonProperty
|
||||||
|
private Long depoAccountId;
|
||||||
|
@ApiModelProperty(value = "Наименование статуса", example = "ACTV")
|
||||||
|
@JsonProperty
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<EnumMessage> validate() {
|
||||||
|
List<EnumMessage> errors = new ArrayList<>();
|
||||||
|
if (this.companyId == null)
|
||||||
|
errors.add(new EnumMessage(BackEndError.ValidationError, "companyId"));
|
||||||
|
if (!StringUtils.hasLength(this.code))
|
||||||
|
errors.add(new EnumMessage(BackEndError.ValidationError, "code"));
|
||||||
|
return errors.isEmpty() ? Collections.emptyList() : errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientCodeNewRequest toRequest() {
|
||||||
|
var req = new ClientCodeNewRequest();
|
||||||
|
req.setCompanyId(this.companyId);
|
||||||
|
req.setCode(this.code);
|
||||||
|
req.setTradingClearingRegistryId(this.tradingClearingRegistryId);
|
||||||
|
req.setMoneyAccountId(this.moneyAccountId);
|
||||||
|
req.setDepoAccountId(this.depoAccountId);
|
||||||
|
req.setStatus(this.status);
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(hidden = true)
|
||||||
|
@Override
|
||||||
|
public ActionType getActionType() {
|
||||||
|
return ActionType.NEW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCompanyId() {
|
||||||
|
return companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompanyId(Long companyId) {
|
||||||
|
this.companyId = companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTradingClearingRegistryId() {
|
||||||
|
return tradingClearingRegistryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTradingClearingRegistryId(Long tradingClearingRegistryId) {
|
||||||
|
this.tradingClearingRegistryId = tradingClearingRegistryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMoneyAccountId() {
|
||||||
|
return moneyAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoneyAccountId(Long moneyAccountId) {
|
||||||
|
this.moneyAccountId = moneyAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDepoAccountId() {
|
||||||
|
return depoAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDepoAccountId(Long depoAccountId) {
|
||||||
|
this.depoAccountId = depoAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
package ru.spcex.clearing.backendapi.controller.request.cud.account;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||||
|
import ru.spcex.clearing.backendapi.errors.BackEndError;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeUpdateRequest;
|
||||||
|
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ClientCodeUpdateAction implements IAction<ClientCodeUpdateRequest> {
|
||||||
|
@ApiModelProperty(hidden = true)
|
||||||
|
@JsonProperty
|
||||||
|
public Long id;
|
||||||
|
@ApiModelProperty(value = "Наименование компании", example = "1200")
|
||||||
|
@JsonProperty
|
||||||
|
private Long companyId;
|
||||||
|
@ApiModelProperty(value = "Код клиента", example = "A301011111")
|
||||||
|
@JsonProperty
|
||||||
|
private String code;
|
||||||
|
@ApiModelProperty(value = "Торгово-клиринговый регистр", example = "1234")
|
||||||
|
@JsonProperty
|
||||||
|
private Long tradingClearingRegistryId;
|
||||||
|
@ApiModelProperty(value = "Номер денежного счета", example = "1234")
|
||||||
|
@JsonProperty
|
||||||
|
private Long moneyAccountId;
|
||||||
|
@ApiModelProperty(value = "Номер депозитарного счета", example = "1234")
|
||||||
|
@JsonProperty
|
||||||
|
private Long depoAccountId;
|
||||||
|
@ApiModelProperty(value = "Наименование статуса", example = "ACTV")
|
||||||
|
@JsonProperty
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<EnumMessage> validate() {
|
||||||
|
List<EnumMessage> errors = new ArrayList<>();
|
||||||
|
if (this.id == null)
|
||||||
|
errors.add(new EnumMessage(BackEndError.ValidationError, "id"));
|
||||||
|
return errors.isEmpty() ? Collections.emptyList() : errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientCodeUpdateRequest toRequest() {
|
||||||
|
var req = new ClientCodeUpdateRequest();
|
||||||
|
req.setId(this.id);
|
||||||
|
req.setCompanyId(this.companyId);
|
||||||
|
req.setCode(this.code);
|
||||||
|
req.setTradingClearingRegistryId(this.tradingClearingRegistryId);
|
||||||
|
req.setMoneyAccountId(this.moneyAccountId);
|
||||||
|
req.setDepoAccountId(this.depoAccountId);
|
||||||
|
req.setStatus(this.status);
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(hidden = true)
|
||||||
|
@Override
|
||||||
|
public ActionType getActionType() {
|
||||||
|
return ActionType.UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCompanyId() {
|
||||||
|
return companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompanyId(Long companyId) {
|
||||||
|
this.companyId = companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTradingClearingRegistryId() {
|
||||||
|
return tradingClearingRegistryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTradingClearingRegistryId(Long tradingClearingRegistryId) {
|
||||||
|
this.tradingClearingRegistryId = tradingClearingRegistryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMoneyAccountId() {
|
||||||
|
return moneyAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoneyAccountId(Long moneyAccountId) {
|
||||||
|
this.moneyAccountId = moneyAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDepoAccountId() {
|
||||||
|
return depoAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDepoAccountId(Long depoAccountId) {
|
||||||
|
this.depoAccountId = depoAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -88,6 +88,8 @@ import static ru.spcex.clearing.test.json.MatcherFactoryWithJson.usingIgnoringFi
|
||||||
BankAccountController.class,
|
BankAccountController.class,
|
||||||
ClearingAccountController.class,
|
ClearingAccountController.class,
|
||||||
DepoAccountController.class,
|
DepoAccountController.class,
|
||||||
|
//account misc
|
||||||
|
ClientCodeController.class,
|
||||||
//company
|
//company
|
||||||
CompanyRoleSetController.class,
|
CompanyRoleSetController.class,
|
||||||
CompanyController.class,
|
CompanyController.class,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,174 @@
|
||||||
|
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||||
|
|
||||||
|
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.account.ClientCode;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.request.cud.account.ClientCodeNewAction;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.request.cud.account.ClientCodeUpdateAction;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||||
|
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.Consts;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static ru.spcex.clearing.test.json.JsonUtil.writeValue;
|
||||||
|
|
||||||
|
class ClientCodeControllerTest extends AbstractControllerTest {
|
||||||
|
private static final String REST_URL = "/accounting/client-codes/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ClientCodeController#add(ClientCodeNewAction)}<br>
|
||||||
|
* Тест проверяет получение сущности {@link ClientCodeNewAction} по REST API и отправку в Apache Kafka.<br>
|
||||||
|
* Входной запрос {@link ClientCodeNewRequest}:<br>
|
||||||
|
* {@link ClientCodeNewRequest#} - 044525776<br>
|
||||||
|
* ...
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void add() throws Exception {
|
||||||
|
//ARRANGE
|
||||||
|
ClientCodeNewAction clientCodeNewAction = getClientCodeNewAction(
|
||||||
|
0,
|
||||||
|
"044525776",
|
||||||
|
"ACTV",
|
||||||
|
1000L,
|
||||||
|
1010L,
|
||||||
|
1020L,
|
||||||
|
1030L);
|
||||||
|
|
||||||
|
//ACT and ASSERT
|
||||||
|
checkAddingByRestApi(REST_URL, clientCodeNewAction);
|
||||||
|
checkSendedMessegeFromKafka(Consts.DESTINATION_CLIENT_CODE_NEW, clientCodeNewAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ClientCodeController#add(ClientCodeNewAction)}<br>
|
||||||
|
* Тест проверяет работу валидации сущности {@link ClientCodeNewAction} принятой по REST API для отправку в Apache Kafka.<br>
|
||||||
|
* Входной запрос {@link ClientCodeNewAction}:<br>
|
||||||
|
* {@link ClientCodeNewAction#id} - (generated)<br>
|
||||||
|
* {@link ClientCodeNewAction#code} - "044525776" или null или ""<br>
|
||||||
|
* {@link ClientCodeNewAction#status} - "ACTV"<br>
|
||||||
|
* {@link ClientCodeNewAction#companyId} - 1000L или null<br>
|
||||||
|
* {@link ClientCodeNewAction#depoAccountId} - 1010L<br>
|
||||||
|
* {@link ClientCodeNewAction#moneyAccountId} - 1020L<br>
|
||||||
|
* {@link ClientCodeNewAction#tradingClearingRegistryId} - 1030L<br>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void addWithException() {
|
||||||
|
assertThrowsFor(getClientCodeNewAction(0, "", "ACTV", 1000L, 1010L, 1020L, 1030L));
|
||||||
|
assertThrowsFor(getClientCodeNewAction(0, null, "ACTV", 1000L, 1010L, 1020L, 1030L));
|
||||||
|
assertThrowsFor(getClientCodeNewAction(0, "044525776", "ACTV", null, 1010L, 1020L, 1030L));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ClientCodeController#update(Long, ClientCodeUpdateAction)}<br>
|
||||||
|
* Тест проверяет получение сущности {@link ClientCodeUpdateAction} по REST API и отправку в Apache Kafka.<br>
|
||||||
|
* Входной запрос {@link ClientCodeUpdateAction}:<br>
|
||||||
|
* {@link ClientCodeUpdateAction#id} - (generated)<br>
|
||||||
|
* {@link ClientCodeUpdateAction#code} - "044525776"<br>
|
||||||
|
* {@link ClientCodeUpdateAction#status} - "ACTV"<br>
|
||||||
|
* {@link ClientCodeUpdateAction#companyId} - 1000L<br>
|
||||||
|
* {@link ClientCodeUpdateAction#depoAccountId} - 1010L<br>
|
||||||
|
* {@link ClientCodeUpdateAction#moneyAccountId} - 1020L<br>
|
||||||
|
* {@link ClientCodeUpdateAction#tradingClearingRegistryId} - 1030L<br>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void update() throws Exception {
|
||||||
|
//ARRANGE
|
||||||
|
long id = 0;
|
||||||
|
ClientCodeUpdateAction clientCodeUpdateAction = getClientCodeUpdateAction(
|
||||||
|
id,
|
||||||
|
"044525776",
|
||||||
|
"ACTV",
|
||||||
|
1000L,
|
||||||
|
1010L,
|
||||||
|
1020L,
|
||||||
|
1030L);
|
||||||
|
|
||||||
|
//ACT and ASSERT
|
||||||
|
checkUpdatingByRestApi(REST_URL, clientCodeUpdateAction, id);
|
||||||
|
checkSendedMessegeFromKafka(Consts.DESTINATION_CLIENT_CODE_UPDATE, clientCodeUpdateAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ClientCodeController#delete(Long)} <br>
|
||||||
|
* Тест проверяет получение id сущности {@link Long} по REST API и отправку в Apache Kafka.<br>
|
||||||
|
* Входной запрос /accounting/client-codes/{@link Long}: - 0L<br>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void delete() throws Exception {
|
||||||
|
//ARRANGE
|
||||||
|
long id = currentId.getAndIncrement();
|
||||||
|
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||||
|
deleteAction.setId(id);
|
||||||
|
//ACT and ASSERT
|
||||||
|
checkDeletingByRestApi(REST_URL, id);
|
||||||
|
checkSendedMessegeFromKafka(Consts.DESTINATION_CLIENT_CODE_DELETE, deleteAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ClientCodeController#getAll()} <br>
|
||||||
|
* Тест проверяет получение запроса по REST API и отправку всех записей из таблицы hazelcast Map_ClientCode.<br>
|
||||||
|
* Входной запрос /accounting/client-codes/ <br>
|
||||||
|
* Ответ CommonGetAllResponse <br>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void getAll() throws Exception {
|
||||||
|
//ARRANGE
|
||||||
|
ClientCode existClientCode = new ClientCode();
|
||||||
|
existClientCode.setCode("ooo tinkoff");
|
||||||
|
existClientCode.setCompanyId(1000L);
|
||||||
|
existClientCode.setDepoAccountId(1010L);
|
||||||
|
existClientCode.setStatus("ACTV");
|
||||||
|
existClientCode.setMoneyAccountId(1020L);
|
||||||
|
existClientCode.setTradingClearingRegistryId(1030L);
|
||||||
|
existClientCode.setCreated(Instant.now());
|
||||||
|
existClientCode.setUpdated(Instant.now());
|
||||||
|
existClientCode.setId(currentId.get());
|
||||||
|
|
||||||
|
//ACT and ASSERT
|
||||||
|
checkGettingAllFromRestApi(IMDGDistributedNames.Map_ClientCode, existClientCode, REST_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertThrowsFor(IAction<?> iAction) {
|
||||||
|
assertThrows(ActionValidationException.class, () -> {
|
||||||
|
try {
|
||||||
|
perform(MockMvcRequestBuilders.post(REST_URL).contentType(MediaType.APPLICATION_JSON).content(writeValue(iAction)));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Throwable rootCause = NestedExceptionUtils.getRootCause(e);
|
||||||
|
throw rootCause != null ? rootCause : e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientCodeNewAction getClientCodeNewAction(long id,
|
||||||
|
String code, String status, Long companyId, Long depoAccountId,
|
||||||
|
Long moneyAccountId, Long tradingClearingRegistryId ) {
|
||||||
|
ClientCodeNewAction clientCodeNewAction = new ClientCodeNewAction();
|
||||||
|
clientCodeNewAction.setCode(code);
|
||||||
|
clientCodeNewAction.setCompanyId(companyId);
|
||||||
|
clientCodeNewAction.setDepoAccountId(depoAccountId);
|
||||||
|
clientCodeNewAction.setStatus(status);
|
||||||
|
clientCodeNewAction.setMoneyAccountId(moneyAccountId);
|
||||||
|
clientCodeNewAction.setTradingClearingRegistryId(tradingClearingRegistryId);
|
||||||
|
return clientCodeNewAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientCodeUpdateAction getClientCodeUpdateAction(long id, String code, String status, Long companyId, Long depoAccountId,
|
||||||
|
Long moneyAccountId, Long tradingClearingRegistryId) {
|
||||||
|
ClientCodeUpdateAction clientCodeUpdateAction = new ClientCodeUpdateAction();
|
||||||
|
clientCodeUpdateAction.setId(id);
|
||||||
|
clientCodeUpdateAction.setCode(code);
|
||||||
|
clientCodeUpdateAction.setCompanyId(companyId);
|
||||||
|
clientCodeUpdateAction.setDepoAccountId(depoAccountId);
|
||||||
|
clientCodeUpdateAction.setStatus(status);
|
||||||
|
clientCodeUpdateAction.setMoneyAccountId(moneyAccountId);
|
||||||
|
clientCodeUpdateAction.setTradingClearingRegistryId(tradingClearingRegistryId);
|
||||||
|
return clientCodeUpdateAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -65,6 +65,10 @@ public interface Consts {
|
||||||
String DESTINATION_PROFILE_DOCUMENT_UPDATE = "profile-document-update";
|
String DESTINATION_PROFILE_DOCUMENT_UPDATE = "profile-document-update";
|
||||||
String DESTINATION_PROFILE_DOCUMENT_DELETE = "profile-document-delete";
|
String DESTINATION_PROFILE_DOCUMENT_DELETE = "profile-document-delete";
|
||||||
|
|
||||||
|
String DESTINATION_CLIENT_CODE_NEW = "client-code-new";
|
||||||
|
String DESTINATION_CLIENT_CODE_UPDATE = "client-code-update";
|
||||||
|
String DESTINATION_CLIENT_CODE_DELETE = "client-code-delete";
|
||||||
|
|
||||||
String DESTINATION_SDF08_NEW = "s-df-08-new";
|
String DESTINATION_SDF08_NEW = "s-df-08-new";
|
||||||
String DESTINATION_SDF02_NEW = "s-df-02-new";
|
String DESTINATION_SDF02_NEW = "s-df-02-new";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
public class ClientCodeNewRequest {
|
||||||
|
@JsonProperty
|
||||||
|
private Long companyId;
|
||||||
|
@JsonProperty
|
||||||
|
private String code;
|
||||||
|
@JsonProperty
|
||||||
|
private Long tradingClearingRegistryId;
|
||||||
|
@JsonProperty
|
||||||
|
private Long moneyAccountId;
|
||||||
|
@JsonProperty
|
||||||
|
private Long depoAccountId;
|
||||||
|
@JsonProperty
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public Long getCompanyId() {
|
||||||
|
return companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompanyId(Long companyId) {
|
||||||
|
this.companyId = companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTradingClearingRegistryId() {
|
||||||
|
return tradingClearingRegistryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTradingClearingRegistryId(Long tradingClearingRegistryId) {
|
||||||
|
this.tradingClearingRegistryId = tradingClearingRegistryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMoneyAccountId() {
|
||||||
|
return moneyAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoneyAccountId(Long moneyAccountId) {
|
||||||
|
this.moneyAccountId = moneyAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDepoAccountId() {
|
||||||
|
return depoAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDepoAccountId(Long depoAccountId) {
|
||||||
|
this.depoAccountId = depoAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
public class ClientCodeUpdateRequest {
|
||||||
|
@JsonProperty
|
||||||
|
public Long id; //Идентификатор записи
|
||||||
|
@JsonProperty
|
||||||
|
private Long companyId;
|
||||||
|
@JsonProperty
|
||||||
|
private String code;
|
||||||
|
@JsonProperty
|
||||||
|
private Long tradingClearingRegistryId;
|
||||||
|
@JsonProperty
|
||||||
|
private Long moneyAccountId;
|
||||||
|
@JsonProperty
|
||||||
|
private Long depoAccountId;
|
||||||
|
@JsonProperty
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCompanyId() {
|
||||||
|
return companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompanyId(Long companyId) {
|
||||||
|
this.companyId = companyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTradingClearingRegistryId() {
|
||||||
|
return tradingClearingRegistryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTradingClearingRegistryId(Long tradingClearingRegistryId) {
|
||||||
|
this.tradingClearingRegistryId = tradingClearingRegistryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMoneyAccountId() {
|
||||||
|
return moneyAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoneyAccountId(Long moneyAccountId) {
|
||||||
|
this.moneyAccountId = moneyAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDepoAccountId() {
|
||||||
|
return depoAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDepoAccountId(Long depoAccountId) {
|
||||||
|
this.depoAccountId = depoAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue