fixing bug in test
This commit is contained in:
parent
42529a8eed
commit
40c716d159
3 changed files with 122 additions and 78 deletions
|
|
@ -1,7 +1,12 @@
|
||||||
package ru.spcex.clearing.backendapi.controller.queue;
|
package ru.spcex.clearing.backendapi.controller.queue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.TestPropertySource;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.ResultActions;
|
import org.springframework.test.web.servlet.ResultActions;
|
||||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||||
|
|
@ -10,20 +15,25 @@ import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
import org.springframework.web.filter.CharacterEncodingFilter;
|
||||||
import ru.spcex.clearing.backendapi.controller.queue.company.DeleteCompanyController;
|
import ru.spcex.clearing.backendapi.controller.queue.company.DeleteCompanyController;
|
||||||
import ru.spcex.clearing.backendapi.controller.queue.config.*;
|
import ru.spcex.clearing.backendapi.controller.queue.config.*;
|
||||||
|
import ru.spcex.clearing.backendapi.meta.GetResponseFactory;
|
||||||
|
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
|
||||||
@SpringJUnitWebConfig(classes = {
|
@ContextConfiguration(classes = {
|
||||||
|
BankAccountControllerConfig.class,
|
||||||
|
DeleteCompanyController.class,
|
||||||
WebTestConfig.class,
|
WebTestConfig.class,
|
||||||
IOperator.class,
|
IOperator.class,
|
||||||
StateLoaderImplConfig.class,
|
|
||||||
DeleteCompanyController.class,
|
|
||||||
BankAccountControllerConfig.class,
|
|
||||||
KafkaTestConfig.class,
|
KafkaTestConfig.class,
|
||||||
HazelcastServiceTestConfiguration.class,
|
HazelcastServiceTestConfiguration.class,
|
||||||
|
StateLoaderImplConfig.class,
|
||||||
Jackson2HttpConverterTestConfig.class})
|
Jackson2HttpConverterTestConfig.class})
|
||||||
|
@ExtendWith(SpringExtension.class)
|
||||||
|
@WebMvcTest//(controllers = DeleteCompanyController.class)
|
||||||
|
@TestPropertySource(properties = "spring.config.location=D:/repo/mfd/clearing/clearing-parent/backend-api/src/main/resources/")
|
||||||
public abstract class AbstractControllerTest {
|
public abstract class AbstractControllerTest {
|
||||||
protected static final AtomicLong currentId = new AtomicLong();
|
protected static final AtomicLong currentId = new AtomicLong();
|
||||||
private static final CharacterEncodingFilter CHARACTER_ENCODING_FILTER = new CharacterEncodingFilter();
|
private static final CharacterEncodingFilter CHARACTER_ENCODING_FILTER = new CharacterEncodingFilter();
|
||||||
|
|
@ -33,8 +43,13 @@ public abstract class AbstractControllerTest {
|
||||||
CHARACTER_ENCODING_FILTER.setForceEncoding(true);
|
CHARACTER_ENCODING_FILTER.setForceEncoding(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("hazelcastServiceTest")
|
||||||
|
protected HazelcastService hazelcastServiceTest;
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("responseFactoryTest")
|
||||||
|
protected GetResponseFactory responseFactory;
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WebApplicationContext webApplicationContext;
|
private WebApplicationContext webApplicationContext;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,16 @@ package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||||
|
|
||||||
import com.hazelcast.core.IMap;
|
import com.hazelcast.core.IMap;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|
||||||
import org.springframework.core.NestedExceptionUtils;
|
import org.springframework.core.NestedExceptionUtils;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
|
||||||
import org.springframework.test.context.TestPropertySource;
|
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
|
||||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
|
||||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||||
import ru.spcex.clearing.backendapi.controller.queue.config.*;
|
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
|
||||||
import ru.spcex.clearing.backendapi.controller.queue.utils.MatcherFactory;
|
|
||||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.BankAccountNewAction;
|
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.account.BankAccountUpdateAction;
|
||||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
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.cud.QueueSuccessResponse;
|
||||||
|
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||||
import ru.spcex.clearing.backendapi.controller.response.entity.account.BankAccountBackendGetById;
|
import ru.spcex.clearing.backendapi.controller.response.entity.account.BankAccountBackendGetById;
|
||||||
import ru.spcex.clearing.backendapi.controller.response.entity.account.BankAccountBackendGetFields;
|
import ru.spcex.clearing.backendapi.controller.response.entity.account.BankAccountBackendGetFields;
|
||||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||||
|
|
@ -30,10 +19,9 @@ import ru.spcex.clearing.backendapi.errors.ActionValidationException;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
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.MockMvcResultHandlers.print;
|
||||||
|
|
@ -41,46 +29,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
import static ru.spcex.clearing.backendapi.controller.queue.utils.JsonUtil.writeValue;
|
import static ru.spcex.clearing.backendapi.controller.queue.utils.JsonUtil.writeValue;
|
||||||
|
|
||||||
@ContextConfiguration(classes = {
|
class BankAccountControllerTest extends AbstractControllerTest {
|
||||||
WebTestConfig.class,
|
|
||||||
IOperator.class,
|
|
||||||
BankAccountControllerConfig.class,
|
|
||||||
KafkaTestConfig.class,
|
|
||||||
HazelcastServiceTestConfiguration.class,
|
|
||||||
StateLoaderImplConfig.class,
|
|
||||||
Jackson2HttpConverterTestConfig.class})
|
|
||||||
@ExtendWith(SpringExtension.class)
|
|
||||||
@WebMvcTest(controllers = BankAccountController.class)
|
|
||||||
@TestPropertySource(properties = "spring.config.location=D:/repo/mfd/clearing/clearing-parent/backend-api/src/main/resources/")
|
|
||||||
class BankAccountControllerTest {
|
|
||||||
|
|
||||||
public static final MatcherFactory.Matcher<CudResponse> CUD_RESPONSE_MATCHER = MatcherFactory.usingIgnoringFieldsComparator(CudResponse.class);
|
|
||||||
private static final String REST_URL = "/securities/bank-accounts/";
|
private static final String REST_URL = "/securities/bank-accounts/";
|
||||||
private static final CharacterEncodingFilter CHARACTER_ENCODING_FILTER = new CharacterEncodingFilter();
|
|
||||||
private static final AtomicLong currentId = new AtomicLong();
|
|
||||||
|
|
||||||
static {
|
|
||||||
CHARACTER_ENCODING_FILTER.setEncoding("UTF-8");
|
|
||||||
CHARACTER_ENCODING_FILTER.setForceEncoding(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
@Qualifier("hazelcastServiceTest")
|
|
||||||
private HazelcastService hazelcastServiceTest;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WebApplicationContext webApplicationContext;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
private void postConstruct() {
|
|
||||||
mockMvc = MockMvcBuilders
|
|
||||||
.webAppContextSetup(webApplicationContext)
|
|
||||||
.addFilter(CHARACTER_ENCODING_FILTER)
|
|
||||||
// .apply(springSecurity())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link BankAccountController#add(BankAccountNewAction)}<br>
|
* {@link BankAccountController#add(BankAccountNewAction)}<br>
|
||||||
|
|
@ -115,7 +65,7 @@ class BankAccountControllerTest {
|
||||||
expected.setMessage("success");
|
expected.setMessage("success");
|
||||||
expected.setPayload(new QueueSuccessResponse(ActionType.NEW, currentId.getAndIncrement()));
|
expected.setPayload(new QueueSuccessResponse(ActionType.NEW, currentId.getAndIncrement()));
|
||||||
//ACT
|
//ACT
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post(REST_URL)
|
perform(MockMvcRequestBuilders.post(REST_URL)
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(writeValue(bankAccountNewAction)))
|
.content(writeValue(bankAccountNewAction)))
|
||||||
.andDo(print())//output to the log request and response
|
.andDo(print())//output to the log request and response
|
||||||
|
|
@ -185,7 +135,7 @@ class BankAccountControllerTest {
|
||||||
expected.setMessage("success");
|
expected.setMessage("success");
|
||||||
expected.setPayload(new QueueSuccessResponse(ActionType.UPDATE, currentId.getAndIncrement()));
|
expected.setPayload(new QueueSuccessResponse(ActionType.UPDATE, currentId.getAndIncrement()));
|
||||||
//ACT
|
//ACT
|
||||||
mockMvc.perform(MockMvcRequestBuilders.put(REST_URL + "0")
|
perform(MockMvcRequestBuilders.put(REST_URL + "0")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(writeValue(bankAccountNewAction)))
|
.content(writeValue(bankAccountNewAction)))
|
||||||
.andDo(print())//output to the log request and response
|
.andDo(print())//output to the log request and response
|
||||||
|
|
@ -195,11 +145,10 @@ class BankAccountControllerTest {
|
||||||
.andExpect(content().json(writeValue(expected)));
|
.andExpect(content().json(writeValue(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link BankAccountController#delete(Long)} <br>
|
* {@link BankAccountController#delete(Long)} <br>
|
||||||
* Тест проверяет получение id сущности {@link Long} по REST API и отправку в Apache Kafka.<br>
|
* Тест проверяет получение id сущности {@link Long} по REST API и отправку в Apache Kafka.<br>
|
||||||
* Входной запрос {@link Long}: - 0L<br>
|
* Входной запрос /securities/bank-accounts/{@link Long}: - 0L<br>
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void delete() throws Exception {
|
void delete() throws Exception {
|
||||||
|
|
@ -209,7 +158,7 @@ class BankAccountControllerTest {
|
||||||
expected.setMessage("success");
|
expected.setMessage("success");
|
||||||
expected.setPayload(new QueueSuccessResponse(ActionType.DELETE, currentId.getAndIncrement()));
|
expected.setPayload(new QueueSuccessResponse(ActionType.DELETE, currentId.getAndIncrement()));
|
||||||
//ACT
|
//ACT
|
||||||
mockMvc.perform(MockMvcRequestBuilders.delete(REST_URL + "0")
|
perform(MockMvcRequestBuilders.delete(REST_URL + "0")
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(print())//output to the log request and response
|
.andDo(print())//output to the log request and response
|
||||||
//ASSERT
|
//ASSERT
|
||||||
|
|
@ -218,6 +167,12 @@ class BankAccountControllerTest {
|
||||||
.andExpect(content().json(writeValue(expected)));
|
.andExpect(content().json(writeValue(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BankAccountController#getById(Long)} <br>
|
||||||
|
* Тест проверяет получение запроса по REST API и отправку всех записей из таблицы hazelcast Map_BankAccount.<br>
|
||||||
|
* Входной запрос /securities/bank-accounts/{@link Long}: - 0L <br>
|
||||||
|
* Ответ BankAccountBackendGetById <br>
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
void getById() throws Exception {
|
void getById() throws Exception {
|
||||||
//ARRANGE
|
//ARRANGE
|
||||||
|
|
@ -250,7 +205,7 @@ class BankAccountControllerTest {
|
||||||
payload.setId(existBankAccount.getId());
|
payload.setId(existBankAccount.getId());
|
||||||
expected.setPayload(payload);
|
expected.setPayload(payload);
|
||||||
//ACT
|
//ACT
|
||||||
mockMvc.perform(MockMvcRequestBuilders.get(REST_URL + existBankAccount.getId())
|
perform(MockMvcRequestBuilders.get(REST_URL + existBankAccount.getId())
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(print())//output to the log request and response
|
.andDo(print())//output to the log request and response
|
||||||
// ASSERT
|
// ASSERT
|
||||||
|
|
@ -259,14 +214,48 @@ class BankAccountControllerTest {
|
||||||
.andExpect(content().json(writeValue(expected)));
|
.andExpect(content().json(writeValue(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BankAccountController#getAll()} <br>
|
||||||
|
* Тест проверяет получение запроса по REST API и отправку всех записей из таблицы hazelcast Map_BankAccount.<br>
|
||||||
|
* Входной запрос /securities/bank-accounts/ <br>
|
||||||
|
* Ответ CommonGetAllResponse <br>
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
void getAll() {
|
void getAll() throws Exception {
|
||||||
|
//ARRANGE
|
||||||
|
BankAccount existBankAccount = new BankAccount();
|
||||||
|
existBankAccount.setBankName("ooo tinkoff");
|
||||||
|
existBankAccount.setBankIdentificationCode("99999");
|
||||||
|
existBankAccount.setCorrespondentAccount("9294189285498598598");
|
||||||
|
existBankAccount.setCorrespondentAccountName("BIK OF TINKOFF");
|
||||||
|
existBankAccount.setCurrency("RUB");
|
||||||
|
existBankAccount.setDestination("OOO ROGA I KOPITA");
|
||||||
|
existBankAccount.setTaxpayerIdentificationNumber("848484848484");
|
||||||
|
existBankAccount.setTaxRegistrationReasonCode("886886");
|
||||||
|
existBankAccount.setAccount("123456789123");
|
||||||
|
existBankAccount.setId(currentId.get());
|
||||||
|
|
||||||
|
IMap<Long, BankAccount> iMap = hazelcastServiceTest.getHazelcast().getMap(IMDGDistributedNames.Map_BankAccount);
|
||||||
|
iMap.put(existBankAccount.getId(), existBankAccount);
|
||||||
|
|
||||||
|
Collection<BankAccount> values = iMap.values();
|
||||||
|
Collection<Map<String, Object>> all = responseFactory.responseFromObjectCollection(values);
|
||||||
|
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) {
|
private void assertThrowsFor(IAction<?> iAction) {
|
||||||
assertThrows(ActionValidationException.class, () -> {
|
assertThrows(ActionValidationException.class, () -> {
|
||||||
try {
|
try {
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post(REST_URL).contentType(MediaType.APPLICATION_JSON).content(writeValue(iAction)));
|
perform(MockMvcRequestBuilders.post(REST_URL).contentType(MediaType.APPLICATION_JSON).content(writeValue(iAction)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwable rootCause = NestedExceptionUtils.getRootCause(e);
|
Throwable rootCause = NestedExceptionUtils.getRootCause(e);
|
||||||
throw rootCause != null ? rootCause : e;
|
throw rootCause != null ? rootCause : e;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,20 @@
|
||||||
package ru.spcex.clearing.backendapi.controller.queue.company;
|
package ru.spcex.clearing.backendapi.controller.queue.company;
|
||||||
|
|
||||||
|
import com.hazelcast.core.IMap;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
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.queue.AbstractControllerTest;
|
||||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
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.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.ActionType;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
@ -19,7 +26,7 @@ class DeleteCompanyControllerTest extends AbstractControllerTest {
|
||||||
/**
|
/**
|
||||||
* {@link DeleteCompanyController#delete(Long)} <br>
|
* {@link DeleteCompanyController#delete(Long)} <br>
|
||||||
* Тест проверяет получение id сущности {@link Long} по REST API и отправку в Apache Kafka.<br>
|
* Тест проверяет получение id сущности {@link Long} по REST API и отправку в Apache Kafka.<br>
|
||||||
* Входной запрос {@link Long}: - 0L<br>
|
* Входной запрос /companies/{@link Long}: - 0L<br>
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void delete() throws Exception {
|
void delete() throws Exception {
|
||||||
|
|
@ -37,4 +44,37 @@ class DeleteCompanyControllerTest extends AbstractControllerTest {
|
||||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(content().json(writeValue(extended)));
|
.andExpect(content().json(writeValue(extended)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DeleteCompanyController#getAll()} <br>
|
||||||
|
* Тест проверяет получение запроса по REST API и отправку всех записей из таблицы hazelcast Map_Company.<br>
|
||||||
|
* Входной запрос /companies <br>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void getAll() throws Exception {
|
||||||
|
//ARRANGE
|
||||||
|
Company existCompany = new Company();
|
||||||
|
existCompany.setTradingCode("ooo tinkoff");
|
||||||
|
existCompany.setClearingCode("99999");
|
||||||
|
existCompany.setFullName("BIK OF TINKOFF");
|
||||||
|
existCompany.setShortName("OOO ROGA I KOPITA");
|
||||||
|
existCompany.setTradingCode("848484848484");
|
||||||
|
existCompany.setId(currentId.get());
|
||||||
|
|
||||||
|
IMap<Long, Company> iMap = hazelcastServiceTest.getHazelcast().getMap(IMDGDistributedNames.Map_Company);
|
||||||
|
iMap.put(existCompany.getId(), existCompany);
|
||||||
|
|
||||||
|
Collection<Company> values = iMap.values();
|
||||||
|
Collection<Map<String, Object>> all = responseFactory.responseFromObjectCollection(values);
|
||||||
|
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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue