From 81c899d17cd3d7d46e9ebf13763af4d2ecfb5748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=87=E6=9D=B0?= <72617766+19916302128@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:19:57 +0800 Subject: [PATCH 1/4] Add files via upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为Java SDK添加单元测试用例 --- pom.xml | 63 +++- unit/common/AbstractClientInitTest.java | 48 +++ .../AbstractClientInternalRequestTest.java | 59 ++++ unit/common/AbstractClientPrivateTest.java | 300 ++++++++++++++++++ unit/common/AbstractModelTest.java | 68 ++++ unit/common/CredentialTest.java | 41 +++ unit/common/HttpConnectionTest.java | 76 +++++ unit/common/HttpProfileTest.java | 25 ++ unit/common/OIDCRoleArnProviderTest.java | 17 + unit/common/RegionTest.java | 34 ++ unit/common/SSEResponseModelTest.java | 81 +++++ unit/common/SignTest.java | 24 ++ unit/hunyuan/ChatCompletionsRequestTest.java | 50 +++ unit/hunyuan/ChatCompletionsResponseTest.java | 45 +++ unit/hunyuan/ChoiceTest.java | 23 ++ unit/hunyuan/ContentTest.java | 26 ++ unit/hunyuan/DeltaTest.java | 25 ++ unit/hunyuan/EmbeddingDataTest.java | 24 ++ unit/hunyuan/EmbeddingUsageTest.java | 18 ++ unit/hunyuan/ErrorMsgTest.java | 21 ++ unit/hunyuan/GetEmbeddingRequestTest.java | 18 ++ unit/hunyuan/GetEmbeddingResponseTest.java | 26 ++ unit/hunyuan/GetTokenCountRequestTest.java | 18 ++ unit/hunyuan/GetTokenCountResponseTest.java | 30 ++ unit/hunyuan/LogoParamTest.java | 22 ++ unit/hunyuan/LogoRectTest.java | 27 ++ unit/hunyuan/MessageTest.java | 29 ++ .../QueryHunyuanImageJobRequestTest.java | 18 ++ .../QueryHunyuanImageJobResponseTest.java | 39 +++ unit/hunyuan/SearchInfoTest.java | 19 ++ unit/hunyuan/SearchResultTest.java | 24 ++ .../SubmitHunyuanImageJobRequestTest.java | 40 +++ .../SubmitHunyuanImageJobResponseTest.java | 20 ++ unit/hunyuan/TextToImageLiteRequestTest.java | 37 +++ unit/hunyuan/TextToImageLiteResponseTest.java | 21 ++ unit/hunyuan/ToolCallFunctionTest.java | 21 ++ unit/hunyuan/ToolCallTest.java | 25 ++ unit/hunyuan/ToolFunctionTest.java | 24 ++ unit/hunyuan/ToolTest.java | 19 ++ unit/hunyuan/UsageTest.java | 24 ++ unit/hunyuanclient/HunyuanClientTest.java | 93 ++++++ unit/hunyuanclient/HunyuanErrorCodeTest.java | 31 ++ 42 files changed, 1692 insertions(+), 1 deletion(-) create mode 100644 unit/common/AbstractClientInitTest.java create mode 100644 unit/common/AbstractClientInternalRequestTest.java create mode 100644 unit/common/AbstractClientPrivateTest.java create mode 100644 unit/common/AbstractModelTest.java create mode 100644 unit/common/CredentialTest.java create mode 100644 unit/common/HttpConnectionTest.java create mode 100644 unit/common/HttpProfileTest.java create mode 100644 unit/common/OIDCRoleArnProviderTest.java create mode 100644 unit/common/RegionTest.java create mode 100644 unit/common/SSEResponseModelTest.java create mode 100644 unit/common/SignTest.java create mode 100644 unit/hunyuan/ChatCompletionsRequestTest.java create mode 100644 unit/hunyuan/ChatCompletionsResponseTest.java create mode 100644 unit/hunyuan/ChoiceTest.java create mode 100644 unit/hunyuan/ContentTest.java create mode 100644 unit/hunyuan/DeltaTest.java create mode 100644 unit/hunyuan/EmbeddingDataTest.java create mode 100644 unit/hunyuan/EmbeddingUsageTest.java create mode 100644 unit/hunyuan/ErrorMsgTest.java create mode 100644 unit/hunyuan/GetEmbeddingRequestTest.java create mode 100644 unit/hunyuan/GetEmbeddingResponseTest.java create mode 100644 unit/hunyuan/GetTokenCountRequestTest.java create mode 100644 unit/hunyuan/GetTokenCountResponseTest.java create mode 100644 unit/hunyuan/LogoParamTest.java create mode 100644 unit/hunyuan/LogoRectTest.java create mode 100644 unit/hunyuan/MessageTest.java create mode 100644 unit/hunyuan/QueryHunyuanImageJobRequestTest.java create mode 100644 unit/hunyuan/QueryHunyuanImageJobResponseTest.java create mode 100644 unit/hunyuan/SearchInfoTest.java create mode 100644 unit/hunyuan/SearchResultTest.java create mode 100644 unit/hunyuan/SubmitHunyuanImageJobRequestTest.java create mode 100644 unit/hunyuan/SubmitHunyuanImageJobResponseTest.java create mode 100644 unit/hunyuan/TextToImageLiteRequestTest.java create mode 100644 unit/hunyuan/TextToImageLiteResponseTest.java create mode 100644 unit/hunyuan/ToolCallFunctionTest.java create mode 100644 unit/hunyuan/ToolCallTest.java create mode 100644 unit/hunyuan/ToolFunctionTest.java create mode 100644 unit/hunyuan/ToolTest.java create mode 100644 unit/hunyuan/UsageTest.java create mode 100644 unit/hunyuanclient/HunyuanClientTest.java create mode 100644 unit/hunyuanclient/HunyuanErrorCodeTest.java diff --git a/pom.xml b/pom.xml index 3aea6eb79..010c02789 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.tencentcloudapi tencentcloud-sdk-java - 3.1.1091 + 3.1.1070 jar tencentcloud-sdk-java https://cloud.tencent.com/ @@ -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/unit/common/AbstractClientInitTest.java b/unit/common/AbstractClientInitTest.java new file mode 100644 index 000000000..e8692537d --- /dev/null +++ b/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/unit/common/AbstractClientInternalRequestTest.java b/unit/common/AbstractClientInternalRequestTest.java new file mode 100644 index 000000000..eab57e985 --- /dev/null +++ b/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/unit/common/AbstractClientPrivateTest.java b/unit/common/AbstractClientPrivateTest.java new file mode 100644 index 000000000..6d304acb2 --- /dev/null +++ b/unit/common/AbstractClientPrivateTest.java @@ -0,0 +1,300 @@ +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 testAbstractClientGetResponseBody() throws Exception { + client = new AbstractClient(endpoint, version, credential, region, clientProfile) { + }; + + String url = "https://example.com/api"; + Map headers = new HashMap<>(); + headers.put("Content-Type", "application/json"); + byte[] body = "{\"key\":\"value\"}".getBytes(); + try { + Whitebox.invokeMethod(client, "getResponseBody", url, headers, body); + } catch (TencentCloudSDKException e) { + assert e.getMessage().contains("404"); + } + } + + @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/unit/common/AbstractModelTest.java b/unit/common/AbstractModelTest.java new file mode 100644 index 000000000..b98303774 --- /dev/null +++ b/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/unit/common/CredentialTest.java b/unit/common/CredentialTest.java new file mode 100644 index 000000000..2982ecd28 --- /dev/null +++ b/unit/common/CredentialTest.java @@ -0,0 +1,41 @@ +package com.tencentcloudapi.unit.common; + +import com.tencentcloudapi.common.Credential; +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import org.junit.Test; +import org.powermock.reflect.Whitebox; + +public class CredentialTest { + @Test + public void testCredential() throws Exception { + class CredentialUpdater implements Credential.Updater { + @Override + public void update(Credential credential) throws TencentCloudSDKException { + throw new TencentCloudSDKException("test"); + } + } + CredentialUpdater updater = new CredentialUpdater(); + Credential credential = new Credential("secretId", "secretKey", "token", updater); + credential.getUpdater(); + credential.setUpdater(new CredentialUpdater()); + credential.setSecretId("secretId"); + credential.setSecretKey("secretKey"); + credential.setToken("token"); + + try { + Whitebox.invokeMethod(credential, "tryUpdate"); + } catch (Exception e) { + assert e.getMessage().contains("test"); + } + + Credential cred = new Credential(); + class testUpdater implements Credential.Updater { + @Override + public void update(Credential credential) throws TencentCloudSDKException { + } + } + testUpdater testUpdater = new testUpdater(); + Credential cred1 = new Credential("secretId", "secretKey", "token", testUpdater); + Whitebox.invokeMethod(cred1, "tryUpdate"); + } +} diff --git a/unit/common/HttpConnectionTest.java b/unit/common/HttpConnectionTest.java new file mode 100644 index 000000000..697e9ad9f --- /dev/null +++ b/unit/common/HttpConnectionTest.java @@ -0,0 +1,76 @@ +package com.tencentcloudapi.unit.common; + +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import com.tencentcloudapi.common.http.HttpConnection; +import okhttp3.Headers; +import org.junit.Test; + +import javax.net.ssl.SSLSocketFactory; +import java.io.IOException; +import java.net.InetAddress; +import java.net.Socket; +import java.net.UnknownHostException; + +public class HttpConnectionTest { + @Test + public void testGetRequest() throws IOException { + HttpConnection httpConnection = new HttpConnection(1, 1, 1); + try { + httpConnection.getRequest(""); + } catch (TencentCloudSDKException e) { + e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); + } + } + + @Test + public void testGetRequestWithHeaders() throws IOException { + HttpConnection httpConnection = new HttpConnection(1, 1, 1); + Headers headers = new Headers.Builder().build(); + try { + httpConnection.getRequest("", headers); + } catch (TencentCloudSDKException e) { + e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); + } + } + + @Test + public void testPostRequest() throws IOException { + HttpConnection httpConnection = new HttpConnection(1, 1, 1); + try { + httpConnection.postRequest("", "body"); + } catch (TencentCloudSDKException e) { + e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); + } + } + + @Test + public void testPostRequestWithHeaders() throws IOException, TencentCloudSDKException { + HttpConnection httpConnection = new HttpConnection(1, 1, 1); + Headers headers = new Headers.Builder() + .add("Content-Type", "application/json") // 添加Content-Type头部字段 + .add("User-Agent", "OkHttp/3.12.12") // 添加User-Agent头部字段 + .build(); + httpConnection.postRequest("https://www.example.com", "body", headers); + + try { + httpConnection.postRequest("", "body", headers); + } catch (TencentCloudSDKException e) { + e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); + } + } + + @Test + public void testPostRequestWithArrayBody() throws IOException, TencentCloudSDKException { + HttpConnection httpConnection = new HttpConnection(1, 1, 1); + Headers headers = new Headers.Builder() + .add("Content-Type", "application/json") // 添加Content-Type头部字段 + .add("User-Agent", "OkHttp/3.12.12") // 添加User-Agent头部字段 + .build(); + byte[] body = "body".getBytes(); + try { + httpConnection.postRequest("", body, headers); + } catch (TencentCloudSDKException e) { + e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); + } + } +} diff --git a/unit/common/HttpProfileTest.java b/unit/common/HttpProfileTest.java new file mode 100644 index 000000000..ed117f1f5 --- /dev/null +++ b/unit/common/HttpProfileTest.java @@ -0,0 +1,25 @@ +package com.tencentcloudapi.unit.common; + +import com.tencentcloudapi.common.profile.HttpProfile; +import org.junit.Test; + +public class HttpProfileTest { + @Test + public void testHttpProfile() { + HttpProfile profile = new HttpProfile(); + profile.setEndpoint("https://unit.tencentcloudapi.com"); + assert profile.getEndpoint().equals("https://unit.tencentcloudapi.com"); + profile.setReadTimeout(10000); + assert profile.getReadTimeout() == 10000; + profile.setWriteTimeout(10000); + assert profile.getWriteTimeout() == 10000; + profile.setConnTimeout(10000); + assert profile.getConnTimeout() == 10000; + profile.setProtocol("http"); + assert profile.getProtocol().equals("http"); + profile.setRootDomain("unit.tencentcloudapi.com"); + assert profile.getRootDomain().equals("unit.tencentcloudapi.com"); + profile.setApigwEndpoint("https://unit.tencentcloudapi.com"); + assert profile.getApigwEndpoint().equals("https://unit.tencentcloudapi.com"); + } +} diff --git a/unit/common/OIDCRoleArnProviderTest.java b/unit/common/OIDCRoleArnProviderTest.java new file mode 100644 index 000000000..45ad7c8aa --- /dev/null +++ b/unit/common/OIDCRoleArnProviderTest.java @@ -0,0 +1,17 @@ +package com.tencentcloudapi.unit.common; + +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import com.tencentcloudapi.common.provider.OIDCRoleArnProvider; +import org.junit.Test; +import org.powermock.reflect.Whitebox; + + +public class OIDCRoleArnProviderTest { + @Test + public void testOIDCRoleArnProviderInit() throws TencentCloudSDKException { + OIDCRoleArnProvider oidcRoleArnProvider = new OIDCRoleArnProvider("ap-shanghai", "", "", "", "", 0L); + oidcRoleArnProvider.ExpirationReservationTime = 0L; + Whitebox.setInternalState(oidcRoleArnProvider,"isTke",false); + + } +} diff --git a/unit/common/RegionTest.java b/unit/common/RegionTest.java new file mode 100644 index 000000000..5977eb1a5 --- /dev/null +++ b/unit/common/RegionTest.java @@ -0,0 +1,34 @@ +package com.tencentcloudapi.unit.common; + +import com.tencentcloudapi.common.profile.Region; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +public class RegionTest { + @Test + public void testRegion() { + String[] expectedRegions = { + "ap-bangkok", "ap-beijing", "ap-chengdu", "ap-chongqing", "ap-guangzhou", "ap-guangzhou-open", + "ap-hongkong", "ap-mumbai", "ap-seoul", "ap-shanghai", "ap-shanghai-fsi", "ap-shenzhen-fsi", + "ap-singapore", "ap-tokyo", "eu-frankfurt", "eu-moscow", "na-ashburn", "na-siliconvalley", "na-toronto" + }; + for (String expectedRegion : expectedRegions) { + boolean found = false; + for (Region region : Region.values()) { + if (region.getValue().equals(expectedRegion)) { + found = true; + break; + } + } + assertTrue("Expected region " + expectedRegion + " to be present", found); + } + } + + @Test + public void testRegionValue() { + assertEquals("ap-bangkok", Region.Bangkok.getValue()); + assertEquals("ap-bangkok", Region.Bangkok.toString()); + } +} diff --git a/unit/common/SSEResponseModelTest.java b/unit/common/SSEResponseModelTest.java new file mode 100644 index 000000000..dfd812c0c --- /dev/null +++ b/unit/common/SSEResponseModelTest.java @@ -0,0 +1,81 @@ +package com.tencentcloudapi.unit.common; + +import com.tencentcloudapi.common.SSEResponseModel; +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import okhttp3.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.mockito.Mockito; +import org.powermock.reflect.Whitebox; + +import java.util.*; + +public class SSEResponseModelTest { + @Test + public void SSETest() throws Exception { + SSEResponseModel.SSE sse = new SSEResponseModel.SSE(); + sse.Id = "123"; + sse.Event = "123"; + sse.Data = "2024"; + sse.Retry = 0l; + assert sse.toString().equals("Id=123 Event=123 Retry=0 Data=2024"); + } + + @Test + public void SSEIteratorTest() throws Exception { + SSEModelTest sse = new SSEModelTest(); + Map map = new HashMap(); + Whitebox.invokeMethod(sse, "toMap", map, "prefix"); + + Request request = new Request.Builder() + .url("https://example.com") + .build(); + // 创建一个MediaType实例,指定响应体的媒体类型为JSON + MediaType jsonMediaType = MediaType.parse("application/json; charset=utf-8"); + + // 创建一个字符串作为响应体的内容 + String responseBodyContent = "{\"key\":\"value\"}"; + + // 使用ResponseBody.create方法创建一个ResponseBody实例 + ResponseBody responseBody = ResponseBody.create(jsonMediaType, responseBodyContent); + Response.Builder builder = new Response.Builder() + .request(request) // 设置请求对象 + .protocol(Protocol.HTTP_2) // 设置协议版本,这里以HTTP/2为例 + .code(200) // 设置响应码 + .message("OK"); // 设置响应消息; + Response response = builder.build(); + Whitebox.setInternalState(sse, "response", response); + + Iterator iterator; + try { + iterator = sse.iterator(); + } catch (RuntimeException e) { + assert e.getMessage().contains("Response body should not be null"); + } + builder.body(responseBody); + response = builder.build(); + Whitebox.setInternalState(sse, "response", response); + iterator = sse.iterator(); + + iterator.hasNext(); + iterator.remove(); + try { + iterator.next(); + }catch (Exception e){ + assert e.getMessage().contains("No line found"); + } + Whitebox.invokeMethod(sse, "close"); + } +} + +class SSEModelTest extends SSEResponseModel { + @Override + public String getRequestId() { + return ""; + } + + @Override + public void setRequestId(String requestId) { + } +} \ No newline at end of file diff --git a/unit/common/SignTest.java b/unit/common/SignTest.java new file mode 100644 index 000000000..1ca194a3a --- /dev/null +++ b/unit/common/SignTest.java @@ -0,0 +1,24 @@ +package com.tencentcloudapi.unit.common; + +import com.tencentcloudapi.common.Sign; +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import org.junit.Test; + +public class SignTest { + @Test + public void testSign() throws TencentCloudSDKException { + Sign sign = new Sign(); + try { + sign.sign("1", "1", "1"); + } catch (TencentCloudSDKException e) { + assert e.getMessage().contains("1 not available"); + } + } + + @Test + public void testSha256Hex() throws TencentCloudSDKException { + Sign sign = new Sign(); + String s = sign.sha256Hex("1"); + assert s.equals("6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b"); + } +} diff --git a/unit/hunyuan/ChatCompletionsRequestTest.java b/unit/hunyuan/ChatCompletionsRequestTest.java new file mode 100644 index 000000000..333b46e32 --- /dev/null +++ b/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/unit/hunyuan/ChatCompletionsResponseTest.java b/unit/hunyuan/ChatCompletionsResponseTest.java new file mode 100644 index 000000000..a96829d02 --- /dev/null +++ b/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/unit/hunyuan/ChoiceTest.java b/unit/hunyuan/ChoiceTest.java new file mode 100644 index 000000000..c0cbbbadf --- /dev/null +++ b/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/unit/hunyuan/ContentTest.java b/unit/hunyuan/ContentTest.java new file mode 100644 index 000000000..4ddeb8deb --- /dev/null +++ b/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/unit/hunyuan/DeltaTest.java b/unit/hunyuan/DeltaTest.java new file mode 100644 index 000000000..bfb8cca57 --- /dev/null +++ b/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/unit/hunyuan/EmbeddingDataTest.java b/unit/hunyuan/EmbeddingDataTest.java new file mode 100644 index 000000000..899031360 --- /dev/null +++ b/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/unit/hunyuan/EmbeddingUsageTest.java b/unit/hunyuan/EmbeddingUsageTest.java new file mode 100644 index 000000000..2d5471ae1 --- /dev/null +++ b/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/unit/hunyuan/ErrorMsgTest.java b/unit/hunyuan/ErrorMsgTest.java new file mode 100644 index 000000000..c74c9ddd7 --- /dev/null +++ b/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/unit/hunyuan/GetEmbeddingRequestTest.java b/unit/hunyuan/GetEmbeddingRequestTest.java new file mode 100644 index 000000000..93c1b8823 --- /dev/null +++ b/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/unit/hunyuan/GetEmbeddingResponseTest.java b/unit/hunyuan/GetEmbeddingResponseTest.java new file mode 100644 index 000000000..5a0ca910f --- /dev/null +++ b/unit/hunyuan/GetEmbeddingResponseTest.java @@ -0,0 +1,26 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.EmbeddingData; +import com.tencentcloudapi.hunyuan.v20230901.models.EmbeddingUsage; +import com.tencentcloudapi.hunyuan.v20230901.models.GetEmbeddingResponse; +import org.junit.Test; + +import java.util.HashMap; + +public class GetEmbeddingResponseTest { + @Test + public void testGetEmbeddingResponse() { + GetEmbeddingResponse response = new GetEmbeddingResponse(); + response.setData(new EmbeddingData[]{}); + assert response.getData().length == 0; + + response.setUsage(new EmbeddingUsage()); + response.getUsage().setPromptTokens(1L); + + response.setRequestId("test"); + assert response.getRequestId().equals("test"); + + new GetEmbeddingResponse(response); + response.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/GetTokenCountRequestTest.java b/unit/hunyuan/GetTokenCountRequestTest.java new file mode 100644 index 000000000..11bf036b0 --- /dev/null +++ b/unit/hunyuan/GetTokenCountRequestTest.java @@ -0,0 +1,18 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.GetTokenCountRequest; +import org.junit.Test; + +import java.util.HashMap; + +public class GetTokenCountRequestTest { + @Test + public void testGetTokenCountRequest() { + GetTokenCountRequest request = new GetTokenCountRequest(); + request.setPrompt("test"); + assert request.getPrompt().equals("test"); + + new GetTokenCountRequest(request); + request.toMap(new HashMap(), ""); + } +} diff --git a/unit/hunyuan/GetTokenCountResponseTest.java b/unit/hunyuan/GetTokenCountResponseTest.java new file mode 100644 index 000000000..2213a8dc5 --- /dev/null +++ b/unit/hunyuan/GetTokenCountResponseTest.java @@ -0,0 +1,30 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.GetTokenCountResponse; +import org.junit.Test; + +import java.util.HashMap; + +public class GetTokenCountResponseTest { + @Test + public void TestGetTokenCountResponse() { + GetTokenCountResponse response = new GetTokenCountResponse(); + response.setTokenCount(1L); + assert response.getTokenCount() == 1L; + + response.setTokenCount(2L); + assert response.getTokenCount() == 2L; + + response.setTokens(new String[]{"a", "b", "c"}); + assert response.getTokens().length == 3; + + response.setCharacterCount(1L); + assert response.getCharacterCount() == 1L; + + response.setRequestId("123"); + assert response.getRequestId().equals("123"); + + new GetTokenCountResponse(response); + response.toMap(new HashMap(), ""); + } +} diff --git a/unit/hunyuan/LogoParamTest.java b/unit/hunyuan/LogoParamTest.java new file mode 100644 index 000000000..c82d9670a --- /dev/null +++ b/unit/hunyuan/LogoParamTest.java @@ -0,0 +1,22 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.LogoParam; +import com.tencentcloudapi.hunyuan.v20230901.models.LogoRect; +import org.junit.Test; + +public class LogoParamTest { + @Test + public void testLogoParam() { + LogoParam logoParam = new LogoParam(); + logoParam.setLogoUrl("https://hunyuan.com"); + assert logoParam.getLogoUrl().equals("https://hunyuan.com"); + + logoParam.setLogoImage("logo"); + assert logoParam.getLogoImage().equals("logo"); + + logoParam.setLogoRect(new LogoRect()); + logoParam.getLogoRect().setX(10L); + + new LogoParam(logoParam); + } +} diff --git a/unit/hunyuan/LogoRectTest.java b/unit/hunyuan/LogoRectTest.java new file mode 100644 index 000000000..da361e0d3 --- /dev/null +++ b/unit/hunyuan/LogoRectTest.java @@ -0,0 +1,27 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.LogoRect; +import org.junit.Test; + +import java.util.HashMap; + +public class LogoRectTest { + @Test + public void testLogoRect() { + LogoRect logoRect = new LogoRect(); + logoRect.setX(1L); + assert logoRect.getX() == 1L; + + logoRect.setY(1L); + assert logoRect.getY() == 1L; + + logoRect.setWidth(2L); + assert logoRect.getWidth() == 2L; + + logoRect.setHeight(2L); + assert logoRect.getHeight() == 2L; + + new LogoRect(logoRect); + logoRect.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/MessageTest.java b/unit/hunyuan/MessageTest.java new file mode 100644 index 000000000..3a35edf7d --- /dev/null +++ b/unit/hunyuan/MessageTest.java @@ -0,0 +1,29 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.Content; +import com.tencentcloudapi.hunyuan.v20230901.models.Message; +import com.tencentcloudapi.hunyuan.v20230901.models.ToolCall; +import org.junit.Test; + +public class MessageTest { + @Test + public void testMessage() { + Message message = new Message(); + message.setRole("role"); + assert message.getRole().equals("role"); + + message.setContent("content"); + assert message.getContent().equals("content"); + + message.setContents(new Content[]{new Content()}); + assert message.getContents().length == 1; + + message.setToolCallId("toolCallId"); + assert message.getToolCallId().equals("toolCallId"); + + message.setToolCalls(new ToolCall[]{new ToolCall()}); + assert message.getToolCalls().length == 1; + + new Message(message); + } +} diff --git a/unit/hunyuan/QueryHunyuanImageJobRequestTest.java b/unit/hunyuan/QueryHunyuanImageJobRequestTest.java new file mode 100644 index 000000000..b59880b28 --- /dev/null +++ b/unit/hunyuan/QueryHunyuanImageJobRequestTest.java @@ -0,0 +1,18 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.QueryHunyuanImageJobRequest; +import org.junit.Test; + +import java.util.HashMap; + +public class QueryHunyuanImageJobRequestTest { + @Test + public void testQueryHunyuanImageJobRequest() { + QueryHunyuanImageJobRequest request = new QueryHunyuanImageJobRequest(); + request.setJobId("jobId"); + assert request.getJobId().equals("jobId"); + + new QueryHunyuanImageJobRequest(request); + request.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/QueryHunyuanImageJobResponseTest.java b/unit/hunyuan/QueryHunyuanImageJobResponseTest.java new file mode 100644 index 000000000..391abd7b1 --- /dev/null +++ b/unit/hunyuan/QueryHunyuanImageJobResponseTest.java @@ -0,0 +1,39 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.QueryHunyuanImageJobResponse; +import org.junit.Test; + +import java.util.HashMap; + +public class QueryHunyuanImageJobResponseTest { + @Test + public void testQueryHunyuanImageJobResponse() { + QueryHunyuanImageJobResponse response = new QueryHunyuanImageJobResponse(); + response.setJobStatusCode("1"); + assert response.getJobStatusCode().equals("1"); + + response.setJobStatusMsg("排队中"); + assert response.getJobStatusMsg().equals("排队中"); + + response.setJobErrorCode("1"); + assert response.getJobErrorCode().equals("1"); + + response.setJobErrorMsg("处理失败"); + assert response.getJobErrorMsg().equals("处理失败"); + + response.setResultImage(new String[]{"1"}); + assert response.getResultImage()[0].equals("1"); + + response.setResultDetails(new String[]{"1"}); + assert response.getResultDetails()[0].equals("1"); + + response.setRevisedPrompt(new String[]{"1"}); + assert response.getRevisedPrompt()[0].equals("1"); + + response.setRequestId("requestId"); + assert response.getRequestId().equals("requestId"); + + new QueryHunyuanImageJobResponse(response); + response.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/SearchInfoTest.java b/unit/hunyuan/SearchInfoTest.java new file mode 100644 index 000000000..17caf361f --- /dev/null +++ b/unit/hunyuan/SearchInfoTest.java @@ -0,0 +1,19 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.SearchInfo; +import com.tencentcloudapi.hunyuan.v20230901.models.SearchResult; +import org.junit.Test; + +import java.util.HashMap; + +public class SearchInfoTest { + @Test + public void testSearchInfo() { + SearchInfo searchInfo = new SearchInfo(); + searchInfo.setSearchResults(new SearchResult[]{new SearchResult(), new SearchResult()}); + assert searchInfo.getSearchResults().length == 2; + + new SearchInfo(searchInfo); + searchInfo.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/SearchResultTest.java b/unit/hunyuan/SearchResultTest.java new file mode 100644 index 000000000..94b6f5641 --- /dev/null +++ b/unit/hunyuan/SearchResultTest.java @@ -0,0 +1,24 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.SearchResult; +import org.junit.Test; + +import java.util.HashMap; + +public class SearchResultTest { + @Test + public void testSearchResult() { + SearchResult searchResult = new SearchResult(); + searchResult.setIndex(1L); + assert searchResult.getIndex() == 1L; + + searchResult.setTitle("title"); + assert searchResult.getTitle().equals("title"); + + searchResult.setUrl("url"); + assert searchResult.getUrl().equals("url"); + + new SearchResult(searchResult); + searchResult.toMap(new HashMap<>(), "prefix"); + } +} diff --git a/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java b/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java new file mode 100644 index 000000000..df736f5a3 --- /dev/null +++ b/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java @@ -0,0 +1,40 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.LogoParam; +import com.tencentcloudapi.hunyuan.v20230901.models.SubmitHunyuanImageJobRequest; +import org.junit.Test; + +import java.util.HashMap; + +public class SubmitHunyuanImageJobRequestTest { + @Test + public void testBuildRequest() { + SubmitHunyuanImageJobRequest request = new SubmitHunyuanImageJobRequest(); + request.setPrompt("test"); + assert request.getPrompt().equals("test"); + + request.setStyle("test"); + assert request.getStyle().equals("test"); + + request.setResolution("768:768(1:1)"); + assert request.getResolution().equals("768:768(1:1)"); + + request.setNum(1L); + assert request.getNum() == 1L; + + request.setSeed(9L); + assert request.getSeed() == 9L; + + request.setRevise(1L); + assert request.getRevise() == 1L; + + request.setLogoAdd(1L); + assert request.getLogoAdd() == 1L; + + request.setLogoParam(new LogoParam()); + request.getLogoParam().setLogoUrl("test"); + + new SubmitHunyuanImageJobRequest(request); + request.toMap(new HashMap(), ""); + } +} diff --git a/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java b/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java new file mode 100644 index 000000000..3f931ff77 --- /dev/null +++ b/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java @@ -0,0 +1,20 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.SubmitHunyuanImageJobResponse; +import org.junit.Test; + +import java.util.HashMap; + +public class SubmitHunyuanImageJobResponseTest { + @Test + public void testSubmitHunyuanImageJobResponse() { + SubmitHunyuanImageJobResponse response = new SubmitHunyuanImageJobResponse(); + response.setRequestId("requestId"); + assert response.getRequestId().equals("requestId"); + + response.setJobId("jobId"); + assert response.getJobId().equals("jobId"); + new SubmitHunyuanImageJobResponse(response); + response.toMap(new HashMap<>(), "prefix"); + } +} diff --git a/unit/hunyuan/TextToImageLiteRequestTest.java b/unit/hunyuan/TextToImageLiteRequestTest.java new file mode 100644 index 000000000..069cf66bc --- /dev/null +++ b/unit/hunyuan/TextToImageLiteRequestTest.java @@ -0,0 +1,37 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.LogoParam; +import com.tencentcloudapi.hunyuan.v20230901.models.TextToImageLiteRequest; +import org.junit.Test; + +import java.util.HashMap; + +public class TextToImageLiteRequestTest { + @Test + public void testTextToImageLiteRequest() { + TextToImageLiteRequest request = new TextToImageLiteRequest(); + request.setPrompt("test"); + assert request.getPrompt().equals("test"); + + request.setNegativePrompt("test"); + assert request.getNegativePrompt().equals("test"); + + request.setStyle("style"); + assert request.getStyle().equals("style"); + + request.setResolution("768:1024(3:4)"); + assert request.getResolution().equals("768:1024(3:4)"); + + request.setLogoAdd(1L); + assert request.getLogoAdd() == 1L; + + request.setLogoParam(new LogoParam()); + request.getLogoParam(); + + request.setRspImgType("png"); + assert request.getRspImgType().equals("png"); + + new TextToImageLiteRequest(request); + request.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/TextToImageLiteResponseTest.java b/unit/hunyuan/TextToImageLiteResponseTest.java new file mode 100644 index 000000000..219ae63f8 --- /dev/null +++ b/unit/hunyuan/TextToImageLiteResponseTest.java @@ -0,0 +1,21 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.TextToImageLiteResponse; +import org.junit.Test; + +import java.util.HashMap; + +public class TextToImageLiteResponseTest { + @Test + public void testTextToImageLiteResponse() { + TextToImageLiteResponse response = new TextToImageLiteResponse(); + response.setRequestId("requestId"); + assert response.getRequestId().equals("requestId"); + + response.setResultImage("resultImage"); + assert response.getResultImage().equals("resultImage"); + + new TextToImageLiteResponse(response); + response.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/ToolCallFunctionTest.java b/unit/hunyuan/ToolCallFunctionTest.java new file mode 100644 index 000000000..4711190f1 --- /dev/null +++ b/unit/hunyuan/ToolCallFunctionTest.java @@ -0,0 +1,21 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.ToolCallFunction; +import org.junit.Test; + +import java.util.HashMap; + +public class ToolCallFunctionTest { + @Test + public void testToolCallFunction() { + ToolCallFunction toolCallFunction = new ToolCallFunction(); + toolCallFunction.setName("test"); + assert toolCallFunction.getName().equals("test"); + + toolCallFunction.setArguments("test"); + assert toolCallFunction.getArguments().equals("test"); + + new ToolCallFunction(toolCallFunction); + toolCallFunction.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/ToolCallTest.java b/unit/hunyuan/ToolCallTest.java new file mode 100644 index 000000000..7c343c3bd --- /dev/null +++ b/unit/hunyuan/ToolCallTest.java @@ -0,0 +1,25 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.ToolCall; +import com.tencentcloudapi.hunyuan.v20230901.models.ToolCallFunction; +import org.junit.Test; + +import java.util.HashMap; + +public class ToolCallTest { + @Test + public void testToolCall() { + ToolCall toolCall = new ToolCall(); + toolCall.setId("111"); + assert toolCall.getId().equals("111"); + + toolCall.setType("test"); + assert toolCall.getType().equals("test"); + + toolCall.setFunction(new ToolCallFunction()); + toolCall.getFunction().setName("test"); + + new ToolCall(toolCall); + toolCall.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/ToolFunctionTest.java b/unit/hunyuan/ToolFunctionTest.java new file mode 100644 index 000000000..9a9885339 --- /dev/null +++ b/unit/hunyuan/ToolFunctionTest.java @@ -0,0 +1,24 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.ToolFunction; +import org.junit.Test; + +import java.util.HashMap; + +public class ToolFunctionTest { + @Test + public void testToolFunction() { + ToolFunction toolFunction = new ToolFunction(); + toolFunction.setName("test"); + assert toolFunction.getName().equals("test"); + + toolFunction.setParameters("test"); + assert toolFunction.getParameters().equals("test"); + + toolFunction.setDescription("test"); + assert toolFunction.getDescription().equals("test"); + + new ToolFunction(toolFunction); + toolFunction.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuan/ToolTest.java b/unit/hunyuan/ToolTest.java new file mode 100644 index 000000000..a26e0ca8a --- /dev/null +++ b/unit/hunyuan/ToolTest.java @@ -0,0 +1,19 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.Tool; +import com.tencentcloudapi.hunyuan.v20230901.models.ToolFunction; +import org.junit.Test; + +public class ToolTest { + @Test + public void testTool() { + Tool tool = new Tool(); + tool.setType("type"); + assert tool.getType().equals("type"); + + tool.setFunction(new ToolFunction()); + tool.getFunction().setName("name"); + + new Tool(tool); + } +} diff --git a/unit/hunyuan/UsageTest.java b/unit/hunyuan/UsageTest.java new file mode 100644 index 000000000..2622934d8 --- /dev/null +++ b/unit/hunyuan/UsageTest.java @@ -0,0 +1,24 @@ +package com.tencentcloudapi.unit.hunyuan; + +import com.tencentcloudapi.hunyuan.v20230901.models.Usage; +import org.junit.Test; + +import java.util.HashMap; + +public class UsageTest { + @Test + public void testUsage() { + Usage usage = new Usage(); + usage.setPromptTokens(1L); + assert usage.getPromptTokens() == 1L; + + usage.setCompletionTokens(2L); + assert usage.getCompletionTokens() == 2L; + + usage.setTotalTokens(3L); + assert usage.getTotalTokens() == 3L; + + new Usage(usage); + usage.toMap(new HashMap<>(), ""); + } +} diff --git a/unit/hunyuanclient/HunyuanClientTest.java b/unit/hunyuanclient/HunyuanClientTest.java new file mode 100644 index 000000000..bd8a8a06b --- /dev/null +++ b/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/unit/hunyuanclient/HunyuanErrorCodeTest.java b/unit/hunyuanclient/HunyuanErrorCodeTest.java new file mode 100644 index 000000000..6ed8d5bc2 --- /dev/null +++ b/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()); + } +} From 63d733e6106c67ed061a9a1abfcdd1600b3d8efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=87=E6=9D=B0?= <72617766+19916302128@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:23:27 +0800 Subject: [PATCH 2/4] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 010c02789..da07b445f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.tencentcloudapi tencentcloud-sdk-java - 3.1.1070 + 3.1.1091 jar tencentcloud-sdk-java https://cloud.tencent.com/ From d149bb6c4904f82c980f3eebde0b84653387a899 Mon Sep 17 00:00:00 2001 From: wenjiezzou Date: Sun, 29 Sep 2024 17:56:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0java-sdk=E7=9A=84?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=EF=BC=8C=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unit}/common/AbstractClientInitTest.java | 0 .../AbstractClientInternalRequestTest.java | 0 .../unit}/common/AbstractClientPrivateTest.java | 16 ---------------- .../unit}/common/AbstractModelTest.java | 0 .../unit}/common/CredentialTest.java | 0 .../unit}/common/HttpConnectionTest.java | 0 .../unit}/common/HttpProfileTest.java | 0 .../unit}/common/OIDCRoleArnProviderTest.java | 0 .../tencentcloudapi/unit}/common/RegionTest.java | 0 .../unit}/common/SSEResponseModelTest.java | 0 .../tencentcloudapi/unit}/common/SignTest.java | 0 .../hunyuan/ChatCompletionsRequestTest.java | 0 .../hunyuan/ChatCompletionsResponseTest.java | 0 .../unit}/hunyuan/ChoiceTest.java | 0 .../unit}/hunyuan/ContentTest.java | 0 .../tencentcloudapi/unit}/hunyuan/DeltaTest.java | 0 .../unit}/hunyuan/EmbeddingDataTest.java | 0 .../unit}/hunyuan/EmbeddingUsageTest.java | 0 .../unit}/hunyuan/ErrorMsgTest.java | 0 .../unit}/hunyuan/GetEmbeddingRequestTest.java | 0 .../unit}/hunyuan/GetEmbeddingResponseTest.java | 0 .../unit}/hunyuan/GetTokenCountRequestTest.java | 0 .../unit}/hunyuan/GetTokenCountResponseTest.java | 0 .../unit}/hunyuan/LogoParamTest.java | 0 .../unit}/hunyuan/LogoRectTest.java | 0 .../unit}/hunyuan/MessageTest.java | 0 .../hunyuan/QueryHunyuanImageJobRequestTest.java | 0 .../QueryHunyuanImageJobResponseTest.java | 0 .../unit}/hunyuan/SearchInfoTest.java | 0 .../unit}/hunyuan/SearchResultTest.java | 0 .../SubmitHunyuanImageJobRequestTest.java | 0 .../SubmitHunyuanImageJobResponseTest.java | 0 .../hunyuan/TextToImageLiteRequestTest.java | 0 .../hunyuan/TextToImageLiteResponseTest.java | 0 .../unit}/hunyuan/ToolCallFunctionTest.java | 0 .../unit}/hunyuan/ToolCallTest.java | 0 .../unit}/hunyuan/ToolFunctionTest.java | 0 .../tencentcloudapi/unit}/hunyuan/ToolTest.java | 0 .../tencentcloudapi/unit}/hunyuan/UsageTest.java | 0 .../unit}/hunyuanclient/HunyuanClientTest.java | 0 .../hunyuanclient/HunyuanErrorCodeTest.java | 0 41 files changed, 16 deletions(-) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/AbstractClientInitTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/AbstractClientInternalRequestTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/AbstractClientPrivateTest.java (94%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/AbstractModelTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/CredentialTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/HttpConnectionTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/HttpProfileTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/OIDCRoleArnProviderTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/RegionTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/SSEResponseModelTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/common/SignTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ChatCompletionsRequestTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ChatCompletionsResponseTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ChoiceTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ContentTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/DeltaTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/EmbeddingDataTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/EmbeddingUsageTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ErrorMsgTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/GetEmbeddingRequestTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/GetEmbeddingResponseTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/GetTokenCountRequestTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/GetTokenCountResponseTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/LogoParamTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/LogoRectTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/MessageTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/QueryHunyuanImageJobRequestTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/QueryHunyuanImageJobResponseTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/SearchInfoTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/SearchResultTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/SubmitHunyuanImageJobRequestTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/SubmitHunyuanImageJobResponseTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/TextToImageLiteRequestTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/TextToImageLiteResponseTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ToolCallFunctionTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ToolCallTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ToolFunctionTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/ToolTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuan/UsageTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuanclient/HunyuanClientTest.java (100%) rename {unit => src/test/java/com/tencentcloudapi/unit}/hunyuanclient/HunyuanErrorCodeTest.java (100%) diff --git a/unit/common/AbstractClientInitTest.java b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientInitTest.java similarity index 100% rename from unit/common/AbstractClientInitTest.java rename to src/test/java/com/tencentcloudapi/unit/common/AbstractClientInitTest.java diff --git a/unit/common/AbstractClientInternalRequestTest.java b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientInternalRequestTest.java similarity index 100% rename from unit/common/AbstractClientInternalRequestTest.java rename to src/test/java/com/tencentcloudapi/unit/common/AbstractClientInternalRequestTest.java diff --git a/unit/common/AbstractClientPrivateTest.java b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientPrivateTest.java similarity index 94% rename from unit/common/AbstractClientPrivateTest.java rename to src/test/java/com/tencentcloudapi/unit/common/AbstractClientPrivateTest.java index 6d304acb2..c5aab57ed 100644 --- a/unit/common/AbstractClientPrivateTest.java +++ b/src/test/java/com/tencentcloudapi/unit/common/AbstractClientPrivateTest.java @@ -56,22 +56,6 @@ public void testAbstractClientGetHeaders() throws Exception { assert "UNSIGNED-PAYLOAD" == map.get("X-TC-Content-SHA256"); } - @Test - public void testAbstractClientGetResponseBody() throws Exception { - client = new AbstractClient(endpoint, version, credential, region, clientProfile) { - }; - - String url = "https://example.com/api"; - Map headers = new HashMap<>(); - headers.put("Content-Type", "application/json"); - byte[] body = "{\"key\":\"value\"}".getBytes(); - try { - Whitebox.invokeMethod(client, "getResponseBody", url, headers, body); - } catch (TencentCloudSDKException e) { - assert e.getMessage().contains("404"); - } - } - @Test public void testAbstractClientTrySetProxy() throws Exception { HttpProfile httpProfile = new HttpProfile(); diff --git a/unit/common/AbstractModelTest.java b/src/test/java/com/tencentcloudapi/unit/common/AbstractModelTest.java similarity index 100% rename from unit/common/AbstractModelTest.java rename to src/test/java/com/tencentcloudapi/unit/common/AbstractModelTest.java diff --git a/unit/common/CredentialTest.java b/src/test/java/com/tencentcloudapi/unit/common/CredentialTest.java similarity index 100% rename from unit/common/CredentialTest.java rename to src/test/java/com/tencentcloudapi/unit/common/CredentialTest.java diff --git a/unit/common/HttpConnectionTest.java b/src/test/java/com/tencentcloudapi/unit/common/HttpConnectionTest.java similarity index 100% rename from unit/common/HttpConnectionTest.java rename to src/test/java/com/tencentcloudapi/unit/common/HttpConnectionTest.java diff --git a/unit/common/HttpProfileTest.java b/src/test/java/com/tencentcloudapi/unit/common/HttpProfileTest.java similarity index 100% rename from unit/common/HttpProfileTest.java rename to src/test/java/com/tencentcloudapi/unit/common/HttpProfileTest.java diff --git a/unit/common/OIDCRoleArnProviderTest.java b/src/test/java/com/tencentcloudapi/unit/common/OIDCRoleArnProviderTest.java similarity index 100% rename from unit/common/OIDCRoleArnProviderTest.java rename to src/test/java/com/tencentcloudapi/unit/common/OIDCRoleArnProviderTest.java diff --git a/unit/common/RegionTest.java b/src/test/java/com/tencentcloudapi/unit/common/RegionTest.java similarity index 100% rename from unit/common/RegionTest.java rename to src/test/java/com/tencentcloudapi/unit/common/RegionTest.java diff --git a/unit/common/SSEResponseModelTest.java b/src/test/java/com/tencentcloudapi/unit/common/SSEResponseModelTest.java similarity index 100% rename from unit/common/SSEResponseModelTest.java rename to src/test/java/com/tencentcloudapi/unit/common/SSEResponseModelTest.java diff --git a/unit/common/SignTest.java b/src/test/java/com/tencentcloudapi/unit/common/SignTest.java similarity index 100% rename from unit/common/SignTest.java rename to src/test/java/com/tencentcloudapi/unit/common/SignTest.java diff --git a/unit/hunyuan/ChatCompletionsRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsRequestTest.java similarity index 100% rename from unit/hunyuan/ChatCompletionsRequestTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsRequestTest.java diff --git a/unit/hunyuan/ChatCompletionsResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsResponseTest.java similarity index 100% rename from unit/hunyuan/ChatCompletionsResponseTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ChatCompletionsResponseTest.java diff --git a/unit/hunyuan/ChoiceTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ChoiceTest.java similarity index 100% rename from unit/hunyuan/ChoiceTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ChoiceTest.java diff --git a/unit/hunyuan/ContentTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ContentTest.java similarity index 100% rename from unit/hunyuan/ContentTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ContentTest.java diff --git a/unit/hunyuan/DeltaTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/DeltaTest.java similarity index 100% rename from unit/hunyuan/DeltaTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/DeltaTest.java diff --git a/unit/hunyuan/EmbeddingDataTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingDataTest.java similarity index 100% rename from unit/hunyuan/EmbeddingDataTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingDataTest.java diff --git a/unit/hunyuan/EmbeddingUsageTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingUsageTest.java similarity index 100% rename from unit/hunyuan/EmbeddingUsageTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/EmbeddingUsageTest.java diff --git a/unit/hunyuan/ErrorMsgTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ErrorMsgTest.java similarity index 100% rename from unit/hunyuan/ErrorMsgTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ErrorMsgTest.java diff --git a/unit/hunyuan/GetEmbeddingRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingRequestTest.java similarity index 100% rename from unit/hunyuan/GetEmbeddingRequestTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingRequestTest.java diff --git a/unit/hunyuan/GetEmbeddingResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingResponseTest.java similarity index 100% rename from unit/hunyuan/GetEmbeddingResponseTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingResponseTest.java diff --git a/unit/hunyuan/GetTokenCountRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountRequestTest.java similarity index 100% rename from unit/hunyuan/GetTokenCountRequestTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountRequestTest.java diff --git a/unit/hunyuan/GetTokenCountResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountResponseTest.java similarity index 100% rename from unit/hunyuan/GetTokenCountResponseTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountResponseTest.java diff --git a/unit/hunyuan/LogoParamTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/LogoParamTest.java similarity index 100% rename from unit/hunyuan/LogoParamTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/LogoParamTest.java diff --git a/unit/hunyuan/LogoRectTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/LogoRectTest.java similarity index 100% rename from unit/hunyuan/LogoRectTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/LogoRectTest.java diff --git a/unit/hunyuan/MessageTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/MessageTest.java similarity index 100% rename from unit/hunyuan/MessageTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/MessageTest.java diff --git a/unit/hunyuan/QueryHunyuanImageJobRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobRequestTest.java similarity index 100% rename from unit/hunyuan/QueryHunyuanImageJobRequestTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobRequestTest.java diff --git a/unit/hunyuan/QueryHunyuanImageJobResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobResponseTest.java similarity index 100% rename from unit/hunyuan/QueryHunyuanImageJobResponseTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobResponseTest.java diff --git a/unit/hunyuan/SearchInfoTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/SearchInfoTest.java similarity index 100% rename from unit/hunyuan/SearchInfoTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/SearchInfoTest.java diff --git a/unit/hunyuan/SearchResultTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/SearchResultTest.java similarity index 100% rename from unit/hunyuan/SearchResultTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/SearchResultTest.java diff --git a/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java similarity index 100% rename from unit/hunyuan/SubmitHunyuanImageJobRequestTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java diff --git a/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java similarity index 100% rename from unit/hunyuan/SubmitHunyuanImageJobResponseTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java diff --git a/unit/hunyuan/TextToImageLiteRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteRequestTest.java similarity index 100% rename from unit/hunyuan/TextToImageLiteRequestTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteRequestTest.java diff --git a/unit/hunyuan/TextToImageLiteResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteResponseTest.java similarity index 100% rename from unit/hunyuan/TextToImageLiteResponseTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteResponseTest.java diff --git a/unit/hunyuan/ToolCallFunctionTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallFunctionTest.java similarity index 100% rename from unit/hunyuan/ToolCallFunctionTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallFunctionTest.java diff --git a/unit/hunyuan/ToolCallTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallTest.java similarity index 100% rename from unit/hunyuan/ToolCallTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallTest.java diff --git a/unit/hunyuan/ToolFunctionTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolFunctionTest.java similarity index 100% rename from unit/hunyuan/ToolFunctionTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ToolFunctionTest.java diff --git a/unit/hunyuan/ToolTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolTest.java similarity index 100% rename from unit/hunyuan/ToolTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/ToolTest.java diff --git a/unit/hunyuan/UsageTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/UsageTest.java similarity index 100% rename from unit/hunyuan/UsageTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuan/UsageTest.java diff --git a/unit/hunyuanclient/HunyuanClientTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanClientTest.java similarity index 100% rename from unit/hunyuanclient/HunyuanClientTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanClientTest.java diff --git a/unit/hunyuanclient/HunyuanErrorCodeTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanErrorCodeTest.java similarity index 100% rename from unit/hunyuanclient/HunyuanErrorCodeTest.java rename to src/test/java/com/tencentcloudapi/unit/hunyuanclient/HunyuanErrorCodeTest.java From d0c0cc3e1a1836e8438813ac1d8978c1c7813718 Mon Sep 17 00:00:00 2001 From: wenjiezzou Date: Mon, 18 Nov 2024 19:53:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=BF=87=E5=A4=9A?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=8F=AA=E5=89=A9=E4=B8=8B?= =?UTF-8?q?part1=E7=9A=84=E9=9C=80=E8=A6=81cr=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unit/common/CredentialTest.java | 41 ---------- .../unit/common/HttpConnectionTest.java | 76 ----------------- .../unit/common/HttpProfileTest.java | 25 ------ .../unit/common/OIDCRoleArnProviderTest.java | 17 ---- .../unit/common/RegionTest.java | 34 -------- .../unit/common/SSEResponseModelTest.java | 81 ------------------- .../tencentcloudapi/unit/common/SignTest.java | 24 ------ .../hunyuan/GetEmbeddingResponseTest.java | 26 ------ .../hunyuan/GetTokenCountRequestTest.java | 18 ----- .../hunyuan/GetTokenCountResponseTest.java | 30 ------- .../unit/hunyuan/LogoParamTest.java | 22 ----- .../unit/hunyuan/LogoRectTest.java | 27 ------- .../unit/hunyuan/MessageTest.java | 29 ------- .../QueryHunyuanImageJobRequestTest.java | 18 ----- .../QueryHunyuanImageJobResponseTest.java | 39 --------- .../unit/hunyuan/SearchInfoTest.java | 19 ----- .../unit/hunyuan/SearchResultTest.java | 24 ------ .../SubmitHunyuanImageJobRequestTest.java | 40 --------- .../SubmitHunyuanImageJobResponseTest.java | 20 ----- .../hunyuan/TextToImageLiteRequestTest.java | 37 --------- .../hunyuan/TextToImageLiteResponseTest.java | 21 ----- .../unit/hunyuan/ToolCallFunctionTest.java | 21 ----- .../unit/hunyuan/ToolCallTest.java | 25 ------ .../unit/hunyuan/ToolFunctionTest.java | 24 ------ .../unit/hunyuan/ToolTest.java | 19 ----- .../unit/hunyuan/UsageTest.java | 24 ------ 26 files changed, 781 deletions(-) delete mode 100644 src/test/java/com/tencentcloudapi/unit/common/CredentialTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/common/HttpConnectionTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/common/HttpProfileTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/common/OIDCRoleArnProviderTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/common/RegionTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/common/SSEResponseModelTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/common/SignTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingResponseTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountRequestTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountResponseTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/LogoParamTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/LogoRectTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/MessageTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobRequestTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobResponseTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/SearchInfoTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/SearchResultTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteRequestTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteResponseTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallFunctionTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/ToolFunctionTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/ToolTest.java delete mode 100644 src/test/java/com/tencentcloudapi/unit/hunyuan/UsageTest.java diff --git a/src/test/java/com/tencentcloudapi/unit/common/CredentialTest.java b/src/test/java/com/tencentcloudapi/unit/common/CredentialTest.java deleted file mode 100644 index 2982ecd28..000000000 --- a/src/test/java/com/tencentcloudapi/unit/common/CredentialTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.tencentcloudapi.unit.common; - -import com.tencentcloudapi.common.Credential; -import com.tencentcloudapi.common.exception.TencentCloudSDKException; -import org.junit.Test; -import org.powermock.reflect.Whitebox; - -public class CredentialTest { - @Test - public void testCredential() throws Exception { - class CredentialUpdater implements Credential.Updater { - @Override - public void update(Credential credential) throws TencentCloudSDKException { - throw new TencentCloudSDKException("test"); - } - } - CredentialUpdater updater = new CredentialUpdater(); - Credential credential = new Credential("secretId", "secretKey", "token", updater); - credential.getUpdater(); - credential.setUpdater(new CredentialUpdater()); - credential.setSecretId("secretId"); - credential.setSecretKey("secretKey"); - credential.setToken("token"); - - try { - Whitebox.invokeMethod(credential, "tryUpdate"); - } catch (Exception e) { - assert e.getMessage().contains("test"); - } - - Credential cred = new Credential(); - class testUpdater implements Credential.Updater { - @Override - public void update(Credential credential) throws TencentCloudSDKException { - } - } - testUpdater testUpdater = new testUpdater(); - Credential cred1 = new Credential("secretId", "secretKey", "token", testUpdater); - Whitebox.invokeMethod(cred1, "tryUpdate"); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/common/HttpConnectionTest.java b/src/test/java/com/tencentcloudapi/unit/common/HttpConnectionTest.java deleted file mode 100644 index 697e9ad9f..000000000 --- a/src/test/java/com/tencentcloudapi/unit/common/HttpConnectionTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.tencentcloudapi.unit.common; - -import com.tencentcloudapi.common.exception.TencentCloudSDKException; -import com.tencentcloudapi.common.http.HttpConnection; -import okhttp3.Headers; -import org.junit.Test; - -import javax.net.ssl.SSLSocketFactory; -import java.io.IOException; -import java.net.InetAddress; -import java.net.Socket; -import java.net.UnknownHostException; - -public class HttpConnectionTest { - @Test - public void testGetRequest() throws IOException { - HttpConnection httpConnection = new HttpConnection(1, 1, 1); - try { - httpConnection.getRequest(""); - } catch (TencentCloudSDKException e) { - e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); - } - } - - @Test - public void testGetRequestWithHeaders() throws IOException { - HttpConnection httpConnection = new HttpConnection(1, 1, 1); - Headers headers = new Headers.Builder().build(); - try { - httpConnection.getRequest("", headers); - } catch (TencentCloudSDKException e) { - e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); - } - } - - @Test - public void testPostRequest() throws IOException { - HttpConnection httpConnection = new HttpConnection(1, 1, 1); - try { - httpConnection.postRequest("", "body"); - } catch (TencentCloudSDKException e) { - e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); - } - } - - @Test - public void testPostRequestWithHeaders() throws IOException, TencentCloudSDKException { - HttpConnection httpConnection = new HttpConnection(1, 1, 1); - Headers headers = new Headers.Builder() - .add("Content-Type", "application/json") // 添加Content-Type头部字段 - .add("User-Agent", "OkHttp/3.12.12") // 添加User-Agent头部字段 - .build(); - httpConnection.postRequest("https://www.example.com", "body", headers); - - try { - httpConnection.postRequest("", "body", headers); - } catch (TencentCloudSDKException e) { - e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); - } - } - - @Test - public void testPostRequestWithArrayBody() throws IOException, TencentCloudSDKException { - HttpConnection httpConnection = new HttpConnection(1, 1, 1); - Headers headers = new Headers.Builder() - .add("Content-Type", "application/json") // 添加Content-Type头部字段 - .add("User-Agent", "OkHttp/3.12.12") // 添加User-Agent头部字段 - .build(); - byte[] body = "body".getBytes(); - try { - httpConnection.postRequest("", body, headers); - } catch (TencentCloudSDKException e) { - e.getMessage().contains("URL scheme 'http' or 'https' but no colon was found"); - } - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/common/HttpProfileTest.java b/src/test/java/com/tencentcloudapi/unit/common/HttpProfileTest.java deleted file mode 100644 index ed117f1f5..000000000 --- a/src/test/java/com/tencentcloudapi/unit/common/HttpProfileTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.tencentcloudapi.unit.common; - -import com.tencentcloudapi.common.profile.HttpProfile; -import org.junit.Test; - -public class HttpProfileTest { - @Test - public void testHttpProfile() { - HttpProfile profile = new HttpProfile(); - profile.setEndpoint("https://unit.tencentcloudapi.com"); - assert profile.getEndpoint().equals("https://unit.tencentcloudapi.com"); - profile.setReadTimeout(10000); - assert profile.getReadTimeout() == 10000; - profile.setWriteTimeout(10000); - assert profile.getWriteTimeout() == 10000; - profile.setConnTimeout(10000); - assert profile.getConnTimeout() == 10000; - profile.setProtocol("http"); - assert profile.getProtocol().equals("http"); - profile.setRootDomain("unit.tencentcloudapi.com"); - assert profile.getRootDomain().equals("unit.tencentcloudapi.com"); - profile.setApigwEndpoint("https://unit.tencentcloudapi.com"); - assert profile.getApigwEndpoint().equals("https://unit.tencentcloudapi.com"); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/common/OIDCRoleArnProviderTest.java b/src/test/java/com/tencentcloudapi/unit/common/OIDCRoleArnProviderTest.java deleted file mode 100644 index 45ad7c8aa..000000000 --- a/src/test/java/com/tencentcloudapi/unit/common/OIDCRoleArnProviderTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.tencentcloudapi.unit.common; - -import com.tencentcloudapi.common.exception.TencentCloudSDKException; -import com.tencentcloudapi.common.provider.OIDCRoleArnProvider; -import org.junit.Test; -import org.powermock.reflect.Whitebox; - - -public class OIDCRoleArnProviderTest { - @Test - public void testOIDCRoleArnProviderInit() throws TencentCloudSDKException { - OIDCRoleArnProvider oidcRoleArnProvider = new OIDCRoleArnProvider("ap-shanghai", "", "", "", "", 0L); - oidcRoleArnProvider.ExpirationReservationTime = 0L; - Whitebox.setInternalState(oidcRoleArnProvider,"isTke",false); - - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/common/RegionTest.java b/src/test/java/com/tencentcloudapi/unit/common/RegionTest.java deleted file mode 100644 index 5977eb1a5..000000000 --- a/src/test/java/com/tencentcloudapi/unit/common/RegionTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.tencentcloudapi.unit.common; - -import com.tencentcloudapi.common.profile.Region; -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; - -public class RegionTest { - @Test - public void testRegion() { - String[] expectedRegions = { - "ap-bangkok", "ap-beijing", "ap-chengdu", "ap-chongqing", "ap-guangzhou", "ap-guangzhou-open", - "ap-hongkong", "ap-mumbai", "ap-seoul", "ap-shanghai", "ap-shanghai-fsi", "ap-shenzhen-fsi", - "ap-singapore", "ap-tokyo", "eu-frankfurt", "eu-moscow", "na-ashburn", "na-siliconvalley", "na-toronto" - }; - for (String expectedRegion : expectedRegions) { - boolean found = false; - for (Region region : Region.values()) { - if (region.getValue().equals(expectedRegion)) { - found = true; - break; - } - } - assertTrue("Expected region " + expectedRegion + " to be present", found); - } - } - - @Test - public void testRegionValue() { - assertEquals("ap-bangkok", Region.Bangkok.getValue()); - assertEquals("ap-bangkok", Region.Bangkok.toString()); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/common/SSEResponseModelTest.java b/src/test/java/com/tencentcloudapi/unit/common/SSEResponseModelTest.java deleted file mode 100644 index dfd812c0c..000000000 --- a/src/test/java/com/tencentcloudapi/unit/common/SSEResponseModelTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.tencentcloudapi.unit.common; - -import com.tencentcloudapi.common.SSEResponseModel; -import com.tencentcloudapi.common.exception.TencentCloudSDKException; -import okhttp3.*; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.mockito.Mockito; -import org.powermock.reflect.Whitebox; - -import java.util.*; - -public class SSEResponseModelTest { - @Test - public void SSETest() throws Exception { - SSEResponseModel.SSE sse = new SSEResponseModel.SSE(); - sse.Id = "123"; - sse.Event = "123"; - sse.Data = "2024"; - sse.Retry = 0l; - assert sse.toString().equals("Id=123 Event=123 Retry=0 Data=2024"); - } - - @Test - public void SSEIteratorTest() throws Exception { - SSEModelTest sse = new SSEModelTest(); - Map map = new HashMap(); - Whitebox.invokeMethod(sse, "toMap", map, "prefix"); - - Request request = new Request.Builder() - .url("https://example.com") - .build(); - // 创建一个MediaType实例,指定响应体的媒体类型为JSON - MediaType jsonMediaType = MediaType.parse("application/json; charset=utf-8"); - - // 创建一个字符串作为响应体的内容 - String responseBodyContent = "{\"key\":\"value\"}"; - - // 使用ResponseBody.create方法创建一个ResponseBody实例 - ResponseBody responseBody = ResponseBody.create(jsonMediaType, responseBodyContent); - Response.Builder builder = new Response.Builder() - .request(request) // 设置请求对象 - .protocol(Protocol.HTTP_2) // 设置协议版本,这里以HTTP/2为例 - .code(200) // 设置响应码 - .message("OK"); // 设置响应消息; - Response response = builder.build(); - Whitebox.setInternalState(sse, "response", response); - - Iterator iterator; - try { - iterator = sse.iterator(); - } catch (RuntimeException e) { - assert e.getMessage().contains("Response body should not be null"); - } - builder.body(responseBody); - response = builder.build(); - Whitebox.setInternalState(sse, "response", response); - iterator = sse.iterator(); - - iterator.hasNext(); - iterator.remove(); - try { - iterator.next(); - }catch (Exception e){ - assert e.getMessage().contains("No line found"); - } - Whitebox.invokeMethod(sse, "close"); - } -} - -class SSEModelTest extends SSEResponseModel { - @Override - public String getRequestId() { - return ""; - } - - @Override - public void setRequestId(String requestId) { - } -} \ No newline at end of file diff --git a/src/test/java/com/tencentcloudapi/unit/common/SignTest.java b/src/test/java/com/tencentcloudapi/unit/common/SignTest.java deleted file mode 100644 index 1ca194a3a..000000000 --- a/src/test/java/com/tencentcloudapi/unit/common/SignTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.tencentcloudapi.unit.common; - -import com.tencentcloudapi.common.Sign; -import com.tencentcloudapi.common.exception.TencentCloudSDKException; -import org.junit.Test; - -public class SignTest { - @Test - public void testSign() throws TencentCloudSDKException { - Sign sign = new Sign(); - try { - sign.sign("1", "1", "1"); - } catch (TencentCloudSDKException e) { - assert e.getMessage().contains("1 not available"); - } - } - - @Test - public void testSha256Hex() throws TencentCloudSDKException { - Sign sign = new Sign(); - String s = sign.sha256Hex("1"); - assert s.equals("6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b"); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingResponseTest.java deleted file mode 100644 index 5a0ca910f..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/GetEmbeddingResponseTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.EmbeddingData; -import com.tencentcloudapi.hunyuan.v20230901.models.EmbeddingUsage; -import com.tencentcloudapi.hunyuan.v20230901.models.GetEmbeddingResponse; -import org.junit.Test; - -import java.util.HashMap; - -public class GetEmbeddingResponseTest { - @Test - public void testGetEmbeddingResponse() { - GetEmbeddingResponse response = new GetEmbeddingResponse(); - response.setData(new EmbeddingData[]{}); - assert response.getData().length == 0; - - response.setUsage(new EmbeddingUsage()); - response.getUsage().setPromptTokens(1L); - - response.setRequestId("test"); - assert response.getRequestId().equals("test"); - - new GetEmbeddingResponse(response); - response.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountRequestTest.java deleted file mode 100644 index 11bf036b0..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountRequestTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.GetTokenCountRequest; -import org.junit.Test; - -import java.util.HashMap; - -public class GetTokenCountRequestTest { - @Test - public void testGetTokenCountRequest() { - GetTokenCountRequest request = new GetTokenCountRequest(); - request.setPrompt("test"); - assert request.getPrompt().equals("test"); - - new GetTokenCountRequest(request); - request.toMap(new HashMap(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountResponseTest.java deleted file mode 100644 index 2213a8dc5..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/GetTokenCountResponseTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.GetTokenCountResponse; -import org.junit.Test; - -import java.util.HashMap; - -public class GetTokenCountResponseTest { - @Test - public void TestGetTokenCountResponse() { - GetTokenCountResponse response = new GetTokenCountResponse(); - response.setTokenCount(1L); - assert response.getTokenCount() == 1L; - - response.setTokenCount(2L); - assert response.getTokenCount() == 2L; - - response.setTokens(new String[]{"a", "b", "c"}); - assert response.getTokens().length == 3; - - response.setCharacterCount(1L); - assert response.getCharacterCount() == 1L; - - response.setRequestId("123"); - assert response.getRequestId().equals("123"); - - new GetTokenCountResponse(response); - response.toMap(new HashMap(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/LogoParamTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/LogoParamTest.java deleted file mode 100644 index c82d9670a..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/LogoParamTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.LogoParam; -import com.tencentcloudapi.hunyuan.v20230901.models.LogoRect; -import org.junit.Test; - -public class LogoParamTest { - @Test - public void testLogoParam() { - LogoParam logoParam = new LogoParam(); - logoParam.setLogoUrl("https://hunyuan.com"); - assert logoParam.getLogoUrl().equals("https://hunyuan.com"); - - logoParam.setLogoImage("logo"); - assert logoParam.getLogoImage().equals("logo"); - - logoParam.setLogoRect(new LogoRect()); - logoParam.getLogoRect().setX(10L); - - new LogoParam(logoParam); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/LogoRectTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/LogoRectTest.java deleted file mode 100644 index da361e0d3..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/LogoRectTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.LogoRect; -import org.junit.Test; - -import java.util.HashMap; - -public class LogoRectTest { - @Test - public void testLogoRect() { - LogoRect logoRect = new LogoRect(); - logoRect.setX(1L); - assert logoRect.getX() == 1L; - - logoRect.setY(1L); - assert logoRect.getY() == 1L; - - logoRect.setWidth(2L); - assert logoRect.getWidth() == 2L; - - logoRect.setHeight(2L); - assert logoRect.getHeight() == 2L; - - new LogoRect(logoRect); - logoRect.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/MessageTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/MessageTest.java deleted file mode 100644 index 3a35edf7d..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/MessageTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.Content; -import com.tencentcloudapi.hunyuan.v20230901.models.Message; -import com.tencentcloudapi.hunyuan.v20230901.models.ToolCall; -import org.junit.Test; - -public class MessageTest { - @Test - public void testMessage() { - Message message = new Message(); - message.setRole("role"); - assert message.getRole().equals("role"); - - message.setContent("content"); - assert message.getContent().equals("content"); - - message.setContents(new Content[]{new Content()}); - assert message.getContents().length == 1; - - message.setToolCallId("toolCallId"); - assert message.getToolCallId().equals("toolCallId"); - - message.setToolCalls(new ToolCall[]{new ToolCall()}); - assert message.getToolCalls().length == 1; - - new Message(message); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobRequestTest.java deleted file mode 100644 index b59880b28..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobRequestTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.QueryHunyuanImageJobRequest; -import org.junit.Test; - -import java.util.HashMap; - -public class QueryHunyuanImageJobRequestTest { - @Test - public void testQueryHunyuanImageJobRequest() { - QueryHunyuanImageJobRequest request = new QueryHunyuanImageJobRequest(); - request.setJobId("jobId"); - assert request.getJobId().equals("jobId"); - - new QueryHunyuanImageJobRequest(request); - request.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobResponseTest.java deleted file mode 100644 index 391abd7b1..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/QueryHunyuanImageJobResponseTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.QueryHunyuanImageJobResponse; -import org.junit.Test; - -import java.util.HashMap; - -public class QueryHunyuanImageJobResponseTest { - @Test - public void testQueryHunyuanImageJobResponse() { - QueryHunyuanImageJobResponse response = new QueryHunyuanImageJobResponse(); - response.setJobStatusCode("1"); - assert response.getJobStatusCode().equals("1"); - - response.setJobStatusMsg("排队中"); - assert response.getJobStatusMsg().equals("排队中"); - - response.setJobErrorCode("1"); - assert response.getJobErrorCode().equals("1"); - - response.setJobErrorMsg("处理失败"); - assert response.getJobErrorMsg().equals("处理失败"); - - response.setResultImage(new String[]{"1"}); - assert response.getResultImage()[0].equals("1"); - - response.setResultDetails(new String[]{"1"}); - assert response.getResultDetails()[0].equals("1"); - - response.setRevisedPrompt(new String[]{"1"}); - assert response.getRevisedPrompt()[0].equals("1"); - - response.setRequestId("requestId"); - assert response.getRequestId().equals("requestId"); - - new QueryHunyuanImageJobResponse(response); - response.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/SearchInfoTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/SearchInfoTest.java deleted file mode 100644 index 17caf361f..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/SearchInfoTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.SearchInfo; -import com.tencentcloudapi.hunyuan.v20230901.models.SearchResult; -import org.junit.Test; - -import java.util.HashMap; - -public class SearchInfoTest { - @Test - public void testSearchInfo() { - SearchInfo searchInfo = new SearchInfo(); - searchInfo.setSearchResults(new SearchResult[]{new SearchResult(), new SearchResult()}); - assert searchInfo.getSearchResults().length == 2; - - new SearchInfo(searchInfo); - searchInfo.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/SearchResultTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/SearchResultTest.java deleted file mode 100644 index 94b6f5641..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/SearchResultTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.SearchResult; -import org.junit.Test; - -import java.util.HashMap; - -public class SearchResultTest { - @Test - public void testSearchResult() { - SearchResult searchResult = new SearchResult(); - searchResult.setIndex(1L); - assert searchResult.getIndex() == 1L; - - searchResult.setTitle("title"); - assert searchResult.getTitle().equals("title"); - - searchResult.setUrl("url"); - assert searchResult.getUrl().equals("url"); - - new SearchResult(searchResult); - searchResult.toMap(new HashMap<>(), "prefix"); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java deleted file mode 100644 index df736f5a3..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobRequestTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.LogoParam; -import com.tencentcloudapi.hunyuan.v20230901.models.SubmitHunyuanImageJobRequest; -import org.junit.Test; - -import java.util.HashMap; - -public class SubmitHunyuanImageJobRequestTest { - @Test - public void testBuildRequest() { - SubmitHunyuanImageJobRequest request = new SubmitHunyuanImageJobRequest(); - request.setPrompt("test"); - assert request.getPrompt().equals("test"); - - request.setStyle("test"); - assert request.getStyle().equals("test"); - - request.setResolution("768:768(1:1)"); - assert request.getResolution().equals("768:768(1:1)"); - - request.setNum(1L); - assert request.getNum() == 1L; - - request.setSeed(9L); - assert request.getSeed() == 9L; - - request.setRevise(1L); - assert request.getRevise() == 1L; - - request.setLogoAdd(1L); - assert request.getLogoAdd() == 1L; - - request.setLogoParam(new LogoParam()); - request.getLogoParam().setLogoUrl("test"); - - new SubmitHunyuanImageJobRequest(request); - request.toMap(new HashMap(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java deleted file mode 100644 index 3f931ff77..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/SubmitHunyuanImageJobResponseTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.SubmitHunyuanImageJobResponse; -import org.junit.Test; - -import java.util.HashMap; - -public class SubmitHunyuanImageJobResponseTest { - @Test - public void testSubmitHunyuanImageJobResponse() { - SubmitHunyuanImageJobResponse response = new SubmitHunyuanImageJobResponse(); - response.setRequestId("requestId"); - assert response.getRequestId().equals("requestId"); - - response.setJobId("jobId"); - assert response.getJobId().equals("jobId"); - new SubmitHunyuanImageJobResponse(response); - response.toMap(new HashMap<>(), "prefix"); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteRequestTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteRequestTest.java deleted file mode 100644 index 069cf66bc..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteRequestTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.LogoParam; -import com.tencentcloudapi.hunyuan.v20230901.models.TextToImageLiteRequest; -import org.junit.Test; - -import java.util.HashMap; - -public class TextToImageLiteRequestTest { - @Test - public void testTextToImageLiteRequest() { - TextToImageLiteRequest request = new TextToImageLiteRequest(); - request.setPrompt("test"); - assert request.getPrompt().equals("test"); - - request.setNegativePrompt("test"); - assert request.getNegativePrompt().equals("test"); - - request.setStyle("style"); - assert request.getStyle().equals("style"); - - request.setResolution("768:1024(3:4)"); - assert request.getResolution().equals("768:1024(3:4)"); - - request.setLogoAdd(1L); - assert request.getLogoAdd() == 1L; - - request.setLogoParam(new LogoParam()); - request.getLogoParam(); - - request.setRspImgType("png"); - assert request.getRspImgType().equals("png"); - - new TextToImageLiteRequest(request); - request.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteResponseTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteResponseTest.java deleted file mode 100644 index 219ae63f8..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/TextToImageLiteResponseTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.TextToImageLiteResponse; -import org.junit.Test; - -import java.util.HashMap; - -public class TextToImageLiteResponseTest { - @Test - public void testTextToImageLiteResponse() { - TextToImageLiteResponse response = new TextToImageLiteResponse(); - response.setRequestId("requestId"); - assert response.getRequestId().equals("requestId"); - - response.setResultImage("resultImage"); - assert response.getResultImage().equals("resultImage"); - - new TextToImageLiteResponse(response); - response.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallFunctionTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallFunctionTest.java deleted file mode 100644 index 4711190f1..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallFunctionTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.ToolCallFunction; -import org.junit.Test; - -import java.util.HashMap; - -public class ToolCallFunctionTest { - @Test - public void testToolCallFunction() { - ToolCallFunction toolCallFunction = new ToolCallFunction(); - toolCallFunction.setName("test"); - assert toolCallFunction.getName().equals("test"); - - toolCallFunction.setArguments("test"); - assert toolCallFunction.getArguments().equals("test"); - - new ToolCallFunction(toolCallFunction); - toolCallFunction.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallTest.java deleted file mode 100644 index 7c343c3bd..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolCallTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.ToolCall; -import com.tencentcloudapi.hunyuan.v20230901.models.ToolCallFunction; -import org.junit.Test; - -import java.util.HashMap; - -public class ToolCallTest { - @Test - public void testToolCall() { - ToolCall toolCall = new ToolCall(); - toolCall.setId("111"); - assert toolCall.getId().equals("111"); - - toolCall.setType("test"); - assert toolCall.getType().equals("test"); - - toolCall.setFunction(new ToolCallFunction()); - toolCall.getFunction().setName("test"); - - new ToolCall(toolCall); - toolCall.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolFunctionTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolFunctionTest.java deleted file mode 100644 index 9a9885339..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolFunctionTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.ToolFunction; -import org.junit.Test; - -import java.util.HashMap; - -public class ToolFunctionTest { - @Test - public void testToolFunction() { - ToolFunction toolFunction = new ToolFunction(); - toolFunction.setName("test"); - assert toolFunction.getName().equals("test"); - - toolFunction.setParameters("test"); - assert toolFunction.getParameters().equals("test"); - - toolFunction.setDescription("test"); - assert toolFunction.getDescription().equals("test"); - - new ToolFunction(toolFunction); - toolFunction.toMap(new HashMap<>(), ""); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolTest.java deleted file mode 100644 index a26e0ca8a..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/ToolTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.Tool; -import com.tencentcloudapi.hunyuan.v20230901.models.ToolFunction; -import org.junit.Test; - -public class ToolTest { - @Test - public void testTool() { - Tool tool = new Tool(); - tool.setType("type"); - assert tool.getType().equals("type"); - - tool.setFunction(new ToolFunction()); - tool.getFunction().setName("name"); - - new Tool(tool); - } -} diff --git a/src/test/java/com/tencentcloudapi/unit/hunyuan/UsageTest.java b/src/test/java/com/tencentcloudapi/unit/hunyuan/UsageTest.java deleted file mode 100644 index 2622934d8..000000000 --- a/src/test/java/com/tencentcloudapi/unit/hunyuan/UsageTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.tencentcloudapi.unit.hunyuan; - -import com.tencentcloudapi.hunyuan.v20230901.models.Usage; -import org.junit.Test; - -import java.util.HashMap; - -public class UsageTest { - @Test - public void testUsage() { - Usage usage = new Usage(); - usage.setPromptTokens(1L); - assert usage.getPromptTokens() == 1L; - - usage.setCompletionTokens(2L); - assert usage.getCompletionTokens() == 2L; - - usage.setTotalTokens(3L); - assert usage.getTotalTokens() == 3L; - - new Usage(usage); - usage.toMap(new HashMap<>(), ""); - } -}