From 1f0d3edbc7fa6b41b6983b7e3cfcb90643a9d7b7 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Wed, 28 Feb 2024 09:07:09 +0100 Subject: [PATCH] refactor: SMS context enable undefined region and default value is managed by SinchClient --- .../main/com/sinch/sdk/models/SmsContext.java | 4 ++-- .../test/java/com/sinch/sdk/SinchClientTest.java | 9 +++++++++ .../com/sinch/sdk/models/SmsContextTest.java | 16 ---------------- 3 files changed, 11 insertions(+), 18 deletions(-) delete mode 100644 client/src/test/java/com/sinch/sdk/models/SmsContextTest.java diff --git a/client/src/main/com/sinch/sdk/models/SmsContext.java b/client/src/main/com/sinch/sdk/models/SmsContext.java index 4b4b34db..30ca2cf7 100644 --- a/client/src/main/com/sinch/sdk/models/SmsContext.java +++ b/client/src/main/com/sinch/sdk/models/SmsContext.java @@ -9,8 +9,8 @@ public class SmsContext { private final SMSRegion smsRegion; private final String smsUrl; - public SmsContext(SMSRegion smsRegion, String smsUrl) { - this.smsRegion = null == smsRegion ? SMSRegion.US : smsRegion; + private SmsContext(SMSRegion smsRegion, String smsUrl) { + this.smsRegion = smsRegion; this.smsUrl = smsUrl; } diff --git a/client/src/test/java/com/sinch/sdk/SinchClientTest.java b/client/src/test/java/com/sinch/sdk/SinchClientTest.java index 9ac490cf..6ea229b0 100644 --- a/client/src/test/java/com/sinch/sdk/SinchClientTest.java +++ b/client/src/test/java/com/sinch/sdk/SinchClientTest.java @@ -34,6 +34,15 @@ void defaultSmsUrlAvailable() { assertNotNull(client.getConfiguration().getSmsContext().get().getSmsUrl()); } + @Test + void defaultSmsRegion() { + Configuration configuration = + Configuration.builder().setKeyId("foo").setKeySecret("foo").setProjectId("foo").build(); + SinchClient client = new SinchClient(configuration); + System.out.println(client.getConfiguration().getSmsContext().get().getSmsRegion()); + assertNotNull(client.getConfiguration().getSmsContext().get().getSmsRegion()); + } + @Test void defaultVerificationUrlAvailable() { Configuration configuration = diff --git a/client/src/test/java/com/sinch/sdk/models/SmsContextTest.java b/client/src/test/java/com/sinch/sdk/models/SmsContextTest.java deleted file mode 100644 index fc8d3b91..00000000 --- a/client/src/test/java/com/sinch/sdk/models/SmsContextTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.sinch.sdk.models; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class SmsContextTest { - - static final String SMS_SERVER = "%sfooSMS_SERVER"; - - @Test - void defaultUSForSmSRegion() { - SmsContext context = SmsContext.builder().setSmsUrl(SMS_SERVER).build(); - assertEquals(context.getSmsRegion(), SMSRegion.US); - } -}