From e99931dd577fa89b7a53c85f7add208518d8b9cc Mon Sep 17 00:00:00 2001 From: Deyner lopez Date: Tue, 18 Aug 2026 14:57:04 -0500 Subject: [PATCH] feat: added a new integration test for jenkins pipeline --- README.md | 4 +-- integration/pom.xml | 2 +- .../kotlin/com/ccai/integration/TestMain.kt | 30 +++++++++++++++---- pom.xml | 2 +- .../com/cloudcontactai/sdk/sms/SMSService.kt | 12 ++++---- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 4f2e879..1f3106a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Add this dependency to your `pom.xml`: com.cloudcontactai ccai-java-sdk - 1.1.0 + 1.2.0 ``` @@ -41,7 +41,7 @@ Add this dependency to your `pom.xml`: Add this dependency to your `build.gradle`: ```gradle -implementation 'com.cloudcontactai:ccai-java-sdk:1.1.0' +implementation 'com.cloudcontactai:ccai-java-sdk:1.2.0' ``` ## Configuration diff --git a/integration/pom.xml b/integration/pom.xml index d7d951c..04d5107 100644 --- a/integration/pom.xml +++ b/integration/pom.xml @@ -15,7 +15,7 @@ 11 UTF-8 - 1.1.0 + 1.2.0 diff --git a/integration/src/main/kotlin/com/ccai/integration/TestMain.kt b/integration/src/main/kotlin/com/ccai/integration/TestMain.kt index d32c3b5..d748ff4 100644 --- a/integration/src/main/kotlin/com/ccai/integration/TestMain.kt +++ b/integration/src/main/kotlin/com/ccai/integration/TestMain.kt @@ -16,9 +16,10 @@ import java.util.Base64 import kotlin.system.exitProcess // --------------------------------------------------------------------------- -// CCAI Java (Kotlin) SDK Integration Tests — 52 tests +// CCAI Java (Kotlin) SDK Integration Tests — 54 tests // Covers: SMS (1-6), MMS (7-17), Email (18-22), Webhook (23-29), Contact (30-31), -// Brands (32-36), Campaigns (37-42), ContactValidator (43-46), Negative cases (47-52) +// Brands (32-36), Campaigns (37-42), ContactValidator (43-46), Negative cases (47-52), +// SMS Templates (53-54) // // Test results use three states: // PASS — the test ran and all assertions held @@ -40,7 +41,7 @@ val requiredEnv = listOf( "CCAI_TEST_FIRST_NAME", "CCAI_TEST_LAST_NAME", "CCAI_TEST_FIRST_NAME_2", "CCAI_TEST_LAST_NAME_2", "CCAI_TEST_FIRST_NAME_3", "CCAI_TEST_LAST_NAME_3", - "WEBHOOK_URL" + "WEBHOOK_URL", "CCAI_TEST_TEMPLATE_ID" ) val clientId = System.getenv("CCAI_CLIENT_ID") ?: "" @@ -57,6 +58,7 @@ val first2 = System.getenv("CCAI_TEST_FIRST_NAME_2") ?: "" val last2 = System.getenv("CCAI_TEST_LAST_NAME_2") ?: "" val first3 = System.getenv("CCAI_TEST_FIRST_NAME_3") ?: "" val last3 = System.getenv("CCAI_TEST_LAST_NAME_3") ?: "" +val templateId = System.getenv("CCAI_TEST_TEMPLATE_ID")?.toLongOrNull() ?: 0L // Unique per-run suffix so parallel SDK runs don't collide on the same webhook URL val runId = "java-${System.currentTimeMillis() / 1000}" @@ -197,9 +199,12 @@ fun main() { runTest("06 SMS sendSingle with customData") { val res = client.sms.sendSingle( - first1, last1, phone1, - "Custom data test", "Java Test 06", - """{"source":"java-integration"}""" + firstName = first1, + lastName = last1, + phone = phone1, + message = "Custom data test", + title = "Java Test 06", + customData = """{"source":"java-integration"}""" ) check(res.id.isNotBlank()) { "Empty id in response" } } @@ -693,6 +698,19 @@ fun main() { ) assertMmsResponse(res) } + + println("\n--- SMS Templates ---") + + runTest("53 SMS sendWithTemplate") { + val accounts = listOf(SmsAccount(first1, last1, phone1), SmsAccount(first2, last2, phone2)) + val res = client.sms.sendWithTemplate(accounts, templateId, "Java Template Test") + check(res.id.isNotBlank()) { "Empty id in response" } + } + + runTest("54 SMS sendSingleWithTemplate") { + val res = client.sms.sendSingleWithTemplate(first1, last1, phone1, templateId, "Java Single Template Test") + check(res.id.isNotBlank()) { "Empty id in response" } + } } finally { // ------------------------------------------------------------------- // Cleanup — always runs, even if the test body threw: delete leftover diff --git a/pom.xml b/pom.xml index c302f6d..0f59db0 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.cloudcontactai ccai-java-sdk - 1.1.0 + 1.2.0 jar CCAI Java SDK diff --git a/src/main/kotlin/com/cloudcontactai/sdk/sms/SMSService.kt b/src/main/kotlin/com/cloudcontactai/sdk/sms/SMSService.kt index d96a820..5e0bd49 100644 --- a/src/main/kotlin/com/cloudcontactai/sdk/sms/SMSService.kt +++ b/src/main/kotlin/com/cloudcontactai/sdk/sms/SMSService.kt @@ -4,7 +4,7 @@ import com.cloudcontactai.sdk.common.ApiClient import com.cloudcontactai.sdk.common.CCAIConfig class SMSService(private val config: CCAIConfig, private val apiClient: ApiClient) { - + fun sendSingle( firstName: String, lastName: String, @@ -17,7 +17,7 @@ class SMSService(private val config: CCAIConfig, private val apiClient: ApiClien lastName = lastName, phone = phone ) - + return send(listOf(account), message, title) } @@ -56,7 +56,7 @@ class SMSService(private val config: CCAIConfig, private val apiClient: ApiClien return send(listOf(account), message, title, senderPhone) } - + fun send( accounts: List, message: String, @@ -71,9 +71,9 @@ class SMSService(private val config: CCAIConfig, private val apiClient: ApiClien senderPhone = senderPhone, templateId = templateId ) - + val headers = mapOf("ForceNewCampaign" to "false") - + return apiClient.request( method = "POST", endpoint = "/clients/${config.clientId}/campaigns/direct", @@ -103,7 +103,7 @@ class SMSService(private val config: CCAIConfig, private val apiClient: ApiClien val account = Account(firstName = firstName, lastName = lastName, phone = phone) return sendWithTemplate(listOf(account), templateId, title, senderPhone) } - + fun getCampaignStatus(campaignId: String): SMSCampaignStatus { return apiClient.request( method = "GET",