diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java index 4880cfcf..2bf8b595 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java @@ -1,9 +1,7 @@ package com.sinch.sdk.domains.sms.models.dto.v1; import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; -import com.adelean.inject.resources.junit.jupiter.GivenTextResource; import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.fasterxml.jackson.core.JsonProcessingException; import com.sinch.sdk.BaseTest; import java.time.OffsetDateTime; import java.util.AbstractMap; @@ -12,19 +10,14 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.assertj.core.api.Assertions; -import org.json.JSONException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.skyscreamer.jsonassert.JSONAssert; @TestWithResources class MediaResponseDtoTest extends BaseTest { @GivenJsonResource("/domains/sms/v1/batches/response/BatchMediaDto.json") MediaResponseDto loadedDto; - @GivenTextResource("/domains/sms/v1/batches/response/BatchMediaDto.json") - String jsonStringDto; - ParameterObjDto parameterObjDto = new ParameterObjDto(); MediaResponseDto mediaDTO = @@ -56,14 +49,6 @@ void deserialize() { Assertions.assertThat(loadedDto).usingRecursiveComparison().isEqualTo(mediaDTO); } - @Test - void serialize() throws JsonProcessingException, JSONException { - - String serializedString = objectMapper.writeValueAsString(mediaDTO); - - JSONAssert.assertEquals(jsonStringDto, serializedString, true); - } - @BeforeEach void setUp() { parameterObjDto.put( diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java index d7361cfd..d9caae8a 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java @@ -22,7 +22,7 @@ class SendSMSRequestDtoTest extends BaseTest { @GivenTextResource("/domains/sms/v1/batches/request/TextRequestDto.json") String jsonRequestTextDto; - @GivenTextResource("/domains/sms/v1/batches/request/MediaRequestDto.json") + @GivenTextResource("/domains/sms/v1/MediaRequestDto.json") String jsonRequestMediaDto; @Test diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyDtoTest.java new file mode 100644 index 00000000..de3daff1 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyDtoTest.java @@ -0,0 +1,41 @@ +package com.sinch.sdk.domains.sms.models.v1.batches; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.TestHelpers; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +public class MediaBodyDtoTest extends BaseTest { + @GivenTextResource("/domains/sms/v1/batches/MediaBodyDto.json") + String jsonMediaBodyDto; + + @GivenJsonResource("/domains/sms/v1/batches/MediaBodyDto.json") + MediaBody loadedMediaBodyDto; + + public static final MediaBody mediaBodyDto = + MediaBody.builder() + .setSubject("subject field") + .setUrl("https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") + .setMessage("Hi ${name} ({an identifier}) ! How are you?") + .build(); + + @Test + void serialize() throws JsonProcessingException, JSONException { + + String serializedString = objectMapper.writeValueAsString(mediaBodyDto); + + JSONAssert.assertEquals(jsonMediaBodyDto, serializedString, true); + } + + @Test + void deserialize() { + + TestHelpers.recursiveEquals(loadedMediaBodyDto, mediaBodyDto); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendBatchRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendBatchRequestDtoTest.java index 948deeb1..6e473a46 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendBatchRequestDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendBatchRequestDtoTest.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.sinch.sdk.BaseTest; import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; -import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBodyDtoTest; import java.time.Instant; import java.util.AbstractMap; import java.util.Arrays; @@ -122,12 +122,7 @@ void serializeMediaRequestDto() throws JsonProcessingException, JSONException { MediaRequest mediaRequestDTO = MediaRequest.builder() .setTo(Arrays.asList("+15551231234", "+15551256344")) - .setBody( - MediaBody.builder() - .setUrl( - "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") - .setMessage("Hi ${name} ({an identifier}) ! How are you?") - .build()) + .setBody(MediaBodyDtoTest.mediaBodyDto) .setFrom("+15551231234") .setDeliveryReport(DeliveryReportType.SUMMARY) .setSendAt(Instant.parse("2019-08-24T14:16:22Z")) diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/SendBatchResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/SendBatchResponseDtoTest.java index 388c040b..ab5f6c32 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/SendBatchResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/SendBatchResponseDtoTest.java @@ -5,7 +5,7 @@ import com.sinch.sdk.BaseTest; import com.sinch.sdk.core.TestHelpers; import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; -import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBodyDtoTest; import java.time.Instant; import java.util.AbstractMap; import java.util.Arrays; @@ -92,12 +92,7 @@ class SendBatchResponseDtoTest extends BaseTest { .setCanceled(false) .setCreatedAt(Instant.parse("2019-08-24T14:14:22Z")) .setModifiedAt(Instant.parse("2019-08-24T14:15:22Z")) - .setBody( - MediaBody.builder() - .setUrl( - "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") - .setMessage("Hi ${name} ({an identifier}) ! How are you?") - .build()) + .setBody(MediaBodyDtoTest.mediaBodyDto) .setCallbackUrl("callback url") .setClientReference("client reference") .setDeliveryReport(DeliveryReportType.SUMMARY) diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/MediaRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/MediaRequestDto.json new file mode 100644 index 00000000..b9622412 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/MediaRequestDto.json @@ -0,0 +1,30 @@ +{ + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "body": { + "message": "Hi ${name} ({an identifier}) ! How are you?", + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" + }, + "parameters": { + "name": { + "15551231234": "name value for 15551231234", + "15551256344": "name value for 15551256344", + "default": "default value" + }, + "an identifier": { + "15551231234": "an identifier value for 15551231234", + "15551256344": "an identifier value for 15551256344" + } + }, + "type": "mt_media", + "delivery_report": "summary", + "send_at": "2019-08-24T14:16:22Z", + "expire_at": "2019-08-24T14:17:22Z", + "callback_url": "callback url", + "client_reference": "client reference", + "feedback_enabled": false, + "strict_validation": true +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/MediaBodyDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/MediaBodyDto.json new file mode 100644 index 00000000..22a59e62 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/MediaBodyDto.json @@ -0,0 +1,5 @@ +{ + "subject": "subject field", + "message": "Hi ${name} ({an identifier}) ! How are you?", + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/MediaRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/MediaRequestDto.json index b9622412..d48fc1e5 100644 --- a/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/MediaRequestDto.json +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/MediaRequestDto.json @@ -6,7 +6,8 @@ "from": "+15551231234", "body": { "message": "Hi ${name} ({an identifier}) ! How are you?", - "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png", + "subject": "subject field" }, "parameters": { "name": { diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/BatchMediaDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/BatchMediaDto.json index 91949c12..7c1143b4 100644 --- a/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/BatchMediaDto.json +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/BatchMediaDto.json @@ -8,7 +8,8 @@ "canceled": false, "body": { "message": "Hi ${name} ({an identifier}) ! How are you?", - "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png", + "subject": "subject field" }, "parameters": { "name": {