From 325437ff8509c8ae19da9e060272e1e12f2ab228 Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期四, 30 十月 2025 17:18:26 +0800
Subject: [PATCH] 接口测试正确
---
src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java | 77 +++++++++++++++++++++++++++++++++++++-
1 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java b/src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java
index cc8dbe1..c6362b1 100644
--- a/src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java
+++ b/src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java
@@ -1,18 +1,91 @@
package com.gs.xiaomi;
-import com.gs.xiaomi.service.XM104Service;
+import cn.hutool.crypto.digest.DigestUtil;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.gs.xiaomi.dto.BCS101Request;
+import com.gs.xiaomi.dto.BCS101Response;
+import com.gs.xiaomi.dto.NumbericalDto;
+import com.gs.xiaomi.entity.DeliveryMain;
+import com.gs.xiaomi.service.BCS101ApiService;
+import com.gs.xiaomi.service.DeliveryMainService;
+import com.gs.xiaomi.service.Xm104Service;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
@SpringBootTest
class XiaomiApplicationTests {
@Autowired
- private XM104Service xm104Service;
+ private Xm104Service xm104Service;
+
+ @Autowired
+ private BCS101ApiService bcs101ApiService;
+
+ @Autowired
+ private DeliveryMainService deliveryMainService;
@Test
void contextLoads() throws Exception {
xm104Service.getDb();
}
+
+ //manualSynchronization
+ @Test
+ void contextLoads1() throws Exception {
+ NumbericalDto barcode = new NumbericalDto();
+ barcode.setAsn("9316702418");
+ xm104Service.manualSynchronization(barcode);
+ }
+
+ @Test
+ void test() {
+// String str = ",,";
+// String[] parts = str.split(",");
+// for (String part : parts) {
+// System.out.println(part);
+// }
+ System.out.println(DigestUtil.md5Hex("VDATA.XM104/177301/c5Kl}xN&i(").toUpperCase());
+ }
+
+ @Test
+ void testBCS101ApiService() throws Exception {
+
+ List<DeliveryMain> list = deliveryMainService.list();
+
+ //List<String> collect = list.stream().map(DeliveryMain::getZzasn).collect(Collectors.toList());
+
+ list.forEach(s->{
+ System.out.println(String.valueOf(Integer.parseInt(s.getLifnr()))+":"+s.getZzasn());
+ // 鍒涘缓娴嬭瘯璇锋眰鍙傛暟
+ BCS101Request request = new BCS101Request();
+ request.setSupplierId(String.valueOf(Integer.parseInt(s.getLifnr())) );
+ request.setDocNo(s.getZzasn());
+ request.setDocType("ASNGR");
+ request.setPageNo(1);
+ request.setPageSize(1000);
+
+ // 璋冪敤API鑾峰彇鍘熷JSON瀛楃涓�
+ String bcs101Data = null;
+ try {
+ bcs101Data = bcs101ApiService.getBCS101Data(request);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ System.out.println("鍘熷鍝嶅簲: " + bcs101Data);
+
+ // 瑙f瀽JSON涓築CS101Response瀵硅薄
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ BCS101Response response = objectMapper.readValue(bcs101Data, BCS101Response.class);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }
}
--
Gitblit v1.9.3