Skip to content

Commit

Permalink
feat (Numbers): Sync client with 'readonly' field declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
JPPortier committed Sep 27, 2024
1 parent c8bd7cd commit 32a8c27
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void convert() {

ScheduledSmsProvisioning converted =
ScheduledSmsProvisioningDtoConverter.convert(
SmsConfigurationDtoTest.configuration.getScheduledProvisioning());
SmsConfigurationDtoTest.configurationResponse.getScheduledProvisioning());
TestHelpers.recursiveEquals(provisioning, converted);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void convert() {

ScheduledVoiceProvisioning converted =
ScheduledVoiceProvisioningDtoConverter.convert(
VoiceConfigurationDtoTest.configurationRTC.getScheduledProvisioning());
VoiceConfigurationDtoTest.configurationResponseRTC.getScheduledProvisioning());
TestHelpers.recursiveEquals(provisioning, converted);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SmsConfigurationDtoConverterTest {
void convertDto() {

SMSConfiguration converted =
SmsConfigurationDtoConverter.convert(SmsConfigurationDtoTest.configuration);
SmsConfigurationDtoConverter.convert(SmsConfigurationDtoTest.configurationResponse);
TestHelpers.recursiveEquals(configuration, converted);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class VoiceConfigurationDtoConverterTest {
void convert() {

VoiceConfiguration converted =
VoiceConfigurationDtoConverter.convert(VoiceConfigurationDtoTest.configurationRTC);
VoiceConfigurationDtoConverter.convert(VoiceConfigurationDtoTest.configurationResponseRTC);
TestHelpers.recursiveEquals(configuration, converted);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class ActiveNumberDtoTest extends NumbersBaseTest {
.setPaymentIntervalMonths(1)
.setNextChargeDate(Instant.parse("2023-09-22T15:49:58.813424Z"))
.setExpireAt(Instant.parse("2023-10-06T15:49:58.813381Z"))
.setSmsConfiguration(SmsConfigurationDtoTest.configuration)
.setVoiceConfiguration(VoiceConfigurationDtoTest.configurationRTC)
.setSmsConfiguration(SmsConfigurationDtoTest.configurationResponse)
.setVoiceConfiguration(VoiceConfigurationDtoTest.configurationResponseRTC)
.setCallbackUrl("foo callback")
.build();

Expand Down Expand Up @@ -95,14 +95,6 @@ public class ActiveNumberDtoTest extends NumbersBaseTest {
.setTotalSize(1)
.build();

@Test
void serialize() throws JsonProcessingException, JSONException {

String serializedString = objectMapper.writeValueAsString(activeNumber);

JSONAssert.assertEquals(activeNumberJson, serializedString, true);
}

@Test
void deserialize() throws JsonProcessingException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import com.sinch.sdk.domains.numbers.api.v1.adapters.NumbersBaseTest;
import com.sinch.sdk.domains.numbers.models.v1.internal.ScheduledVoiceProvisioningInternalImpl;
import java.time.Instant;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;

@TestWithResources
public class ScheduledVoiceProvisioningDtoTest extends NumbersBaseTest {
Expand Down Expand Up @@ -43,14 +41,6 @@ public class ScheduledVoiceProvisioningDtoTest extends NumbersBaseTest {
.setLastUpdatedTime(Instant.parse("2024-07-01T11:58:35.610198Z"))
.build();

@Test
void serializeEST() throws JsonProcessingException, JSONException {

String serializedString = objectMapper.writeValueAsString(provisioningEST);

JSONAssert.assertEquals(provisioningJsonEST, serializedString, true);
}

@Test
void deserializeEST() throws JsonProcessingException {

Expand All @@ -61,14 +51,6 @@ void deserializeEST() throws JsonProcessingException {
provisioningEST, deserializedString.getScheduledVoiceProvisioningESTImpl());
}

@Test
void serializeFAX() throws JsonProcessingException, JSONException {

String serializedString = objectMapper.writeValueAsString(provisioningFAX);

JSONAssert.assertEquals(provisioningJsonFAX, serializedString, true);
}

@Test
void deserializeFAX() throws JsonProcessingException {

Expand All @@ -79,14 +61,6 @@ void deserializeFAX() throws JsonProcessingException {
provisioningFAX, deserializedString.getScheduledVoiceProvisioningFAXImpl());
}

@Test
void serializeRTC() throws JsonProcessingException, JSONException {

String serializedString = objectMapper.writeValueAsString(provisioningRTC);

JSONAssert.assertEquals(provisioningJsonRTC, serializedString, true);
}

@Test
void deserializeRTC() throws JsonProcessingException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@
@TestWithResources
public class SmsConfigurationDtoTest extends NumbersBaseTest {

@GivenTextResource("/domains/numbers/v1/active/SmsConfigurationDto.json")
String configurationJSON;
@GivenTextResource("/domains/numbers/v1/active/SmsConfigurationRequestDto.json")
String configurationRequestJSON;

@GivenTextResource("/domains/numbers/v1/active/SmsConfigurationResponseDto.json")
String configurationResponseJSON;

@GivenTextResource("/domains/numbers/v1/active/SmsConfigurationDtoServicePlanIdNull.json")
String SMSConfigurationDtoServicePlanIdNull;

@GivenTextResource("/domains/numbers/v1/active/SmsConfigurationDtoServicePlanIdValue.json")
String SMSConfigurationDtoServicePlanIdValue;

public static SmsConfiguration configuration =
public static SmsConfiguration configurationRequest =
SmsConfiguration.builder()
.setServicePlanId("service plan id")
.setCampaignId("campaign id")
.build();
public static SmsConfiguration configurationResponse =
SmsConfiguration.builder()
.setServicePlanId("service plan id")
.setCampaignId("campaign id")
Expand All @@ -44,18 +52,18 @@ public class SmsConfigurationDtoTest extends NumbersBaseTest {
@Test
void serialize() throws JsonProcessingException, JSONException {

String serializedString = objectMapper.writeValueAsString(configuration);
String serializedString = objectMapper.writeValueAsString(configurationRequest);

JSONAssert.assertEquals(configurationJSON, serializedString, true);
JSONAssert.assertEquals(configurationRequestJSON, serializedString, true);
}

@Test
void deserialize() throws JsonProcessingException {

SmsConfiguration deserializedString =
objectMapper.readValue(configurationJSON, configuration.getClass());
objectMapper.readValue(configurationResponseJSON, SmsConfiguration.class);

TestHelpers.recursiveEquals(configuration, deserializedString);
TestHelpers.recursiveEquals(configurationResponse, deserializedString);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,50 @@
@TestWithResources
public class VoiceConfigurationDtoTest extends NumbersBaseTest {

@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationDtoEST.json")
String configurationJsonEST;
@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationRequestDtoEST.json")
String configurationRequestJsonEST;

@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationDtoFAX.json")
String configurationJsonFAX;
@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationResponseDtoEST.json")
String configurationResponseJsonEST;

@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationDtoRTC.json")
String configurationJsonRTC;
@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationRequestDtoFAX.json")
String configurationRequestJsonFAX;

@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationResponseDtoFAX.json")
String configurationResponseJsonFAX;

@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationRequestDtoRTC.json")
String configurationRequestJsonRTC;

@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationResponseDtoRTC.json")
String configurationResponseJsonRTC;

@GivenTextResource("/domains/numbers/v1/active/VoiceConfigurationDtoRTCSwitchToFAX.json")
String configurationJsonRTCSwitchToFAX;

public static VoiceConfigurationEST configurationEST =
public static VoiceConfigurationEST configurationRequestEST =
VoiceConfigurationEST.builder().setTrunkId("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE").build();

public static VoiceConfigurationEST configurationResponseEST =
VoiceConfigurationEST.builder()
.setTrunkId("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE")
.setLastUpdatedTime(Instant.parse("2024-06-30T07:08:09.10Z"))
.setScheduledProvisioning(ScheduledVoiceProvisioningDtoTest.provisioningEST)
.build();
public static VoiceConfigurationFAX configurationRequestFAX =
VoiceConfigurationFAX.builder().setServiceId("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE").build();

public static VoiceConfigurationFAX configurationFAX =
public static VoiceConfigurationFAX configurationResponseFAX =
VoiceConfigurationFAX.builder()
.setServiceId("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE")
.setLastUpdatedTime(Instant.parse("2024-06-30T07:08:09.10Z"))
.setScheduledProvisioning(ScheduledVoiceProvisioningDtoTest.provisioningFAX)
.build();
public static VoiceConfigurationRTC configurationRTC =

public static VoiceConfigurationRTC configurationRequestRTC =
VoiceConfigurationRTC.builder().setAppId("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE").build();

public static VoiceConfigurationRTC configurationResponseRTC =
VoiceConfigurationRTC.builder()
.setAppId("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE")
.setLastUpdatedTime(Instant.parse("2024-06-30T07:08:09.10Z"))
Expand All @@ -56,52 +74,52 @@ public class VoiceConfigurationDtoTest extends NumbersBaseTest {
@Test
void serializeEST() throws JsonProcessingException, JSONException {

String serializedString = objectMapper.writeValueAsString(configurationEST);
String serializedString = objectMapper.writeValueAsString(configurationRequestEST);

JSONAssert.assertEquals(configurationJsonEST, serializedString, true);
JSONAssert.assertEquals(configurationRequestJsonEST, serializedString, true);
}

@Test
void deserializeEST() throws JsonProcessingException {

VoiceConfiguration deserializedString =
objectMapper.readValue(configurationJsonEST, VoiceConfigurationEST.class);
objectMapper.readValue(configurationResponseJsonEST, VoiceConfigurationEST.class);

TestHelpers.recursiveEquals(configurationEST, deserializedString);
TestHelpers.recursiveEquals(configurationResponseEST, deserializedString);
}

@Test
void serializeFAX() throws JsonProcessingException, JSONException {

String serializedString = objectMapper.writeValueAsString(configurationFAX);
String serializedString = objectMapper.writeValueAsString(configurationRequestFAX);

JSONAssert.assertEquals(configurationJsonFAX, serializedString, true);
JSONAssert.assertEquals(configurationRequestJsonFAX, serializedString, true);
}

@Test
void deserializeFAX() throws JsonProcessingException {

VoiceConfiguration deserializedString =
objectMapper.readValue(configurationJsonFAX, VoiceConfigurationFAX.class);
objectMapper.readValue(configurationResponseJsonFAX, VoiceConfigurationFAX.class);

TestHelpers.recursiveEquals(configurationFAX, deserializedString);
TestHelpers.recursiveEquals(configurationResponseFAX, deserializedString);
}

@Test
void serializeRTC() throws JsonProcessingException, JSONException {

String serializedString = objectMapper.writeValueAsString(configurationRTC);
String serializedString = objectMapper.writeValueAsString(configurationRequestRTC);

JSONAssert.assertEquals(configurationJsonRTC, serializedString, true);
JSONAssert.assertEquals(configurationRequestJsonRTC, serializedString, true);
}

@Test
void deserializeRTC() throws JsonProcessingException {

VoiceConfiguration deserializedString =
objectMapper.readValue(configurationJsonRTC, VoiceConfigurationRTC.class);
objectMapper.readValue(configurationResponseJsonRTC, VoiceConfigurationRTC.class);

TestHelpers.recursiveEquals(configurationRTC, deserializedString);
TestHelpers.recursiveEquals(configurationResponseRTC, deserializedString);
}

@Test
Expand All @@ -117,7 +135,7 @@ void deserializeRTCSwitchToFax() throws JsonProcessingException {
void deserialize() throws JsonProcessingException {

VoiceConfigurationInternalImpl deserializedString =
objectMapper.readValue(configurationJsonRTC, VoiceConfigurationInternalImpl.class);
TestHelpers.recursiveEquals(configurationRTC, deserializedString.getActualInstance());
objectMapper.readValue(configurationRequestJsonRTC, VoiceConfigurationInternalImpl.class);
TestHelpers.recursiveEquals(configurationRequestRTC, deserializedString.getActualInstance());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"servicePlanId": "service plan id",
"campaignId": "campaign id"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trunkId": "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE",
"type": "EST"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"serviceId": "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE",
"type": "FAX"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"appId": "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE",
"type": "RTC"
}

0 comments on commit 32a8c27

Please sign in to comment.