|
@@ -7,6 +7,7 @@ import com.malk.minglei.dto.MingleiPortRequest;
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
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.mock.http.client.MockClientHttpRequest;
|
|
|
import org.springframework.test.web.client.MockRestServiceServer;
|
|
import org.springframework.test.web.client.MockRestServiceServer;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
@@ -42,7 +43,7 @@ class MingleiPortServiceImplTest {
|
|
|
void submitSupplierPriceApprovalForwardsDocumentAndReturnsExternalResponse() throws Exception {
|
|
void submitSupplierPriceApprovalForwardsDocumentAndReturnsExternalResponse() throws Exception {
|
|
|
server.expect(requestTo("http://external.example/wtoptst/ws/r/awsp920"))
|
|
server.expect(requestTo("http://external.example/wtoptst/ws/r/awsp920"))
|
|
|
.andExpect(method(org.springframework.http.HttpMethod.POST))
|
|
.andExpect(method(org.springframework.http.HttpMethod.POST))
|
|
|
- .andExpect(header("Content-Type", MediaType.APPLICATION_JSON_VALUE))
|
|
|
|
|
|
|
+ .andExpect(header("Content-Type", "application/json;charset=UTF-8"))
|
|
|
.andExpect(content().json(externalRequestJson()))
|
|
.andExpect(content().json(externalRequestJson()))
|
|
|
.andRespond(withSuccess("{\"srvver\":\"1.0\",\"srvcode\":\"100\",\"datakey\":null,\"payload\":{\"std_data\":{\"execution\":{\"code\":\"0\",\"sql_code\":null,\"description\":\"SUCCESS\"},\"parameter\":{\"pmdidocno\":\"CH3\",\"tran_time\":\"2026-08-25 10:00:00\"}}}}", MediaType.APPLICATION_JSON));
|
|
.andRespond(withSuccess("{\"srvver\":\"1.0\",\"srvcode\":\"100\",\"datakey\":null,\"payload\":{\"std_data\":{\"execution\":{\"code\":\"0\",\"sql_code\":null,\"description\":\"SUCCESS\"},\"parameter\":{\"pmdidocno\":\"CH3\",\"tran_time\":\"2026-08-25 10:00:00\"}}}}", MediaType.APPLICATION_JSON));
|
|
|
|
|
|
|
@@ -56,11 +57,16 @@ class MingleiPortServiceImplTest {
|
|
|
void submitT100DocumentUsesDingTalkServiceName() {
|
|
void submitT100DocumentUsesDingTalkServiceName() {
|
|
|
server.expect(requestTo("http://external.example/wtoptst/ws/r/awsp920"))
|
|
server.expect(requestTo("http://external.example/wtoptst/ws/r/awsp920"))
|
|
|
.andExpect(method(org.springframework.http.HttpMethod.POST))
|
|
.andExpect(method(org.springframework.http.HttpMethod.POST))
|
|
|
|
|
+ .andExpect(header("Content-Type", "application/json;charset=UTF-8"))
|
|
|
.andExpect(content().json("{\"service\":{\"name\":\"DingTalk To T100\"},\"datakey\":{\"type\":\"priceSheets\"}}", false))
|
|
.andExpect(content().json("{\"service\":{\"name\":\"DingTalk To T100\"},\"datakey\":{\"type\":\"priceSheets\"}}", false))
|
|
|
|
|
+ .andExpect(request -> assertEquals("中文备注",
|
|
|
|
|
+ objectMapper.readTree(((MockClientHttpRequest) request).getBodyAsBytes())
|
|
|
|
|
+ .at("/payload/std_data/parameter/remark").asText()))
|
|
|
.andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
|
|
.andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
|
|
|
|
|
|
|
|
Map<String, Object> parameter = new LinkedHashMap<String, Object>();
|
|
Map<String, Object> parameter = new LinkedHashMap<String, Object>();
|
|
|
parameter.put("head", Collections.singletonMap("pmaaucent", "86"));
|
|
parameter.put("head", Collections.singletonMap("pmaaucent", "86"));
|
|
|
|
|
+ parameter.put("remark", "中文备注");
|
|
|
mingleiPortService.submitT100Document(parameter, "priceSheets", "DingTalk To T100");
|
|
mingleiPortService.submitT100Document(parameter, "priceSheets", "DingTalk To T100");
|
|
|
|
|
|
|
|
server.verify();
|
|
server.verify();
|