diff --git a/pom.xml b/pom.xml
index 78e9f440d7..f952129f82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,11 +40,37 @@
4.13.1
test
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.7
+
+
+ org.mockito
+ mockito-core
+ 2.23.0
+ test
+
+
+ org.powermock
+ powermock-api-mockito2
+ 2.0.2
+ test
+
+
+ org.powermock
+ powermock-module-junit4
+ 2.0.2
+ test
+
UTF-8
-Xdoclint:none
+ 3.0.0-M5
+ 8
+ 8
@@ -121,6 +147,41 @@
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.7
+
+
+ default-prepare-agent
+
+ prepare-agent
+
+
+
+ default-report
+
+ report
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 8
+ 8
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/com/tencentcloudapi/unit/common/AbstractClientInitTest.java b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientInitTest.java
new file mode 100644
index 0000000000..e8692537d5
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientInitTest.java
@@ -0,0 +1,48 @@
+package com.tencentcloudapi.unit.common;
+
+import com.tencentcloudapi.common.AbstractClient;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+public class AbstractClientInitTest {
+ private Credential credential;
+ private ClientProfile clientProfile;
+
+ @Before
+ public void setUp() {
+ credential =
+ new Credential(
+ System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
+ clientProfile = new ClientProfile();
+
+ HttpProfile httpProfile = new HttpProfile();
+ clientProfile.setHttpProfile(httpProfile);
+ clientProfile.setSignMethod("HmacSHA256");
+ }
+
+ @Test
+ public void testAbstractClientWithEndpointVersionCredentialRegion() {
+ String endpoint = "example.com";
+ String version = "v1";
+ String region = "ap-guangzhou";
+ AbstractClient client = new AbstractClient(endpoint, version, credential, region) {
+ };
+
+ client.setRegion(region);
+ client.setClientProfile(clientProfile);
+ client.setCredential(credential);
+ assertEquals(region, client.getRegion());
+ assertNotNull(client.getCredential());
+ assertNotNull(client.getClientProfile());
+
+ }
+
+
+}
+
diff --git a/src/test/java/com/tencentcloudapi/unit/common/AbstractClientInternalRequestTest.java b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientInternalRequestTest.java
new file mode 100644
index 0000000000..eab57e985b
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientInternalRequestTest.java
@@ -0,0 +1,59 @@
+package com.tencentcloudapi.unit.common;
+
+import com.tencentcloudapi.common.AbstractClient;
+import com.tencentcloudapi.common.AbstractModel;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import org.junit.Before;
+import org.junit.Test;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.reflect.Whitebox;
+
+import java.util.HashMap;
+
+class Client extends AbstractClient {
+ public Client(String endpoint, String version, Credential credential, String region) {
+ super(endpoint, version, credential, region);
+ }
+
+ public Client(String endpoint, String version, Credential credential, String region, ClientProfile profile) {
+ super(endpoint, version, credential, region, profile);
+ }
+}
+
+public class AbstractClientInternalRequestTest {
+ private Credential credential;
+ private ClientProfile clientProfile;
+ private String endpoint = "example.com";
+ private String version = "v1";
+ private String region = "ap-guangzhou";
+
+ @Before
+ public void setUp() {
+ credential =
+ new Credential(
+ System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"), "123e4567-e89b-12d3-a456-426614174000");
+ clientProfile = new ClientProfile();
+ }
+
+ @Test
+ public void testAbstractInternalRequest() throws Exception {
+ clientProfile.setBackupEndpoint("example.com");
+ Client client = new Client(endpoint, version, credential, region, clientProfile);
+ AbstractModel req = new AbstractModel() {
+ @Override
+ protected void toMap(HashMap map, String prefix) {
+ }
+ };
+ String actionName = "ActionName";
+
+ Client client1 = PowerMockito.spy(client);
+ PowerMockito.doReturn(null).when(client1, "internalRequestRaw", req, actionName);
+ try {
+ Whitebox.invokeMethod(client1, "internalRequest", req, actionName);
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+}
+
diff --git a/src/test/java/com/tencentcloudapi/unit/common/AbstractClientPrivateTest.java b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientPrivateTest.java
new file mode 100644
index 0000000000..c5aab57ed6
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientPrivateTest.java
@@ -0,0 +1,284 @@
+package com.tencentcloudapi.unit.common;
+
+import com.tencentcloudapi.common.*;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.http.HttpConnection;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import okhttp3.Headers;
+import okhttp3.Protocol;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.junit.Before;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.tencentcloudapi.common.profile.Language.ZH_CN;
+
+
+public class AbstractClientPrivateTest {
+ private Credential credential;
+ private ClientProfile clientProfile;
+ private AbstractClient client;
+ private String endpoint = "example.com";
+ private String version = "v1";
+ private String region = "ap-guangzhou";
+
+ @Before
+ public void setUp() {
+ credential =
+ new Credential(
+ System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"), "123e4567-e89b-12d3-a456-426614174000");
+ clientProfile = new ClientProfile();
+ }
+
+ @Test
+ public void testAbstractClientGetHeaders() throws Exception {
+ clientProfile.setUnsignedPayload(true);
+ clientProfile.setLanguage(ZH_CN);
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+
+ HashMap map = Whitebox.invokeMethod(client, "getHeaders");
+ assert "123e4567-e89b-12d3-a456-426614174000" == map.get("X-TC-Token");
+ assert "zh-CN" == map.get("X-TC-Language");
+ assert "UNSIGNED-PAYLOAD" == map.get("X-TC-Content-SHA256");
+ }
+
+ @Test
+ public void testAbstractClientTrySetProxy() throws Exception {
+ HttpProfile httpProfile = new HttpProfile();
+ httpProfile.setProxyHost("127.0.0.1");
+ httpProfile.setProxyPort(80);
+ httpProfile.setProxyUsername("user");
+ httpProfile.setProxyPassword("pwd");
+ clientProfile.setHttpProfile(httpProfile);
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+
+ HttpConnection conn = new HttpConnection(10, 10, 10);
+ Object result = Whitebox.invokeMethod(client, "trySetProxy", conn);
+ assert result == null;
+
+ httpProfile.setProxyHost("");
+ clientProfile.setHttpProfile(httpProfile);
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+ result = Whitebox.invokeMethod(client, "trySetProxy", conn);
+ assert result == null;
+
+ httpProfile.setProxyHost("127.0.0.1");
+ httpProfile.setProxyUsername("");
+ clientProfile.setHttpProfile(httpProfile);
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+ result = Whitebox.invokeMethod(client, "trySetProxy", conn);
+ assert result == null;
+ }
+
+ @Test
+ public void testAbstractClientTrySetSSLSocketFactory() throws Exception {
+ HttpProfile httpProfile = new HttpProfile();
+ SSLSocketFactory factory = new SSLSocketFactory() {
+ @Override
+ public String[] getDefaultCipherSuites() {
+ return new String[0];
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites() {
+ return new String[0];
+ }
+
+ @Override
+ public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException {
+ return null;
+ }
+
+ @Override
+ public Socket createSocket(String s, int i) throws IOException, UnknownHostException {
+ return null;
+ }
+
+ @Override
+ public Socket createSocket(String s, int i, InetAddress inetAddress, int i1) throws IOException, UnknownHostException {
+ return null;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress inetAddress, int i) throws IOException {
+ return null;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress1, int i1) throws IOException {
+ return null;
+ }
+ };
+ httpProfile.setSslSocketFactory(factory);
+ X509TrustManager trustManager = new X509TrustManager() {
+ @Override
+ public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+ };
+ httpProfile.setX509TrustManager(trustManager);
+ clientProfile.setHttpProfile(httpProfile);
+
+ HttpConnection conn = new HttpConnection(10, 10, 10);
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+
+ Whitebox.invokeMethod(client, "trySetSSLSocketFactory", conn);
+ }
+
+ @Test
+ public void testAbstractClientTrySetHostnameVerifier() throws Exception {
+ HttpProfile httpProfile = new HttpProfile();
+ httpProfile.setHostnameVerifier((s, sslSession) -> true);
+ clientProfile.setHttpProfile(httpProfile);
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+
+ HttpConnection conn = new HttpConnection(10, 10, 10);
+ Whitebox.invokeMethod(client, "trySetHostnameVerifier", conn);
+ }
+
+ @Test
+ public void testAbstractClientTrySetRegionBreaker() throws Exception {
+ clientProfile.setBackupEndpoint("example.com");
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+
+ Whitebox.invokeMethod(client, "trySetRegionBreaker");
+ }
+
+ @Test
+ public void testAbstractClientProcessResponseSSE() throws Exception {
+ // 创建一个Response实例
+ Request request = new Request.Builder()
+ .url("https://example.com")
+ .build();
+
+ Headers headers = new Headers.Builder()
+ .add("Content-Type", "application/json")
+ .build();
+
+ Response.Builder builder = new Response.Builder()
+ .request(request) // 设置请求对象
+ .protocol(Protocol.HTTP_2) // 设置协议版本,这里以HTTP/2为例
+ .code(200) // 设置响应码
+ .message("OK") // 设置响应消息
+ .headers(headers) // 设置响应头
+ .body(null) // 设置响应体,这里假设响应体为空
+ .networkResponse(null) // 设置网络响应,这里假设没有网络响应
+ .cacheResponse(null) // 设置缓存响应,这里假设没有缓存响应
+ .priorResponse(null) // 设置之前的响应,这里假设没有之前的响应
+ .sentRequestAtMillis(System.currentTimeMillis()) // 设置请求发送的时间戳
+ .receivedResponseAtMillis(System.currentTimeMillis()); // 设置响应接收的时间戳
+ builder.header("X-TC-RequestId", "123e4567-e89b-12d3");
+
+ Response resp = builder.build();
+ // 创建Token实例
+ CircuitBreaker circuitBreaker = new CircuitBreaker();
+ CircuitBreaker.Token token = circuitBreaker.allow();
+
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+ Class typeOfT = CommonSSEResponse.class;
+
+ Whitebox.invokeMethod(client, "processResponseSSE", resp, typeOfT, token);
+
+ try {
+ Whitebox.invokeMethod(client, "processResponseSSE", resp, SSEResponseModel.class, token);
+ } catch (Exception e) {}
+
+ CommonSSEResponse sse = new CommonSSEResponse();
+ sse.setRequestId("123e4567-e89b-12d3");
+ assert sse.getRequestId().equals("123e4567-e89b-12d3");
+ }
+
+ @Test
+ public void testAbstractClientGetMultipartPayload() throws Exception {
+ AbstractModel request = new AbstractModel() {
+ @Override
+ protected void toMap(HashMap map, String prefix) {
+ }
+
+ @Override
+ protected HashMap getMultipartRequestParams() {
+ HashMap map = new HashMap<>();
+ map.put("key", "value".getBytes());
+ return map;
+ }
+
+ @Override
+ protected String[] getBinaryParams() {
+ String[] strings = new String[1];
+ strings[0] = "key";
+ return strings;
+ }
+ };
+ String boundary = "boundary";
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+
+ Whitebox.invokeMethod(client, "getMultipartPayload", request, boundary);
+ }
+
+ @Test
+ public void testAbstractClientRetry() {
+ client = new AbstractClient(endpoint, version, credential, region, clientProfile) {
+ };
+ client.setRegionBreaker(new CircuitBreaker());
+ client.getRegionBreaker();
+
+ try {
+ client.retry(null, -1);
+ } catch (TencentCloudSDKException e) {
+ assert e.getMessage().contains("The number of retryTimes supported is 0 to 10.");
+ }
+
+ class getRegionBreakerRequest extends AbstractModel {
+ getRegionBreakerRequest() {
+ }
+
+ @Override
+ protected void toMap(HashMap map, String prefix) {
+ }
+ }
+ try {
+ client.retry(new getRegionBreakerRequest(), 0);
+ } catch (TencentCloudSDKException e) {
+ assert e.getMessage().contains("ClientSideError");
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/com/tencentcloudapi/unit/common/AbstractModelTest.java b/src/test/java/com/tencentcloudapi/unit/common/AbstractModelTest.java
new file mode 100644
index 0000000000..b983037740
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/common/AbstractModelTest.java
@@ -0,0 +1,68 @@
+package com.tencentcloudapi.unit.common;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
+import com.tencentcloudapi.common.AbstractModel;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static junit.framework.Assert.assertTrue;
+
+public class AbstractModelTest {
+ @Test
+ public void fromJsonStringTest() {
+ TestModel testModel = new TestModel();
+ TestModel.fromJsonString("{}", TestModel.class);
+ }
+
+ @Test
+ public void getMultipartRequestParamsTest() throws Exception {
+ TestModel testModel = new TestModel();
+ Map map = Whitebox.invokeMethod(testModel, "getMultipartRequestParams");
+ assertTrue(map == null || map.isEmpty());
+ }
+
+ @Test
+ public void setParamSimpleTest() throws Exception {
+ TestModel testModel = new TestModel();
+ String key = "key";
+ Map map = new HashMap<>();
+ Whitebox.invokeMethod(testModel, "setParamSimple", map, key, 123);
+ }
+
+ @Test
+ public void setParamArraySimpleTest() throws Exception {
+ TestModel testModel = new TestModel();
+ String key = "key";
+ Map map = new HashMap<>();
+ String[] V = new String[]{"a", "b"};
+ Whitebox.invokeMethod(testModel, "setParamArraySimple", map, key, V);
+ }
+
+ @Test
+ public void setParamObjTest() throws Exception {
+ TestModel testModel = new TestModel();
+ String prefix = "prefix";
+ Map map = new HashMap<>();
+ Whitebox.invokeMethod(testModel, "setParamObj", map, prefix, testModel);
+ }
+
+ @Test
+ public void setParamArrayObjTest() throws Exception {
+ TestModel testModel = new TestModel();
+ String prefix = "prefix";
+ Map map = new HashMap<>();
+ TestModel[] array = new TestModel[]{testModel};
+ Whitebox.invokeMethod(testModel, "setParamArrayObj", map, prefix, array);
+ }
+}
+
+class TestModel extends AbstractModel {
+ @Override
+ protected void toMap(HashMap map, String prefix) {
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsRequestTest.java
new file mode 100644
index 0000000000..333b46e32a
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsRequestTest.java
@@ -0,0 +1,50 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.ChatCompletionsRequest;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class ChatCompletionsRequestTest {
+ @Test
+ public void testChatCompletionsRequest() {
+ ChatCompletionsRequest request = new ChatCompletionsRequest();
+ request.setModel("model");
+ assert request.getModel().equals("model");
+
+ request.setMessages(new com.tencentcloudapi.hunyuan.v20230901.models.Message[]{new com.tencentcloudapi.hunyuan.v20230901.models.Message()});
+ assert request.getMessages().length == 1;
+
+ request.setStream(true);
+ assert request.getStream() == true;
+
+ request.setStreamModeration(true);
+ assert request.getStreamModeration() == true;
+
+ request.setTopP(1.0f);
+ assert request.getTopP() == 1.0f;
+
+ request.setTemperature(1.0f);
+ assert request.getTemperature() == 1.0f;
+
+ request.setEnableEnhancement(true);
+ assert request.getEnableEnhancement() == true;
+
+ request.setTools(new com.tencentcloudapi.hunyuan.v20230901.models.Tool[]{new com.tencentcloudapi.hunyuan.v20230901.models.Tool()});
+ assert request.getTools().length == 1;
+
+ request.setToolChoice("toolChoice");
+ assert request.getToolChoice().equals("toolChoice");
+
+ request.setCustomTool(new com.tencentcloudapi.hunyuan.v20230901.models.Tool());
+ request.getCustomTool();
+
+ request.setSearchInfo(true);
+ assert request.getSearchInfo() == true;
+
+ new ChatCompletionsRequest(request);
+
+ HashMap map = new HashMap<>();
+ request.toMap(map, "");
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsResponseTest.java
new file mode 100644
index 0000000000..a96829d02a
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsResponseTest.java
@@ -0,0 +1,45 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.ChatCompletionsResponse;
+import com.tencentcloudapi.hunyuan.v20230901.models.Choice;
+import com.tencentcloudapi.hunyuan.v20230901.models.ErrorMsg;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class ChatCompletionsResponseTest {
+ @Test
+ public void testChatCompletionsResponse() {
+ ChatCompletionsResponse resp = new ChatCompletionsResponse();
+ resp.setCreated(1L);
+ assert resp.getCreated() == 1L;
+
+ resp.setUsage(null);
+ assert resp.getUsage() == null;
+
+ resp.setNote("note");
+ assert resp.getNote() == "note";
+
+ resp.setId("id");
+ assert resp.getId() == "id";
+
+ resp.setChoices(new Choice[]{new Choice()});
+ assert resp.getChoices().length == 1;
+
+ resp.setErrorMsg(null);
+ assert resp.getErrorMsg() == null;
+
+ resp.setModerationLevel("moderationLevel");
+ assert resp.getModerationLevel() == "moderationLevel";
+
+ resp.setSearchInfo(null);
+ assert resp.getSearchInfo() == null;
+
+ resp.setRequestId("requestId");
+ assert resp.getRequestId() == "requestId";
+
+ new ChatCompletionsResponse(resp);
+
+ resp.toMap(new HashMap(), "");
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ChoiceTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChoiceTest.java
new file mode 100644
index 0000000000..c0cbbbadf7
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChoiceTest.java
@@ -0,0 +1,23 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.Choice;
+import com.tencentcloudapi.hunyuan.v20230901.models.Delta;
+import com.tencentcloudapi.hunyuan.v20230901.models.Message;
+import org.junit.Test;
+
+public class ChoiceTest {
+ @Test
+ public void testChoice() {
+ Choice choice = new Choice();
+ choice.setFinishReason("finishReason");
+ assert choice.getFinishReason().equals("finishReason");
+
+ choice.setDelta(new Delta());
+ choice.getDelta();
+
+ choice.setMessage(new Message());
+ choice.getMessage().setRole("role");
+
+ new Choice(choice);
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ContentTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ContentTest.java
new file mode 100644
index 0000000000..4ddeb8deb5
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/ContentTest.java
@@ -0,0 +1,26 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.Content;
+import com.tencentcloudapi.hunyuan.v20230901.models.ImageUrl;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class ContentTest {
+ @Test
+ public void testContent() {
+ Content content = new Content();
+ content.setType("test");
+ assert content.getType().equals("test");
+
+ content.setText("test");
+ assert content.getText().equals("test");
+
+ content.setImageUrl(new ImageUrl());
+ content.getImageUrl().setUrl("test");
+ assert content.getImageUrl().getUrl().equals("test");
+
+ new Content(content);
+ content.toMap(new HashMap<>(), "");
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/DeltaTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/DeltaTest.java
new file mode 100644
index 0000000000..bfb8cca57a
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/DeltaTest.java
@@ -0,0 +1,25 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.Delta;
+import com.tencentcloudapi.hunyuan.v20230901.models.ToolCall;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class DeltaTest {
+ @Test
+ public void testDelta() {
+ Delta delta = new Delta();
+ delta.setRole("test");
+ assert delta.getRole().equals("test");
+
+ delta.setContent("test");
+ assert delta.getContent().equals("test");
+
+ delta.setToolCalls(new ToolCall[]{new ToolCall()});
+ assert delta.getToolCalls().length == 1;
+
+ new Delta(delta);
+ delta.toMap(new HashMap<>(), "");
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingDataTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingDataTest.java
new file mode 100644
index 0000000000..8990313609
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingDataTest.java
@@ -0,0 +1,24 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.EmbeddingData;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class EmbeddingDataTest {
+ @Test
+ public void testEmbeddingData() {
+ EmbeddingData embeddingData = new EmbeddingData();
+ embeddingData.setEmbedding(new Float[]{1.0f, 2.0f, 3.0f});
+ assert embeddingData.getEmbedding().length == 3;
+
+ embeddingData.setIndex(1L);
+ assert embeddingData.getIndex() == 1L;
+
+ embeddingData.setObject("test");
+ assert embeddingData.getObject().equals("test");
+
+ new EmbeddingData(embeddingData);
+ embeddingData.toMap(new HashMap<>(), "");
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingUsageTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingUsageTest.java
new file mode 100644
index 0000000000..2d5471ae14
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingUsageTest.java
@@ -0,0 +1,18 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.EmbeddingUsage;
+import org.junit.Test;
+
+public class EmbeddingUsageTest {
+ @Test
+ public void testEmbeddingUsage() {
+ EmbeddingUsage usage = new EmbeddingUsage();
+ usage.setPromptTokens(10L);
+ assert usage.getPromptTokens() == 10L;
+
+ usage.setTotalTokens(100L);
+ assert usage.getTotalTokens() == 100L;
+
+ new EmbeddingUsage(usage);
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ErrorMsgTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ErrorMsgTest.java
new file mode 100644
index 0000000000..c74c9ddd71
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/ErrorMsgTest.java
@@ -0,0 +1,21 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.ErrorMsg;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class ErrorMsgTest {
+ @Test
+ public void testErrorMsg() {
+ ErrorMsg errorMsg = new ErrorMsg();
+ errorMsg.setMsg("msg");
+ assert errorMsg.getMsg().equals("msg");
+
+ errorMsg.setCode(1L);
+ assert errorMsg.getCode() == 1L;
+
+ new ErrorMsg(errorMsg);
+ errorMsg.toMap(new HashMap<>(), "prefix");
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingRequestTest.java
new file mode 100644
index 0000000000..93c1b8823a
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingRequestTest.java
@@ -0,0 +1,18 @@
+package com.tencentcloudapi.unit.hunyuan;
+
+import com.tencentcloudapi.hunyuan.v20230901.models.GetEmbeddingRequest;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class GetEmbeddingRequestTest {
+ @Test
+ public void testGetEmbeddingRequest() {
+ GetEmbeddingRequest request = new GetEmbeddingRequest();
+ request.setInput("test");
+ assert request.getInput().equals("test");
+
+ new GetEmbeddingRequest(request);
+ request.toMap(new HashMap<>(), "");
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanClientTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanClientTest.java
new file mode 100644
index 0000000000..bd8a8a06b7
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanClientTest.java
@@ -0,0 +1,93 @@
+package com.tencentcloudapi.unit.hunyuanclient;
+
+import com.tencentcloudapi.common.AbstractModel;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.hunyuan.v20230901.HunyuanClient;
+import com.tencentcloudapi.hunyuan.v20230901.models.*;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+
+public class HunyuanClientTest {
+ @Test
+ public void testChatCompletions() throws TencentCloudSDKException {
+ Credential cred =
+ new Credential(
+ System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
+ HttpProfile httpProfile = new HttpProfile();
+ ClientProfile clientProfile = new ClientProfile();
+ clientProfile.setHttpProfile(httpProfile);
+ HunyuanClient client = new HunyuanClient(cred, "ap-guangzhou", clientProfile);
+
+ ChatCompletionsRequest req = new ChatCompletionsRequest();
+ Whitebox.setInternalState(req, "Model", "hunyuan-pro");
+ Message message = new Message();
+ Whitebox.setInternalState(message, "Role", "user");
+ Whitebox.setInternalState(message, "Content", "hello");
+ Message[] messages = new Message[1];
+ messages[0] = message;
+ Whitebox.setInternalState(req, "Messages", messages);
+
+ ChatCompletionsResponse response = client.ChatCompletions(req);
+ assert response != null;
+ }
+
+ @Test
+ public void testGetEmbedding() throws TencentCloudSDKException {
+ Credential cred =
+ new Credential(
+ System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
+ HunyuanClient client = new HunyuanClient(cred, "ap-guangzhou");
+
+ GetEmbeddingRequest req = new GetEmbeddingRequest();
+ req.setInput("hello");
+
+ GetEmbeddingResponse response = client.GetEmbedding(req);
+ assert response != null;
+ }
+
+ @Test
+ public void testGetTokenCount() throws TencentCloudSDKException {
+ Credential cred =
+ new Credential(
+ System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
+ HunyuanClient client = new HunyuanClient(cred, "ap-guangzhou");
+
+ GetTokenCountRequest req = new GetTokenCountRequest();
+ req.setPrompt("hello");
+
+ GetTokenCountResponse response = client.GetTokenCount(req);
+ assert response != null;
+ }
+
+ @Test
+ public void testQueryHunyuanImageJobResponse() throws TencentCloudSDKException {
+ Credential cred =
+ new Credential(
+ System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
+ HunyuanClient client = new HunyuanClient(cred, "ap-guangzhou");
+
+ SubmitHunyuanImageJobRequest req = new SubmitHunyuanImageJobRequest();
+ req.setPrompt("snow and fire");
+
+ SubmitHunyuanImageJobResponse response = client.SubmitHunyuanImageJob(req);
+ assert response != null;
+ }
+
+ @Test
+ public void testTextToImageLite() throws TencentCloudSDKException {
+ Credential cred =
+ new Credential(
+ System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
+ HunyuanClient client = new HunyuanClient(cred, "ap-guangzhou");
+
+ TextToImageLiteRequest req = new TextToImageLiteRequest();
+ req.setPrompt("mountains and rivers");
+
+ TextToImageLiteResponse response = client.TextToImageLite(req);
+ assert response != null;
+ }
+}
diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanErrorCodeTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanErrorCodeTest.java
new file mode 100644
index 0000000000..6ed8d5bc29
--- /dev/null
+++ b/src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanErrorCodeTest.java
@@ -0,0 +1,31 @@
+package com.tencentcloudapi.unit.hunyuanclient;
+
+import com.tencentcloudapi.hunyuan.v20230901.HunyuanErrorCode;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import static org.junit.Assert.assertEquals;
+
+public class HunyuanErrorCodeTest {
+ @Test
+ public void testErrorCode() throws Exception {
+ assertEquals("FailedOperation", HunyuanErrorCode.FAILEDOPERATION.getValue());
+ assertEquals("FailedOperation.EngineRequestTimeout", HunyuanErrorCode.FAILEDOPERATION_ENGINEREQUESTTIMEOUT.getValue());
+ assertEquals("FailedOperation.EngineServerError", HunyuanErrorCode.FAILEDOPERATION_ENGINESERVERERROR.getValue());
+ assertEquals("FailedOperation.EngineServerLimitExceeded",HunyuanErrorCode.FAILEDOPERATION_ENGINESERVERLIMITEXCEEDED.getValue());
+ assertEquals("FailedOperation.FreeResourcePackExhausted", HunyuanErrorCode.FAILEDOPERATION_FREERESOURCEPACKEXHAUSTED.getValue());
+ assertEquals("FailedOperation.ImageDecodeFailed", HunyuanErrorCode.FAILEDOPERATION_IMAGEDECODEFAILED.getValue());
+ assertEquals("FailedOperation.ImageDownloadError", HunyuanErrorCode.FAILEDOPERATION_IMAGEDOWNLOADERROR.getValue());
+ assertEquals("FailedOperation.ResourcePackExhausted", HunyuanErrorCode.FAILEDOPERATION_RESOURCEPACKEXHAUSTED.getValue());
+ assertEquals("FailedOperation.ServiceNotActivated", HunyuanErrorCode.FAILEDOPERATION_SERVICENOTACTIVATED.getValue());
+ assertEquals("FailedOperation.ServiceStop", HunyuanErrorCode.FAILEDOPERATION_SERVICESTOP.getValue());
+ assertEquals("FailedOperation.ServiceStopArrears", HunyuanErrorCode.FAILEDOPERATION_SERVICESTOPARREARS.getValue());
+ assertEquals("InternalError", HunyuanErrorCode.INTERNALERROR.getValue());
+ assertEquals("InvalidParameter", HunyuanErrorCode.INVALIDPARAMETER.getValue());
+ assertEquals("InvalidParameterValue", HunyuanErrorCode.INVALIDPARAMETERVALUE.getValue());
+ assertEquals("InvalidParameterValue.Model", HunyuanErrorCode.INVALIDPARAMETERVALUE_MODEL.getValue());
+ assertEquals("InvalidParameterValue.ParameterValueError", HunyuanErrorCode.INVALIDPARAMETERVALUE_PARAMETERVALUEERROR.getValue());
+ assertEquals("LimitExceeded", HunyuanErrorCode.LIMITEXCEEDED.getValue());
+ assertEquals("OperationDenied.ImageIllegalDetected", HunyuanErrorCode.OPERATIONDENIED_IMAGEILLEGALDETECTED.getValue());
+ }
+}